summaryrefslogtreecommitdiffstats
path: root/sdl/pyramid.c
diff options
context:
space:
mode:
Diffstat (limited to 'sdl/pyramid.c')
-rw-r--r--sdl/pyramid.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/sdl/pyramid.c b/sdl/pyramid.c
index 4fb2b6a..42c7a22 100644
--- a/sdl/pyramid.c
+++ b/sdl/pyramid.c
@@ -61,6 +61,9 @@ static struct
GLfloat xrot;
GLfloat yrot;
+ /* SDL surface, our screen */
+ SDL_Surface *screen;
+
SDL_TimerID timer_id;
SDL_Cursor *my_cursor;
} p;
@@ -173,20 +176,20 @@ static void platform_init(void)
p.ground_list = glGenLists(2);
p.triangle_list = p.ground_list + 1;
- /* a ground with grass drawn using magneta lines */
- glNewList(p.ground_list, GL_COMPILE);
- //glBindTexture(GL_TEXTURE_2D, p.textures[1]);
- glColor3ub(255, 0, 255);
- glDrawGround();
- glEndList();
-
/* a triangle with a texture */
glNewList(p.triangle_list, GL_COMPILE);
glBindTexture(GL_TEXTURE_2D, p.textures[0]);
+ /* glBindTexture(GL_TEXTURE_2D, p.textures[1]); */
glColor3f(1.0f, 1.0f, 1.0f);
glDrawTriangle();
glEndList();
+ /* a ground drawn using magneta lines */
+ glNewList(p.ground_list, GL_COMPILE);
+ glColor3ub(255, 0, 255);
+ glDrawGround();
+ glEndList();
+
/* add a simple timer / callback function */
p.timer_id = SDL_AddTimer(5000, sdlTimerCallback, &(p.camera));
@@ -199,6 +202,8 @@ static void platform_destroy(void)
{
glDeleteTextures(2, p.textures);
glDeleteLists(p.ground_list, 2);
+
+ SDL_FreeSurface(p.screen);
}
static void render(void)
@@ -210,7 +215,6 @@ static void render(void)
glPushMatrix();
/* apply camera transform, and draw the ground */
glframe_apply_camera_transform(&p.camera, 1);
-
glCallList(p.ground_list);
glPushMatrix();
@@ -225,7 +229,10 @@ static void render(void)
/* draw a snowman */
glTranslatef(0.0f, 0.0f, -7.0f);
+
+ glDisable(GL_TEXTURE_2D);
glDrawSnowman();
+ glEnable(GL_TEXTURE_2D);
/* restore the matrix state */
glPopMatrix();
@@ -236,11 +243,12 @@ static void render(void)
int main(int argc, char **argv)
{
- setup_sdl();
+ p.screen = setup_sdl();
setup_glew();
setup_opengl();
platform_init();
gltErrorCheck();
+ gltOpenGLInfo();
unsigned int startclock;
while (program_running)