Home > OpenGL > Multiple OpenGL rendering contexts

Multiple OpenGL rendering contexts

Hi all. Currently I’m working on a software which “should” have different OpenGL areas, each drawn in a different window or a more generic drawable surface (a panel, a group box, etc.. anything that has a window handle in practice).

But what I’m facing is demotivating me 😦

From what I’m reading, if you loose an OpenGL context, you also loose anything associated with it (textures, state changes, etc..):

This means that all the GL state is destroyed with it. This includes textures, among other things. More precisely, on Windows the textures are corrupted, whereas Linux handles it correctly.

Actually, in my application, I have different contexts and simply switch between them thanks to the wglMakeCurrent and everything works fine as long as I just render polygons with glColor.

But as I try to apply a texture (loaded with SDL_Image) nothing happens. So I tried to dump the texture raw data to a file and open it with PhotoShop but the resulting image is completely gray (205/255) 😐

I thought it could be the loosing-context problem mentioned above, so I tried to dump the texture as soon as I upload the data in it with glTexImage2D but I got the same gray image as before. Just to be sure I checked that SDL_Image was loading the texture correctly and that was the case…

I still have to check a couple of things… If you have some tips, please share them with me!

Bye

Advertisements
  1. July 21, 2008 at 4:11 pm

    Each context has it’s own set of textures, which is valid as long as the context isn’t destroyed. I think something is wrong with your texture loading, if you switch only using wglMakeCurrent the textures you’ve previously uploaded to the new context are usable again.

  2. eraser85
    July 21, 2008 at 4:22 pm

    Yes, you are correct. During these days I’ve been playing a bit with glGetError() along with even more debug cout(s) and now my texture gets loaded correctly, since dumping data to file now works 😉

    Actually my problem is that even if the texture is being uploaded to vram correctly, I’m still unable to use it.. glBindTexture is called but no texture is being applied to the geometry.. this bug must be very stupid and I hope to solve it tomorrow or at worse in a couple of days..

    thank you for your reply, eile!

  3. eraser85
    July 22, 2008 at 10:09 am

    It was a stupid mistake indeed.

    I defined min and mag filtering but I wasn’t generating mipmaps… As soon as I uploaded the texture in memory with gluBuild2DMipmaps() my beautiful windows logo done in paint showed up LOL 😀

    Thank you eile. 🙂

  4. furyofelements
    October 4, 2008 at 3:47 pm

    Ciao ho visto su Gamedev.net che sei di Foggia…Anche io sono di Foggia e sto studiando il c++…Potresti dirmi dove posso trovare la tua email per avere dei consigli?
    Ciao,
    Marco

  1. No trackbacks yet.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: