Getting the OpenGL context?

BlitzMax Forums/BlitzMax Programming/Getting the OpenGL context?

Damien Sturdy(Posted 2008) [#1]
Hi,

So, we just released a compatibility demo for Flow, but found there were issues with OpenGL in Fullscreen.

The purpose: Attaching OGRE to the BlitzMax window.

Basically we need to retrieve the actual OpenGL context-

GetActiveWindow() is not working for some reason when using fullscreen, I'm not entirely sure that it's working correctly in windowed mode but Ogre seems to work with it happily.

Basically, Ogre is using the value from GetActiveWindow(). This is invalid, so Ogre is creating it's own window, which does not receive Events that the Max window would use.


SO! How can we go about getting the OpenGL context? Why was the _context value of Tgraphics driver made private? Could there be a GetGLContext() function in a future module update?

Thanks,


Dreamora(Posted 2008) [#2]
so for the demo you could just alter it or create the function and put in the models board then it will surely soon be within the SVN version of BM :)
but yes I agree in some cases its hard to understand why important private variables didn't get at least getter functions


N(Posted 2008) [#3]
I would recommend writing code to create the windows/contexts/what have you on your own. Doing this, you're far more likely to not have to fight against the current setup, and it's not like it's hard to do anyway.


Damien Sturdy(Posted 2008) [#4]
Dreamora, aha, could look into the function, BUT,really, the value i want is right in front of me. _context.

@dingbat_blump.

This is one option, but then, when you have what you are looking for right in front of you but cant use it, and are told to do something a little more complex to achieve what you want, it seems like a waste of time, yes?

Either way, before release Flow will most likely route all bmax events to an Ogre created window, eliminating the problem, but this is a feature that will not only benefit Flow but any engine that can plug into an OpenGL context.

[edit]
Bugger, after all that it *is* returning the right value. odd behavior somewhere... Thanks guys.


ImaginaryHuman(Posted 2008) [#5]
Doesn't canvasgraphics() and creategraphics() both return OpenGL context objects?


N(Posted 2008) [#6]
No.


Dreamora(Posted 2008) [#7]
Well then create a function
function GetGLContext:int()
  return _context
end function

and put it into the corresponding bmx and the module board as addition suggestion for the SVN :)


Damien Sturdy(Posted 2008) [#8]
Guys. I traced the Max sourcecode, GetActiveWindow() *does* return the GL context. (like, all it does is return _context) Our problem lies elsewhere now.


Dreamora(Posted 2008) [#9]
You are using the correct way to create it right?
not max2d gl context but the creategl... stuff with the correct buffer flags for OGRE


Damien Sturdy(Posted 2008) [#10]

not max2d gl context but the creategl... stuff with the correct buffer flags for OGRE



Tried this last night, in this instance Ogre recognises there is a window but throws an exception. We are looking into it. there are a couple of solutions, just need to try them and see which works better :-)


Dreamora(Posted 2008) [#11]
can't wait for it :D