# HG changeset patch # User Eleni Maria Stea # Date 1389455416 -7200 # Node ID cca2e05dbabe464fc5a03d018dde7698469a0baf # Parent 88d390af583f28f5096111c3872107a216e1afa8 display one slide (debugging) diff -r 88d390af583f -r cca2e05dbabe src/main.cc --- a/src/main.cc Sat Jan 11 17:22:36 2014 +0200 +++ b/src/main.cc Sat Jan 11 17:50:16 2014 +0200 @@ -4,6 +4,8 @@ #include #include +#include "image.h" + //static void init(void); static void display(void); static void reshape(int x, int y); @@ -13,6 +15,13 @@ static int win_xsz, win_ysz; +///////////////////////////// +// debug TODO remove +//////////////////////////// +static bool init(); +Image img; +unsigned int tex; + int main(int argc, char **argv) { glutInit(&argc, argv); @@ -30,6 +39,10 @@ glutMotionFunc(motion); glewInit(); + if(!init()) { + fprintf(stderr, "Failed to initialize La votre Colonoscopie\n"); + return 1; + } //call init @@ -37,15 +50,18 @@ return 0; } -int init(void) -{ - //TODO - return 0; -} - void display(void) { //render + glBindTexture(GL_TEXTURE_2D, tex); + glEnable(GL_TEXTURE_2D); + glBegin(GL_QUADS); + glTexCoord2f(0, 0); glVertex3f(-1, -1, 0); + glTexCoord2f(0, 1); glVertex3f(-1, 1, 0); + glTexCoord2f(1, 1); glVertex3f(1, 1, 0); + glTexCoord2f(1, 0); glVertex3f(1, -1, 0); + glEnd(); + glDisable(GL_TEXTURE_2D); glutSwapBuffers(); assert(glGetError() == GL_NO_ERROR); @@ -85,3 +101,20 @@ prev_x = x; prev_y = y; } + +bool init() +{ + if(!img.load("data/la_colonoscopie/IM-0001-0248.png")) { + fprintf(stderr, "Failed to load votre Colonoscopie\n"); + return false; + } + + glGenTextures(1, &tex); + glBindTexture(GL_TEXTURE_2D, tex); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE16F_ARB, img.get_width(), + img.get_height(), 0, GL_LUMINANCE, GL_FLOAT, img.get_pixels()); + + return true; +} diff -r 88d390af583f -r cca2e05dbabe src/volume.h --- a/src/volume.h Sat Jan 11 17:22:36 2014 +0200 +++ b/src/volume.h Sat Jan 11 17:50:16 2014 +0200 @@ -1,4 +1,9 @@ #ifndef VOLUME_H_ #define VOLUME_H_ +class Volume { +private: + +}; + #endif // VOLUME_H_