OpenGL Window Resize Issue

Started by
7 comments, last by szecs 14 years, 1 month ago
Whenever I resize my OpenGL window, it appears that the OpenGL part stays at the original size. Here is an example of what I mean (the original window size was 800x600): http://img251.imageshack.us/img251/3151/resizeproblem.png My question is, based on what is being displayed, is there any idea on how to fix it? My code is basically an OOP version of the NeHe tutorials so far written in C++ with rendering being performed on its own thread (but window operations being performed on the main thread) (I might've messed something up in porting it though or maybe it is a threading issue?). Thanks.
Advertisement
Are you changing the viewport?
You'll need use something like glViewport(0, 0, newwidth, newheight) for every resize. If you've already written an OOP version, I'm sure you can figure out where it should go. :)
Yeah I have a glViewport(0, 0, width, height) in my resize method. After thinking that it might be a threading issue, I looked at Multithreaded OpenGL in the MSDN Library and I'm going to try some things from there to see if it fixes it.

Any other suggestions?
You would have to call glViewport() from the thread that has the OpenGL context.

Is there any reason you want the window operations in a different thread than the rendering?
I forgot exactly why I did it (it had something to do with lowering latency on input I think, I did it after reading a suggestion off of a tutorial). Here is what I am doing:

int Window::Loop()
{
static bool isLooping = false;

if (!isLooping)
{
isLooping = true;

DWORD threadID;
HANDLE threadHandle;

threadHandle = CreateThread(NULL, 0, Window::RenderThread, this, 0, &threadID);

if (threadHandle == NULL)
{
throw WINDOW_EXCEPTION_RENDERTHREAD;
}

return this->MessageLoop();
}
else
{
return 0;
}
}

Two more things... when I click the X button on the window, it won't close unless I move or resize the window first. Do you know why this happens? And also, when using vertex arrays, is it best to use the defined shapes like GL_TRIANGLES and GL_QUADS or should I use something more generic like GL_POLYGON?
Unless you have a really concrete reason, I strongly advise against using threads for this. I can't imagine that this technique will improve preceived input latency - unless you need extremely precise timing information for some reason (e.g. you are measuring reaction time in a research simulation).
I changed it back to using a single thread and the resize problem is gone, but now a new problem exists. Whenever I move or resize the window, the rendering pauses. Do you know how to fix this?
Try handling the WM_SIZING message and calling your render method there.This will render to the window while you are resizing it.
Quote:Original post by Black Knight
Try handling the WM_SIZING message and calling your render method there.This will render to the window while you are resizing it.
I did that once with glut, that caused the app to crash after a number of updates while resizing.

This topic is closed to new replies.

Advertisement