volmetrics

changeset 1:cca2e05dbabe

display one slide (debugging)
author Eleni Maria Stea <eleni@mutantstargoat.com>
date Sat, 11 Jan 2014 17:50:16 +0200
parents 88d390af583f
children 46a24c493efd
files src/main.cc src/volume.h
diffstat 2 files changed, 44 insertions(+), 6 deletions(-) [+]
line diff
     1.1 --- a/src/main.cc	Sat Jan 11 17:22:36 2014 +0200
     1.2 +++ b/src/main.cc	Sat Jan 11 17:50:16 2014 +0200
     1.3 @@ -4,6 +4,8 @@
     1.4  #include <stdio.h>
     1.5  #include <assert.h>
     1.6  
     1.7 +#include "image.h"
     1.8 +
     1.9  //static void init(void);
    1.10  static void display(void);
    1.11  static void reshape(int x, int y);
    1.12 @@ -13,6 +15,13 @@
    1.13  
    1.14  static int win_xsz, win_ysz;
    1.15  
    1.16 +/////////////////////////////
    1.17 +// debug TODO remove
    1.18 +////////////////////////////
    1.19 +static bool init();
    1.20 +Image img;
    1.21 +unsigned int tex;
    1.22 +
    1.23  int main(int argc, char **argv)
    1.24  {
    1.25  	glutInit(&argc, argv);
    1.26 @@ -30,6 +39,10 @@
    1.27  	glutMotionFunc(motion);
    1.28  
    1.29  	glewInit();
    1.30 +	if(!init()) {
    1.31 +		fprintf(stderr, "Failed to initialize La votre Colonoscopie\n");
    1.32 +		return 1;
    1.33 +	}
    1.34  
    1.35  	//call init
    1.36  
    1.37 @@ -37,15 +50,18 @@
    1.38  	return 0;
    1.39  }
    1.40  
    1.41 -int init(void)
    1.42 -{
    1.43 -	//TODO
    1.44 -	return 0;
    1.45 -}
    1.46 -
    1.47  void display(void)
    1.48  {
    1.49  	//render
    1.50 +	glBindTexture(GL_TEXTURE_2D, tex);
    1.51 +	glEnable(GL_TEXTURE_2D);
    1.52 +	glBegin(GL_QUADS);
    1.53 +	glTexCoord2f(0, 0); glVertex3f(-1, -1, 0);
    1.54 +	glTexCoord2f(0, 1); glVertex3f(-1, 1, 0);
    1.55 +	glTexCoord2f(1, 1); glVertex3f(1, 1, 0);
    1.56 +	glTexCoord2f(1, 0); glVertex3f(1, -1, 0);
    1.57 +	glEnd();
    1.58 +	glDisable(GL_TEXTURE_2D);
    1.59  
    1.60  	glutSwapBuffers();
    1.61  	assert(glGetError() == GL_NO_ERROR);
    1.62 @@ -85,3 +101,20 @@
    1.63  	prev_x = x;
    1.64  	prev_y = y;
    1.65  }
    1.66 +
    1.67 +bool init()
    1.68 +{
    1.69 +	if(!img.load("data/la_colonoscopie/IM-0001-0248.png")) {
    1.70 +		fprintf(stderr, "Failed to load votre Colonoscopie\n");
    1.71 +		return false;
    1.72 +	}
    1.73 +
    1.74 +	glGenTextures(1, &tex);
    1.75 +	glBindTexture(GL_TEXTURE_2D, tex);
    1.76 +	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    1.77 +	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    1.78 +	glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE16F_ARB, img.get_width(),
    1.79 +			img.get_height(), 0, GL_LUMINANCE, GL_FLOAT, img.get_pixels());
    1.80 +
    1.81 +	return true;
    1.82 +}
     2.1 --- a/src/volume.h	Sat Jan 11 17:22:36 2014 +0200
     2.2 +++ b/src/volume.h	Sat Jan 11 17:50:16 2014 +0200
     2.3 @@ -1,4 +1,9 @@
     2.4  #ifndef VOLUME_H_
     2.5  #define VOLUME_H_
     2.6  
     2.7 +class Volume {
     2.8 +private:
     2.9 +
    2.10 +};
    2.11 +
    2.12  #endif // VOLUME_H_