Jump to content
  • Advertisement
Sign in to follow this  
JPulham

OpenGL resizing showing up blank... again

This topic is 4414 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

OK... I have an OpenGL app. It has 4 view port that display properly (for now test data/scene) When I resize using just glViewport it still draws, just stretched. However when I resize with : //psudeo code ish... cant remember EXACT code glMatrixMode(GL_PROJECTIONMATRIX); glLoadIdentity(); gluPerspective(45.0f,w/h,0.1,200.0); glMatrixMode(GL_MODELVIEWMATRIX); glLoadIdentity(); I GET A BLANK SCREEN!!!!! only the glClearColor shows :( what should I do? Any comments?

Share this post


Link to post
Share on other sites
Advertisement
Without source code to look at, any help will be "shooting from the hip", but here goes:

Likely, the problem rests in "4 viewports". If you have four view ports, you have to resize all four. You have to reinitialize all four correctly. Beyond that, I don't know how your code works, but consider the following code:


// OpenGL resizing function, called when my window gets resized
void resizeOpenGLWindow(int w,int h)
{
glViewport(0,0,w/2-1,h/2-1);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();

gluPerspective(45.0f,w/h,0.1,200.0);
// w/h is bad code, BTW. If h = 0, crash. If w = 0, OpenGL generates errors

glViewport(w/2,h/2,w,h/2);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();

//... repeat ...
}

// More random code

// OpenGL render code
void render()
{
// Draw stuff in viewport 1
glViewport(0,0,w/2-1,h/2-1);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();

gluPerspective(45.0f,w/h,0.1,200.0);
//.....
// This is necessary because the viewport and
// rendering matrices must be set EVERY time something changes.
// This includes viewports
// You can save some time by changing the viewports, but inside
// each viewport, have the same viewing perspective.
}


If you don't reinitialize the viewports before you render, you'll be drawing into one of them, and if that one has the wrong projection matrix or whatever, you could see a black screen.

But without source code, or at least a more detailed description of the code, there's not much anyone can do to diagnose the problem. :)

Share this post


Link to post
Share on other sites
I realised that after I'd shut down :?
I use 4 different windows, with wglMakeCurrent(hDC1,hRC1); or something like it.
The main loop looks like this (Win32) :

while(!quit)
{
if(getmessage)
{
messagepump
}
else
{
for each message :
wglMakeCurrent()
glClear()
glPushMatrix()
glPopMatrix()
}
}


I'm at school right now so I'll post the source later. I'm using subclassing BTW.
Like I said ealier, it works if you use glViewport, its only when I use matrix/Perspective stuff that it goes wrong. Could I use glFrustrum() instead?

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!