summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKyle K <kylek389@gmail.com>2010-10-15 02:46:10 -0500
committerKamil Kaminski <kamilkss@gmail.com>2010-10-15 02:46:10 -0500
commit4843f992664c1ddabe1d99755f8e2282af19a615 (patch)
treec4f059c25f3f1fd4b018286ff88bfc3a522ac603
parent26d4028354a0cc953f2f37fc9b5129fbb042ff31 (diff)
downloadGLPyramid-4843f992664c1ddabe1d99755f8e2282af19a615.tar.gz
GLPyramid-4843f992664c1ddabe1d99755f8e2282af19a615.tar.bz2
GLPyramid-4843f992664c1ddabe1d99755f8e2282af19a615.zip
pyramid: switch from immiediate redering to display list
-rw-r--r--sdl/GL_notes.txt6
-rw-r--r--sdl/pyramid.c24
2 files changed, 26 insertions, 4 deletions
diff --git a/sdl/GL_notes.txt b/sdl/GL_notes.txt
index c4d71fe..a370290 100644
--- a/sdl/GL_notes.txt
+++ b/sdl/GL_notes.txt
@@ -41,4 +41,8 @@ Terms
OBJ Loader
- glGenTextures()
- glBindTextures()
-
+
+Pipeline
+- Display Lists: precompile series of OpenGL commands (static)
+- Vertex Array: modifiable, gets rid of glBegin() and glEnd() ?
+
diff --git a/sdl/pyramid.c b/sdl/pyramid.c
index 689e9dd..783b2de 100644
--- a/sdl/pyramid.c
+++ b/sdl/pyramid.c
@@ -29,6 +29,10 @@
int program_running = 1;
GLFrame camera;
+/* display lists identifiers */
+GLuint ground_list;
+GLuint triangle_list;
+
static GLfloat xRot = 0.0f;
static GLfloat yRot = 0.0f;
@@ -148,6 +152,18 @@ static void setup_opengl(void)
/* don't know about this, but why not */
glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);
+
+ /* display list, precompile commands */
+ ground_list = glGenLists(2);
+ triangle_list = ground_list + 1;
+
+ glNewList(ground_list, GL_COMPILE);
+ gltDrawGround();
+ glEndList();
+
+ glNewList(triangle_list, GL_COMPILE);
+ gltDrawTriangle();
+ glEndList();
}
static void keys(SDL_keysym *keysym, unsigned int *keys_held, int flag)
@@ -247,7 +263,7 @@ static void render(void)
/* apply camera transform, and draw the ground */
glframe_apply_camera_transform(&camera);
glColor3ub(255, 0, 255);
- gltDrawGround();
+ glCallList(ground_list);
/* move object back and do in place rotation */
glTranslatef(0.0f, 0.2f, -3.5f);
@@ -256,7 +272,7 @@ static void render(void)
/* draw the pyramid */
glColor3f(1.0f, 1.0f, 1.0f);
- gltDrawTriangle();
+ glCallList(triangle_list);
/* restore the matrix state */
glPopMatrix();
@@ -343,10 +359,12 @@ int main(int argc, char **argv)
current_fps = 1000 / deltaclock;
static char buffer[30] = { 0 };
- sprintf(buffer, "Textured Pyramid: %04d fps", current_fps);
+ sprintf(buffer, "Textured Pyramid: %4d fps", current_fps);
SDL_WM_SetCaption(buffer, NULL);
#endif
}
+
+ glDeleteLists(ground_list, 2);
puts("bye!");
return 0;