Is it possible to have openGL in 2 windows? as in 2 different windows (lets say the first is 640×480 and the other is 1024×768) rendering different things (lets say one window is an editor and the other is the main/normal window display)
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you’re using GLUT you can use the glutSetWindow() / glutGetWindow() calls to select the correct window (after creating them with glutCreateSubWindow()). However sometimes GLUT might not be the right tool for the job.
If you’re working on Windows you’ll want to look into the wglMakeCurrent() and wglCreateContext(). On OS X there is aglSetCurrentContext() et cetera, and X11 requires glXMakeCurrent().
Those functions activate the current OpenGL context to which you can render. Each platform specific library has it’s own ways of creating a window and binding an OpenGL context to it.
On Windows, after you’ve acquired your HWND and HDC for a window (after a CreateWindow and GetDC call). You generally do something like this to set up OpenGL:
You use that code to create multiple windows and bind OpenGL to it, then each time you want to draw to a specific window you have to call wglMakeCurrent before you do anything and you pass in the parameters corresponding to that window.
As a side-note, OpenGL allows you to share certain data between different contexts, however as per spec the data that you can share is pretty limited. However, most OSes allow you to share more data than specified in the specification.