volmetrics

diff src/main.cc @ 30:e548d95e0667

fixed lighting, added parameter for volume rotation
author Eleni Maria Stea <elene.mst@gmail.com>
date Thu, 01 May 2014 15:28:51 +0300
parents 77cbc31cd31f
children cfeecd093730
line diff
     1.1 --- a/src/main.cc	Sun Apr 27 21:07:10 2014 +0300
     1.2 +++ b/src/main.cc	Thu May 01 15:28:51 2014 +0300
     1.3 @@ -26,7 +26,6 @@
     1.4  static void mouse_xfer(int button, int state, int x, int y);
     1.5  static void motion_xfer(int x, int y);
     1.6  static void volume_preview();
     1.7 -static void draw_slices();
     1.8  static void draw_iso();
     1.9  static void draw_volume();
    1.10  
    1.11 @@ -94,10 +93,6 @@
    1.12  	glEnable(GL_DEPTH_TEST);
    1.13  	glEnable(GL_NORMALIZE);
    1.14  
    1.15 -	glEnable(GL_LIGHTING);
    1.16 -	glEnable(GL_LIGHT0);
    1.17 -	glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 1);
    1.18 -
    1.19  	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    1.20  
    1.21  	//FIXME shaders setup
    1.22 @@ -245,13 +240,15 @@
    1.23  	glEnd();
    1.24  	glDisable(GL_TEXTURE_3D);
    1.25  
    1.26 +	glUseProgram(0);
    1.27 +
    1.28  	glLineWidth(3);
    1.29  	glBegin(GL_LINE_LOOP);
    1.30  	glColor3f(0.4, 0.8, 0.4);
    1.31 -	glVertex3f(-1.0, 1.0, 0.0);
    1.32 -	glVertex3f(-1.0, 0.5, 0.0);
    1.33 -	glVertex3f(-0.5, 0.5, 0.0);
    1.34 -	glVertex3f(-0.5, 1.0, 0.0);
    1.35 +	glVertex3f(0, 1, 0);
    1.36 +	glVertex3f(0, 0.75, 0);
    1.37 +	glVertex3f(0.25, 0.75, 0);
    1.38 +	glVertex3f(0.25, 1, 0);
    1.39  	glEnd();
    1.40  
    1.41  	glMatrixMode(GL_PROJECTION);
    1.42 @@ -260,24 +257,9 @@
    1.43  	glMatrixMode(GL_MODELVIEW);
    1.44  	glPopMatrix();
    1.45  
    1.46 -	glUseProgram(0);
    1.47 -
    1.48  	glEnable(GL_DEPTH_TEST);
    1.49  }
    1.50  
    1.51 -static void draw_slices()
    1.52 -{
    1.53 -	glBindTexture(GL_TEXTURE_3D, vol->get_texture());
    1.54 -	glEnable(GL_TEXTURE_3D);
    1.55 -	glBegin(GL_QUADS);
    1.56 -	glTexCoord3f(0, 0, cur_z); glVertex3f(-1, -1, 0);
    1.57 -	glTexCoord3f(0, 1, cur_z); glVertex3f(-1, 1, 0);
    1.58 -	glTexCoord3f(1, 1, cur_z); glVertex3f(1, 1, 0);
    1.59 -	glTexCoord3f(1, 0, cur_z); glVertex3f(1, -1, 0);
    1.60 -	glEnd();
    1.61 -	glDisable(GL_TEXTURE_3D);
    1.62 -}
    1.63 -
    1.64  static void draw_iso()
    1.65  {
    1.66  	if(mesh->is_empty()) {
    1.67 @@ -304,6 +286,8 @@
    1.68  	if(res_loc != -1)
    1.69  		glUniform3f(res_loc, (float)vol_res[0], (float)vol_res[1], (float)vol_res[2]);
    1.70  
    1.71 +	glRotatef(-vol->get_volume_rotation(), 1, 0, 0);
    1.72 +
    1.73  	glDisable(GL_DEPTH_TEST);
    1.74  	glBindTexture(GL_TEXTURE_3D, vol->get_texture());
    1.75  	glEnable(GL_TEXTURE_3D);