[Solved] Restoring settings used before...

Started by
8 comments, last by Noobico 18 years, 11 months ago
hi! i wrote a menu class... it works nice till i click the button to start my game (the window stays just black).. i think it has something to do with how i change the OpenGl settings so that the class can work with it if i change my program to just start with the game it works... i think this code causes the problem (it´s in the init function of my menu class): glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0.0f, mWidth, mHeight, 0.0f, 0.1f, 100.0f); glViewport(0,0, Window->right, Window->bottom); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); i would like to put in some code to save the "old" opengl settings and restore those setting with a function like menu->deinit() could someone tell me how to do that? thx for your help [Edited by - Noobico on May 29, 2005 3:55:28 PM]
Advertisement
Look at glPushMatrix/glPopMatrix and glPushAttribute/glPopAttribute
i tried to solve the problem that way but it doesn´t work:
(i tried glPushAttrib(GL_ALL_ATTRIB_BITS) too but it didn´t work
either :( )

void cMenu::InitView(){	glMatrixMode(GL_PROJECTION);	glPushMatrix();	glLoadIdentity();		glOrtho(0.0f, mWidth, mHeight, 0.0f, 0.1f, 100.0f);	glViewport(0,0, Window->right, Window->bottom);			glMatrixMode(GL_MODELVIEW);	glPushMatrix();	glLoadIdentity();	}void cMenu::DeInitView() {	glMatrixMode(GL_PROJECTION);	glPopMatrix();	glMatrixMode(GL_MODELVIEW);	glPopMatrix();	}
hi, i might be wrong cause i'm still a noob in OpenGL programming but i believe that the glPopMatrix() and glPushMatrix() work in a FILO (First In Last Out) way like stacks. After all that's what it is all about the matrix stack.

So in order to solve this you'd need to reverse the order in which you are calling glPopMatrix
like this:

void cMenu::DeInitView() {	glMatrixMode(GL_MODELVIEW);	glPopMatrix();	glMatrixMode(GL_PROJECTION);	glPopMatrix();}


i might be wrong though, hope this helps and good luck.

cheers
no, this way it doesn´t work either...

but you are right it could have been a problem IF
(glPushMatrix and glPopMatrix) don´t make a difference
if i set the martixmode... if they make a difference OGL
would have one stack for GL_PROJECTION and one for GL_MODELVIEW
(don´t know if this actually IS the case)

if that is true it wouldn´t matter if i restore PROJECTION
or MODELVIEW first right?

but iam not sure (i coded this a long time ago and most of it
i couldn´t even recode at the moment)... even tough it´s really basic
Hi,
Make sure before you make Push for the matrix you didn't reach the limit of the stack.

bye
iam not reaching the max stacks:

Projection stacks MAX = 4
Projection stacks used (before Pushing) = 1

Modelview stacks MAX = 34
Modelview stacks used (before Pushing) = 1

so i don´t have a problem with the stack size
actually it seems to work BUT...

the colors get so dark that i can´t see very much...
what could be a cause that bright colors are almost black now?
Hi ,
Make sure you disable the texture and/or the lighting .
bye
thx alot...

that´s been the problem :)

i didn´t know that the colors assigned get dark
if textures are enabled....

This topic is closed to new replies.

Advertisement