# HG changeset patch # User Eleni Maria Stea # Date 1383692930 -7200 # Node ID b6de02e21d827a9b101289dcaf31148a68f9f8a2 # Parent 65fd6d7c42b1c7c62f55d3e0042522fbe53e7167 quick backup: todo: remove orthographic from background quad, calculate translation (fov), add subdivision diff -r 65fd6d7c42b1 -r b6de02e21d82 src/main.cc --- a/src/main.cc Tue Nov 05 00:24:25 2013 +0200 +++ b/src/main.cc Wed Nov 06 01:08:50 2013 +0200 @@ -6,12 +6,15 @@ #include "kinect.h" #include "frame.h" #include "tesquad.h" +#include "texture.h" freenect_context *kin_ctx; freenect_device *kin_dev; KinectParams kin_params; Frame *frame; +static const char *filename = "data/textures/wallpaper.jpg"; +static unsigned char tex; static bool show; static void cleanup(); @@ -46,24 +49,28 @@ glutKeyboardFunc(keyb); glutIdleFunc(idle); + atexit(cleanup); + glClearColor(1, 1, 1, 1); + frame = new Frame; + if(!(tex = load_texture(filename))) { + fprintf(stderr, "Failed to load texture: %s\n", filename); + exit(1); + } - atexit(cleanup); glutMainLoop(); } static void display() { - glClear(GL_COLOR_BUFFER_BIT); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - - glClearColor(1, 0, 0, 1); + glClearColor(1, 1, 1, 1); has_depth = false; has_video = false; - if(freenect_process_events(kin_ctx) != 0) { fprintf(stderr, "Failed to process events.\n"); exit(0); @@ -71,11 +78,14 @@ frame->process(); glEnable(GL_TEXTURE_2D); + glBindTexture(GL_TEXTURE_2D, tex); + draw_tess_quad(-1, -1, 2, 2, 1, 1, true); + if(show) { glBindTexture(GL_TEXTURE_2D, frame->video_tex); - draw_tess_quad(-1, -1, 1, 2, 1, 1); + draw_tess_quad(-1, -1, 1, 1, 1, 1, true); glBindTexture(GL_TEXTURE_2D, frame->depth_tex); - draw_tess_quad(0, -1, 1, 2, 1, 1); + draw_tess_quad(-1, 0, 1, 1, 1, 1, true); } glDisable(GL_TEXTURE_2D);