Hi,
I’ve got some 2D images representing cuts of a 3D volume in a program and I need to make the contour of those 2D images (managed as textures) in order to define the volume.
I use glVertex*f for this purpose but can’t get to see any lines…
Some lines of code :
void init (void) {
glEnable (GL_TEXTURE_2D);
glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
glGenTextures (1, texture_id);
glBindTexture (GL_TEXTURE_2D, texture_id[0]);
load_texture (“test.dcm”);
//Have tried with depth test on and off
//glEnable (GL_DEPTH_TEST);
glClearColor (0.0, 0.0, 0.0, 0.0);
}
void draw_texture (int number) {
float tempX= -0.5f+panX0+panX, tempY=-0.5f+panY0+panY;
int i;
//change filtering for performance when zooming
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filtre);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filtre);
glPushMatrix ();
glColor3f (1.0, 1.0, 1.0);
glBindTexture (GL_TEXTURE_2D, texture_id[number]);
glBegin (GL_QUADS); //apply texture (512512)
glTexCoord2f(0.0f, 0.0f); glVertex3f(tempX, tempY, depth_factor);
glTexCoord2f(1.0f, 0.0f); glVertex3f(tempX+1.0F, tempY, depth_factor);
glTexCoord2f(1.0f, 1.0f); glVertex3f(tempX+1.0F, tempY+1.0F, depth_factor);
glTexCoord2f(0.0f, 1.0f); glVertex3f(tempX, tempY+1.0F, depth_factor);
glEnd ();
glColor3f (1.0, 0.0, 0.0);
/ try to draw the line on top (tried also glVertex3f with any z coordonates
from texture.z-3.0f to texture.z+3.0f without results) */
glBegin (GL_LINE_LOOP);
for (i=0; i<C1.nbr; ++i) //draw the contour
glVertex2f(C1[i].x,C1[i].yF);
glEnd ();
glPopMatrix ( );
}
void display ( void ) {
//tried with the depth bit as well
//glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClear (GL_COLOR_BUFFER_BIT);
glPushMatrix ();
draw_texture (0);
glPopMatrix ();
glutSwapBuffers ();
}
void reshape ( int w, int h ) {
glViewport (0, 0, (GLint) w, (GLint) h);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gluPerspective (60, (GLdouble)w/ (GLdouble)h, 0.1, 1000.0); //not a special one… enabling to zoom near and far the picture
//glOrtho(0, 256, 256, 0, 0, -10);
glMatrixMode (GL_MODELVIEW);
glLoadIdentity ();
}
Any help is welcome
Thanks.
acerb