Jump to content
  • Advertisement
Sign in to follow this  
y2jsave

second opengl window

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

i was making a program in which my main opengl window when clicked at a place opens another opengl window . but when i closed the second window , the first windows drawing etc etc were all vanished .......... its not that drawing on the first window vanished when i closed the second window but in fact as soom as second window is made, the first one drawing is erased.... how to correct it. thanks in advance

Share this post


Link to post
Share on other sites
Advertisement
It sounds like you're losing the rendering context for the first window when the second window is created. Are you using GLUT? Or SDL? Or Win32? There's separate solutions for each...

Share this post


Link to post
Share on other sites
Quote:
Original post by klaymore142
It sounds like you're losing the rendering context for the first window when the second window is created. Are you using GLUT? Or SDL? Or Win32? There's separate solutions for each...


win 32
whats the solution?
thanks

Share this post


Link to post
Share on other sites
Okay, so in Win32 you have some objects declared like this:

HGLRC hRC;
HDC hDC;
HWND hWnd;
HINSTANCE hInstance;

First, make sure you have separate objects for each window that renders to OpenGL.
Then, whenever you create a new window (using CreateWindowEx() ), make sure you are using unique objects for each window. In other words, each window needs its own hRC, hDC, hWnd, and hInstance. Then, when rendering, make sure you draw to the correct window (whichever is in front).
Finally, make sure your function to kill the second window doesn't do anything to the other window's objects.

Hope this helps, but if not, some sample code would help.

Share this post


Link to post
Share on other sites
Quote:
Original post by klaymore142
In other words, each window needs its own hRC, hDC, hWnd, and hInstance.

Each window does NOT need it's own hInstance. All in the same executable module should be the same.

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!