Jump to content
  • Advertisement
Sign in to follow this  
Noobico

OpenGL [Solved] Restoring settings used before...

This topic is 4865 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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]

Share this post


Link to post
Share on other sites
Advertisement
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();

}

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Hi,
Make sure before you make Push for the matrix you didn't reach the limit of the stack.

bye

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
Hi ,
Make sure you disable the texture and/or the lighting .
bye

Share this post


Link to post
Share on other sites
thx alot...

that´s been the problem :)

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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!