Perspective affects textures?
Im setting up a HUD in my game, and if I change the perspective to ortho to draw it the textures are messed up? And my mouse cursor appears behind the HUD even though depth testing is off and the cursor is draw very last.
heres my hud draw code
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(-4,4,-3,3,1,10);
glMatrixMode(GL_MODELVIEW);
draw_HUD();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
If I just simply call draw_HUD() then the textures are cursor problems are not there. I dont understand what could be wrong?
www.EberKain.comThere it is, Television, Look Listen Kneel Pray.
In my opinion, the textures will be messed up if you use texture matrix :
glMatrixMode(GL_TEXTURE);
Otherwise, I can say that this code is perfectly correct.
Personnaly I would load the identity in the modelview matrix, but that''s just a detail.
I think that you should post some code of the draw_HUD function/method, since the code that you wrote in your post has no problem.
glMatrixMode(GL_TEXTURE);
Otherwise, I can say that this code is perfectly correct.
Personnaly I would load the identity in the modelview matrix, but that''s just a detail.
I think that you should post some code of the draw_HUD function/method, since the code that you wrote in your post has no problem.
I dont actually have a draw_HUD function, If I dont use the perspective change everything is fine, but If I do use it my textures are not working right. None of the draw code is changeing. This one has me stumped.
www.EberKain.comThere it is, Television, Look Listen Kneel Pray.
Maybe you should try adding this line before the above hud code :
GLint matrix_mode;
glGetIntegerv(GL_MATRIX_MODE, &matrix_mode);
and this line after :
glMatrixMode(matrix_mode);
And there only other problem I can think of : the projection matrix stack depth.
OpenGL specifies that the projection matrix stack depth is at least 2, so if you push the projection matrix, say, 4 times then you''ll eventually experience matrix problems :
- at best, the error GL_STACK_OVERFLOW will be generated,
- at worst, matrices may overlap (eg OpenGL may compute projection matrix where the memory stores a texture matrix) if the drivers don''t implement exact OpenGL specifications.
In this second case, you should do try adding that line before the above hud code :
GLint matrix_mode;
glGetIntegerv(GL_MATRIX_MODE, &matrix_mode);
GLdouble texture_matrix[16];
glGetDoublev(GL_TEXTURE_MATRIX, texutre_matrix);
and add those lines after :
glMatrixMode(GL_TEXTURE);
glLoadMatrixd(texture_matrix);
glMatrixMode(matrix_mode);
if those modifications make your progrram working correctly, then you probably have some matrix overlap.
Hope that helps
GLint matrix_mode;
glGetIntegerv(GL_MATRIX_MODE, &matrix_mode);
and this line after :
glMatrixMode(matrix_mode);
And there only other problem I can think of : the projection matrix stack depth.
OpenGL specifies that the projection matrix stack depth is at least 2, so if you push the projection matrix, say, 4 times then you''ll eventually experience matrix problems :
- at best, the error GL_STACK_OVERFLOW will be generated,
- at worst, matrices may overlap (eg OpenGL may compute projection matrix where the memory stores a texture matrix) if the drivers don''t implement exact OpenGL specifications.
In this second case, you should do try adding that line before the above hud code :
GLint matrix_mode;
glGetIntegerv(GL_MATRIX_MODE, &matrix_mode);
GLdouble texture_matrix[16];
glGetDoublev(GL_TEXTURE_MATRIX, texutre_matrix);
and add those lines after :
glMatrixMode(GL_TEXTURE);
glLoadMatrixd(texture_matrix);
glMatrixMode(matrix_mode);
if those modifications make your progrram working correctly, then you probably have some matrix overlap.
Hope that helps
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement