descala
Topic Author
Posts: 15
Joined: 19 Sep 2013, 20:11

OpenGL support in Ogre bindings

12 Oct 2013, 06:40

Amazing and very capable library!

We are currently using Ogre, but plan to deploy to multiple platforms. Is there an expected timeline for OpenGL support in the Ogre bindings?

Thanks!
 
User avatar
jsantos
Site Admin
Posts: 3919
Joined: 20 Jan 2012, 17:18
Contact:

Re: OpenGL support in Ogre bindings

12 Oct 2013, 20:20

I know that the people that helped us with the Linux port had the Ogre Bindings working in GL. I have contacted them to see if they can make public that code.
 
TheSHEEEP
Posts: 37
Joined: 13 Sep 2012, 10:52

Re: OpenGL support in Ogre bindings

13 Oct 2013, 00:28

Hey, I happen to be part of that "people".

Yes, we (as in the people helped with Linux, not Ogre team ;) ) have it working in our own game research prototype, but it is rather intertwined there (for example, we don't render to the screen, but instead to a render texture which is then used somewhere else, etc.) and I currently simply don't have the time to clean it and wrap it up nicely. I will try to do that once we're done with the research prototype. But that might very well be in 2 or 3 months, not earlier.

What I can do, however, is just upload our NoesisManager files and explain how we use those. That certainly won't work out of the box for you, but it should get you started. It's not too complicated, the hardest part was figuring out which OpenGL states to save and restore, and when to do that. I'll upload those and post them as I get back to working (Monday).
 
TheSHEEEP
Posts: 37
Joined: 13 Sep 2012, 10:52

Re: OpenGL support in Ogre bindings

14 Oct 2013, 09:07

Hey, I've uploaded the files. A short disclaimer first:

You'll find some members and classes that are pretty much unrelated to making NoesisGUI work with Ogre OpenGL. There is one mouse cursor class (that is using the Ogre Overlay system, we will replace that using Noesis as well later), some classes that bind functions to Lua scripts. You can basically ignore all those. There is also no binding from OIS keyboard keys to Noesis key codes.

The most important functions to you are probably the store and restoreCurrentRenderStates.
I had to comment some of the GL functions there as they were causing OpenGL errors during runtime (it was working, but the GL errors were logging away).


Here are the files:

Header
Source

You will also need the OgreNsGuiStream and OgreNsGuiFileSystem files/classes from the official Ogre Noesis bindings (you can find them on the repo).

And here is how we use those:

Initialization (we use an extra SceneManager for GUI, but maybe using visibility flags would be faster) and Cleanup:
    // setup gui scene manager
    // the extra scene manager is there to prevent anything being rendered on the render target other than the gui
    _guiTexture = TextureManager::getSingleton().createManual("GuiTexture", "RenderTextureGroup", TEX_TYPE_2D, _window->getWidth(), _window->getHeight(), 0, PF_B8G8R8A8, TU_RENDERTARGET);
    _guiRenderTarget = _guiTexture->getBuffer()->getRenderTarget();
    _guiRenderTarget->setAutoUpdated(true);
    
    _guiSceneMgr = _root->createSceneManager("OctreeSceneManager", "GuiSceneManager");    

    // Create the camera
    _guiCamera = _guiSceneMgr->createCamera("GuiCam");
    _guiCamera->setNearClipDistance(1);
    _guiCamera->setFarClipDistance(3000);

    // Create one viewport, entire window
    _guiViewport = _guiRenderTarget->addViewport(_guiCamera);
    _guiViewport->setBackgroundColour(Ogre::ColourValue(0,0,0,0));

    // Alter the camera aspect ratio to match the viewport
    _guiCamera->setAspectRatio(
                    Ogre::Real(_guiViewport->getActualWidth()) / Ogre::Real(_guiViewport->getActualHeight()));

    _guiManager = new NoesisManager();
    if (!_guiManager->setup(_guiSceneMgr, _root, _memoryLog, _inputManager->getMouse(),  
                            _window->getWidth(), _window->getHeight()))
    {
        CONSOLE_LOG("Failed to setup gui!");
        return false;
    }

    // Cleanup code
    _guiManager->shutdown();
    delete _guiManager;
    _guiManager = 0;
And this is done during the render loop:
    // Take time
        lastProgTime = progTime;
        progTime = ((float)_root->getTimer()->getMilliseconds()) / 1000.0f;
        _timeSinceLastFrame = progTime - lastProgTime;
        
        // Render a frame
        _guiManager->doPreSceneStep((double)_timeSinceLastFrame);
        _root->renderOneFrame();
 
User avatar
jsantos
Site Admin
Posts: 3919
Joined: 20 Jan 2012, 17:18
Contact:

Re: OpenGL support in Ogre bindings

14 Oct 2013, 12:16

Hi Jan,

Thanks a lot for sharing this!

I think that the best is integrating this with our github. Will try to find time to do this myself. Of course, if anybody wants to help, he is welcome.

Who is online

Users browsing this forum: Semrush [Bot] and 14 guests