Skip to main content
GameDev.net gamedev.net
🔒 Locked

multiple windows/instances and gl::GL_MAX_DRAW_BUFFERS

Started by miggs Feb 6, 2013 at 2:14 AM 1 replies 2.2k views
Original Post
miggs
miggs

hi,

my current renderer uses a number of frame+renderbuffers and rendertextures at the moment. I wanted to implenent the possibility to render to multiple independent windows and got multiple OpenGL 3.0 contexts running and at first it worked, without render buffers on the other windows.

But when the second windows' scene got more complex and I added renderbuffers and framebuffers the problems began.


GLint maxBuffers;
gl::GetIntegerv(gl::GL_MAX_DRAW_BUFFERS, &maxBuffers);

returns 8, and the first window consumes 5-6. I tried starting my app.exe twice with only 1 window and both ran without any trouble (2 app.exe each 1 window), but when starting only 1 app.exe and having it spawn 2 windows with each a context, i get GL_INVALID_VALUE on gl::GenFramebuffers, which indicates to me that both contexts' buffer count add up.

How can i have my HGLRC's work indepentent like 2 separate apps, within one?

Thanks in advance

Arkhyl
Arkhyl

GL_MAX_DRAW_BUFFERS indicate the maximum number of buffers in which you can simultaneously draw, not the number you can create. So your problem is not here.

Do you call wglMakeCurrent in each thread in order to use the correct context?

miggs
miggs

i do call wglMakeCurrent, but the thing is: i don't call it in each thread, since i only run 1 thread. I do run both window computations and draw methods one after the other. (both windows don't need a lot of computations so this works for me i'd like to keep it simple)

imagine my loop is like:


instance1 = new inst... // an instance containing it's scene logic, window, and opengl context
instance2 = new inst...

while(myloopShouldBeRunning)
{
    instance1->update()->draw(); // calls makecurrent does it's stuff and renders
    instance2->update()->draw(); 
}

could the problem be that i run multiple contexts on the same thread?

EDIT:

problem solved

a background worker thread had some old not cleaned up messy code that switched the context in some cases at uncontrolled times...

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.