OpenGL Contexts with Ogre

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
astro_cc
Gnoblar
Posts: 1
Joined: Mon Apr 04, 2016 7:37 pm

OpenGL Contexts with Ogre

Post by astro_cc »

Hello all,

In my application, I have to have two Ogre render windows, and I have to use OpenGL. I can set the rendersystem and initialize Ogre::Root just fine, and I create the render windows using

Code: Select all

Ogre::Root::createRenderWindow()
. I am using separate scene managers to handle the different objects in each window, and everything seems to work pretty well. The problem, though, is that I also have to use of a lot of lines (from ManualObjects) in my scenes, and I need to be able to change their line width (via

Code: Select all

glLineWidth(int)
commands) at will in the application.

It seems that Ogre creates a unique GL context for each new window, but it only ever keeps the first context active. That is, if I use

Code: Select all

glLineWidth(2)
after creating the second window, only the lines in the first window will be set to 2 pixels width, and the second window will still have 1-pixel-wide lines. I have tried querying the context using

Code: Select all

wglGetCurrentContext()
, but it never returns anything other than the context of the first window, which is not at all helpful when I want to modify the line width in the second window.

This may be a straightforward question and I'm just missing something basic, but how do I get the OpenGL context associated with a specific Ogre renderwindow? Some of the documentation I've found when searching about this problem suggests that the way to do it would be to create the contexts outside of Ogre and then force Ogre to use them, but then it seems that I'd be getting into a lot of stuff I don't know how to do (manual buffer switching, etc.).

Thanks in advance for any insight.