element borders with textures

Hi!
I am displaying a 1D texture over my element mesh. I also want to display the mesh of the elements in white. How can i do that?
Juergen

You mean you want a white wireframe mesh on top of your filled, textured mesh?

Pretty simple:

  • Switch on glPolygonMode(GL_FRONT_AND_BACK, GL_LINE),
  • disable texturing and lighting,
  • set glColor3f(1.0f, 1.0f, 1.0f);
  • glEnable(GL_POLYGON_OFFSET_LINE) (Note, this is for glPolygonMode(…,GL_LINE), this doesn’t work GL_LINES, GL_LINE_LOOP, or G_LINE_STRIP.)
  • For perfect z-separation move the outlined polygons to the front with glPolygonOffset(1.0, -1.0) (values may need adjustment)
  • and render the same geometry again. Voila!

[This message has been edited by Relic (edited 06-18-2002).]

Hi!
I made the following:
glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
glBindTexture( GL_TEXTURE_1D, texResult );
glTexCoordPointer(1, GL_FLOAT, 0, result_damage);
glEnableClientState (GL_VERTEX_ARRAY);
glVertexPointer (3, GL_FLOAT, 0, vertices);
glDrawElements (GL_QUADS, numQuads4, GL_UNSIGNED_INT, elements_quad);
glDrawElements (GL_TRIANGLES, numTrias
3, GL_UNSIGNED_INT, elements_tria);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE),
glDisable(GL_TEXTURE_1D);
glColor3f(float(mesh_R)/255.,float(mesh_G)/255.,float(mesh_B)/255.);
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(1.,-1.);
glEnableClientState (GL_VERTEX_ARRAY);
glVertexPointer (3, GL_FLOAT, 0, vertices);
glDrawElements (GL_QUADS, numQuads4, GL_UNSIGNED_INT, elements_quad);
glDrawElements (GL_TRIANGLES, numTrias
3, GL_UNSIGNED_INT, elements_tria);

But the quality of the lines is very bad. They are not continous. whats the error?

You’re seeing the z-bleeding I mentioned.

The glEnable(GL_POLYGON_OFFSET_FILL); needs to be GL_POLYGON_OFFSET_LINE, as I said.

But I had the polygon offset factor parameter in the wrong z direction.
Try glPolygonOffset(-1.0f, -1.0f);
or (0.0f, -1.0f). Experiment with bigger values and read the docs, and you’ll figure it out.

And make sure the polygon offset is disabled for again if you don’t want it to be applied in other routines.

(Well, you could also do it the other way round and move the filled geometry to the back and leave the wireframe in place.
That would involve switching glEnable(GL_POLYGON_OFFSET_FILL) for the filled mesh and polygon offsets with positive values.)

This one should work:
// Filled
glEnable(GL_TEXTURE_1D);
glBindTexture( GL_TEXTURE_1D, texResult );
glTexCoordPointer(1, GL_FLOAT, 0, result_damage);
glEnableClientState (GL_TEXTURE_COORD_ARRAY); // Missing?
glVertexPointer (3, GL_FLOAT, 0, vertices);
glEnableClientState (GL_VERTEX_ARRAY);
glDrawElements (GL_QUADS, numQuads4, GL_UNSIGNED_INT, elements_quad);
glDrawElements (GL_TRIANGLES, numTrias
3, GL_UNSIGNED_INT, elements_tria);

// Wireframe
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE),
glDisable(GL_TEXTURE_1D);
glDisableClientState (GL_TEXTURE_COORD_ARRAY); // Don’t send texcoords if texturing disabled.
glColor3f(float(mesh_R)/255.,float(mesh_G)/255.,float(mesh_B)/255.); (edit: // Better use glColor3ub or 3ubv if mesh_X are unsigned char?)
glEnable(GL_POLYGON_OFFSET_LINE);
glPolygonOffset(-1.,-1.);
// glEnableClientState (GL_VERTEX_ARRAY); // unchanged!
// glVertexPointer (3, GL_FLOAT, 0, vertices); // unchanged!
glDrawElements (GL_QUADS, numQuads4, GL_UNSIGNED_INT, elements_quad);
glDrawElements (GL_TRIANGLES, numTrias
3, GL_UNSIGNED_INT, elements_tria);
glDisable(GL_POLYGON_OFFSET_LINE);
glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);

[This message has been edited by Relic (edited 06-19-2002).]