summaryrefslogtreecommitdiffstats
path: root/sdl/GL_notes.txt
blob: 2c77ed908062f3180f10778c24b7bedfbf234830 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
Performance
- Depth Testing, aka Z-buffer
- Culling: don't render what you can't see

Ideas
- Use scissor test or bind texture for HUD display?

Terms
- Winding: by default, primitives that follow in CCW fashion are front facing

Projections
- Orthographic: glOrtho(), define visibility in a *volume*
- Perspective: gluPerspective()

Transformations
- Viewing: specifies the location of the viewer or camera (must be specified first)
- Modeling: moves objects around the scene
- Modelview: describes the duality of viewing and modeling transformations
- Projection: sizes and reshapes the viewing volume (squishing 3D data down into 2D)
- Viewport: a pseudo-transformation that scales the final output to the window

Matrices
- Modelview
- Projection
- Texture

Buffers
- Color Buffer
- Depth Buffer, aka Z-buffer
- Stencil Buffer
- Multisampling Buffer
- Accumulation Buffer: this buffer allows you to render to the color buffer, and
  then instead of displaying the results in the window, copy the contents of the
  color buffer to the accu-mulation buffer.
- Front Buffer
- Back Buffer

Lighting
- when lighting is enabled, we need to specify normals for each polygon face so
  OpenGL can calculate e.g. how light reflects

Fake Shadow
- drawing a shadow for the pyramid would require drawing things twice, so on 2nd
  pass we would draw with black color and multiply by squished matrix, we should
  get to this later with better approach

Terms
 - Dithering: simulate displaying wider range of colors on on systems with small
   amount of colors
 - Texture Filtering: process of calculating color fragments from a stretched or
   shrunken texture map
 - Fragments: color values placed in the color buffer
   
OBJ Loader
- glGenTextures()
- glBindTextures() 

Pipeline
- Display Lists: precompile series of OpenGL commands (static)
    GLuint identifiers
    1st identifier = glGenLists()
    glNewList()
        commands
    glEndList()
    
- Vertex Array: modifiable, gets rid of glBegin() and glEnd()
    glEnableClientState()
        glVertexPointer() || glTexCoordPointer() || glNormalPointer()
	    glDrawArrays() || glDrawElements()
    glDisableClientState()

Shadow Mapping
- getting the depth buffer from lights point of view of the scene, we don't swap
  we only care about raw geometry
  we regenerate the shadow map if the light or object moves, or window size changes
  first we draw the scene with dim lighting, then we double the the values of lighting
  once depth buffer is written to the backbuffer, we retrieve that into a texture, then
  lots of magic is done to project the texture/shadow map back into the final scene

Shaders
- VP: to mimick fixed functionality, multiply incoming vertex by MVP (modelview/projection matrices)
  if no transformation took place, just transfer the vertex data into next stage, clipping AFAIK

Vertex Shader--you can write code for tasks such as:
- Vertex position transformation using the modelview and projection matrices
- Normal transformation, and if required its normalization
- Texture coordinate generation and transformation
- Lighting per vertex or computing values for lighting per pixel
- Color computation

Fixed Functionality Pipeline
- glTranslatef: can be mimicked by building m3dTranslationMatrix44f
- glRotatef: can be mimicked by building m3dRotationMatrix44f
- Both of the matrices can be combined by multiplying them, and loaded by using glLoadMatrixf,
  but more efficient way is to let OpenGL do the multiplication for you by using glMultMatrixf