# HG changeset patch # User Eleni Maria Stea # Date 1384036618 -7200 # Node ID 136460b6c9afcf392562f81bed0a2fe05a2f4023 # Parent 97dad98482f5426044b232e7b5ff987b6d137c8e display lists diff -r 97dad98482f5 -r 136460b6c9af src/main.cc --- a/src/main.cc Wed Nov 06 21:04:45 2013 +0200 +++ b/src/main.cc Sun Nov 10 00:36:58 2013 +0200 @@ -8,16 +8,21 @@ #include "tesquad.h" #include "texture.h" +#define ASPECT 1 + freenect_context *kin_ctx; freenect_device *kin_dev; KinectParams kin_params; Frame *frame; static const char *filename = "data/textures/wallpaper.jpg"; +static unsigned int drawing; +static unsigned int debugging; static unsigned char tex; static bool show; static void cleanup(); +static void init(); static void display(); static void reshape(int w, int h); @@ -50,18 +55,7 @@ glutIdleFunc(idle); atexit(cleanup); - - glClearColor(1, 1, 1, 1); -// glGenList -// glNewList -// glEndList -// glCallList - - frame = new Frame; - if(!(tex = load_texture(filename))) { - fprintf(stderr, "Failed to load texture: %s\n", filename); - exit(1); - } + init(); glutMainLoop(); } @@ -72,7 +66,6 @@ glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - glClearColor(1, 1, 1, 1); has_depth = false; has_video = false; if(freenect_process_events(kin_ctx) != 0) { @@ -81,22 +74,11 @@ } frame->process(); - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - glTranslatef(0, 0, -24); - glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, tex); - draw_tess_quad(-14, -10, 28, 20, 600, 800); - glPopMatrix(); - glMatrixMode(GL_MODELVIEW); + glCallList(drawing); + if(show) + glCallList(debugging); - if(show) { - glBindTexture(GL_TEXTURE_2D, frame->video_tex); - draw_tess_quad(-1, -1, 1, 1, 1, 1, true); - glBindTexture(GL_TEXTURE_2D, frame->depth_tex); - draw_tess_quad(-1, 0, 1, 1, 1, 1, true); - } - glDisable(GL_TEXTURE_2D); + glFlush(); glutSwapBuffers(); } @@ -135,3 +117,39 @@ stop_kinect_frames(kin_dev); stop_kinect(kin_ctx, kin_dev); } + +static void init() +{ + glClearColor(1, 1, 1, 1); + + frame = new Frame; + if(!(tex = load_texture(filename))) { + fprintf(stderr, "Failed to load texture: %s\n", filename); + exit(1); + } + + drawing = glGenLists(1); + glNewList(drawing, GL_COMPILE); + + /* drawing */ + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glTranslatef(0, 0, -24); + glEnable(GL_TEXTURE_2D); + glBindTexture(GL_TEXTURE_2D, tex); + draw_tess_quad(-14, -14 * 1/ASPECT, 28, 28 * 1 / ASPECT, 850, 850 * 1 / ASPECT); + glDisable(GL_TEXTURE_2D); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); + glEndList(); + + debugging = glGenLists(1); + glNewList(debugging, GL_COMPILE); + glEnable(GL_TEXTURE_2D); + glBindTexture(GL_TEXTURE_2D, frame->video_tex); + draw_tess_quad(-1, -1, 1, 2, 1, 1, true); + glBindTexture(GL_TEXTURE_2D, frame->depth_tex); + draw_tess_quad(0, -1, 1, 2, 1, 1, true); + glDisable(GL_TEXTURE_2D); + glEndList(); +}