Sign in to follow this  
Matrinix

OpenGL Window Resize Issue

Recommended Posts

Matrinix    100
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.

Share this post


Link to post
Share on other sites
Ignifex    520
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. :)

Share this post


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

Share this post


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

Share this post


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

Share this post


Link to post
Share on other sites
rip-off    10976
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).

Share this post


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

Share this post


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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this