void draw()
{
GLint previous[2];
glGetIntegerv( GL_POLYGON_MODE, previous );
glPolygonMode( GL_FRONT_AND_BACK, GL_LINE ); // We want wire-frame mode
// Do some drawing
glPolygonMode( previous[0], previous[1] );
}
[SOLVED] glGet() problem
Hi, I have a draw() routine for a specific shape that I draw. I draw this shape in wire-frame, so I attempt to call glGet() to get the current polygon mode and then set this mode when I'm done drawing as to retain the previous state. Here's some sample code: The problem is that glGet() is filling the entire previous array with the same value. When I come around to setting glPolygonMode() (at the bottom of the snippet), it doesn't change the state back to the default which should be GL_FILL. Since the state isn't changed, all of my other meshes draw in wireframe. Note that in this specific scenario, glPolygonMode() has never been called before glGet() is called. So basically I'm querying the default state (whatever that may be). Can anyone tell me why this isn't working? Thanks. [Edited by - MrDoomMaster on November 27, 2007 11:00:50 AM]
According to what I read, previous[0] will contains the state for front facing polygons and previous[1] would contain state for back facing polygons.
Isn't it just simpler to call glPolygonMode( GL_FRONT_AND_BACK, GL_FILL)?
Isn't it just simpler to call glPolygonMode( GL_FRONT_AND_BACK, GL_FILL)?
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
Quote:
Isn't it just simpler to call glPolygonMode( GL_FRONT_AND_BACK, GL_FILL)?
.. or use glPushAttrib(GL_POLYGON_BIT) and glPopAttrib()
do unto others... and then run like hell.
Quote:
Original post by FReY Quote:
Isn't it just simpler to call glPolygonMode( GL_FRONT_AND_BACK, GL_FILL)?
.. or use glPushAttrib(GL_POLYGON_BIT) and glPopAttrib()
Great idea! I like this much better. However, it concerns me that glGet() is so useless. I should still be able to achieve the same results using glGet(), correct?
Ah, I should have checked your code more closely and indeed there is a bug. This is what you should have (according to my OpenGL reference)
GLint previous[2]; glGetIntegerv( GL_POLYGON_MODE, previous ); glPolygonMode( GL_FRONT_AND_BACK, GL_LINE ); // We want wire-frame mode // Do some drawing glPolygonMode( GL_FRONT, previous[0] ); glPolygonMode( GL_BACK, previous[1] );
do unto others... and then run like hell.
Quote:
Original post by FReY
Ah, I should have checked your code more closely and indeed there is a bug. This is what you should have (according to my OpenGL reference)
*** Source Snippet Removed ***
I see now. I misunderstood the documentation then. Thank you very much for the help. Indeed, I do like glPushAttrib() better. I didn't know they existed.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement