volmetrics

diff src/main.cc @ 18:4e02e18e70ef

quick backup - shaders 4 transfer function preview
author Eleni Maria Stea <elene.mst@gmail.com>
date Mon, 24 Mar 2014 23:28:08 +0200
parents 0f4fff558737
children 21bc62bb3e14
line diff
     1.1 --- a/src/main.cc	Mon Mar 03 23:12:13 2014 +0200
     1.2 +++ b/src/main.cc	Mon Mar 24 23:28:08 2014 +0200
     1.3 @@ -19,15 +19,15 @@
     1.4  static void keyboard_up(unsigned char key, int x, int y);
     1.5  static void mouse(int button, int state, int x, int y);
     1.6  static void motion(int x, int y);
     1.7 -
     1.8  static bool init_xfer(void);
     1.9  static void display_xfer(void);
    1.10  static void reshape_xfer(int x, int y);
    1.11  static void mouse_xfer(int button, int state, int x, int y);
    1.12  static void motion_xfer(int x, int y);
    1.13 -//todo keyb esc
    1.14 +static void volume_preview ();
    1.15  
    1.16  static int mainwin_id, xferwin_id;
    1.17 +//todo keyb esc
    1.18  
    1.19  static int win_xsz, win_ysz;
    1.20  static float cam_phi, cam_theta, cam_dist = 6;
    1.21 @@ -171,6 +171,42 @@
    1.22  	return ui;
    1.23  }
    1.24  
    1.25 +static void volume_preview ()
    1.26 +{
    1.27 +	float aspect = win_xsz / win_ysz;
    1.28 +	float z = 0.0;
    1.29 +
    1.30 +	glDisable(GL_LIGHTING);
    1.31 +
    1.32 +	glMatrixMode(GL_MODELVIEW);
    1.33 +	glPushMatrix();
    1.34 +	glLoadIdentity();
    1.35 +
    1.36 +	glMatrixMode(GL_PROJECTION);
    1.37 +	glPushMatrix();
    1.38 +	glLoadIdentity();
    1.39 +	glOrtho(-aspect, aspect, -1.0, 1.0, -1.0, 1.0);
    1.40 +
    1.41 +	glBindTexture(GL_TEXTURE_3D, vol->get_texture());
    1.42 +	glEnable(GL_TEXTURE_3D);
    1.43 +	glBegin(GL_QUADS);
    1.44 +	glColor3f(1.0, 0.0, 0.0);
    1.45 +	glTexCoord3f(0, 0, z); glVertex3f(-1.0, 1.0, 0.0);
    1.46 +	glTexCoord3f(0, 1, z); glVertex3f(-1.0, 0.5, 0.0);
    1.47 +	glTexCoord3f(1, 1, z); glVertex3f(-0.5, 0.5, 0.0);
    1.48 +	glTexCoord3f(1, 0, z); glVertex3f(-0.5, 1.0, 0.0);
    1.49 +	glEnd();
    1.50 +	glDisable(GL_TEXTURE_3D);
    1.51 +
    1.52 +	glMatrixMode(GL_PROJECTION);
    1.53 +	glPopMatrix();
    1.54 +
    1.55 +	glMatrixMode(GL_MODELVIEW);
    1.56 +	glPopMatrix();
    1.57 +
    1.58 +	glEnable(GL_LIGHTING);
    1.59 +}
    1.60 +
    1.61  static void display(void)
    1.62  {
    1.63  	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    1.64 @@ -201,7 +237,7 @@
    1.65  	}
    1.66  	mesh->draw();
    1.67  
    1.68 -	//TODO: draw threshold
    1.69 +	volume_preview();
    1.70  	glutSwapBuffers();
    1.71  	assert(glGetError() == GL_NO_ERROR);
    1.72  }