The libRocket GUI library

Post your questions, suggestions and experiences regarding game design, integration of external libraries here. For irrEdit, irrXML and irrKlang, see the
ambiera forums
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: The libRocket GUI library

Post by hybrid »

'There is no such method so far. You can raise a feature request in our trackers so it will be recognized by the dev team and maybe added.
Violence
Posts: 10
Joined: Mon Aug 13, 2012 11:32 am

Re: The libRocket GUI library

Post by Violence »

hybrid wrote:'There is no such method so far. You can raise a feature request in our trackers so it will be recognized by the dev team and maybe added.
New day, fresh thoughts.
I can just add openGL to IrrRocketRenderer and call very same Opengl functions like in SFML Rocket renderer without having to change the Irrlicht :D

This goes to includes

Code: Select all

#include <GL/gl.h>
EnableScissorRegion function code:

Code: Select all

 
void IrrRocketRenderer::EnableScissorRegion(bool enable){
if (enable) glEnable(GL_SCISSOR_TEST); else glDisable(GL_SCISSOR_TEST);
}
 
SetScissorScreen function code:

Code: Select all

 
void IrrRocketRenderer::SetScissorRegion(int x, int y, int width, int height){
glScissor(x, Driver->getScreenSize().Height-(y+height), width, height);
}
 
Also add libopengl32.a (or other on linux) library to linker.

Now it works OK, except the input (unable to use delete, arrows and backspace keys), I'll try to fix them too.
Dex-
Posts: 2
Joined: Sat Aug 11, 2012 7:07 pm

Re: The libRocket GUI library

Post by Dex- »

Following your idea we can do this for both opengl and directx without modifying irrlicht sources!

Include the headers

IrrRocketRenderer.cpp

Code: Select all

 
#include <d3d9.h>
#include <GL/gl.h>
 
then replaced the Enable and SetScissorRegion functions

IrrRocketRenderer.cpp

Code: Select all

 
void IrrRocketRenderer::EnableScissorRegion(bool enable)
{
    irr::video::E_DRIVER_TYPE driverType = Driver->getDriverType();
    switch (driverType) {
        case irr::video::EDT_DIRECT3D9: {
            irr::video::SExposedVideoData videoData = Driver->getExposedVideoData();
            LPDIRECT3DDEVICE9 g_pd3dDevice = (LPDIRECT3DDEVICE9)videoData.D3D9.D3DDev9;
            g_pd3dDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, enable);
            break;
        }
        case irr::video::EDT_OPENGL: {
            if (enable)
                glEnable(GL_SCISSOR_TEST);
            else
                glDisable(GL_SCISSOR_TEST);
            break;
        }
        default:
            break;
    }
}
 
void IrrRocketRenderer::SetScissorRegion(int x, int y, int width, int height)
{
    irr::video::E_DRIVER_TYPE driverType = Driver->getDriverType();
    switch (driverType) {
        case irr::video::EDT_DIRECT3D9: {
            irr::video::SExposedVideoData videoData = Driver->getExposedVideoData();
            LPDIRECT3DDEVICE9 g_pd3dDevice = (LPDIRECT3DDEVICE9)videoData.D3D9.D3DDev9;
            RECT scissor_rect;
            scissor_rect.left = x;
            scissor_rect.right = x + width;
            scissor_rect.top = y;
            scissor_rect.bottom = y + height;
            g_pd3dDevice->SetScissorRect(&scissor_rect);
            break;
        }
        case irr::video::EDT_OPENGL: {
            glScissor(x, 768 - (y + height), width, height);
            break;
        }
        default:
            break;
    }
}
 
Finally link with the opengl and directx libraries.
Dex-
Posts: 2
Joined: Sat Aug 11, 2012 7:07 pm

Re: The libRocket GUI library

Post by Dex- »

Oh, and to get the keys working properly i did this:

in file CIrrRocketEventReceiver.cpp replaced this part

Code: Select all

 
    else if (event.EventType  == irr::EET_KEY_INPUT_EVENT)
    {
        ...
        ...
    }
 

with

Code: Select all

 
    else if (event.EventType  == irr::EET_KEY_INPUT_EVENT)
    {
        int mod = 0;
        if (event.KeyInput.Shift)
            mod &= Rocket::Core::Input::KM_SHIFT;
        if (event.KeyInput.Control)
            mod &= Rocket::Core::Input::KM_CTRL;
 
        Rocket::Core::Input::KeyIdentifier key = Rocket::Core::Input::KI_UNKNOWN;
        switch (event.KeyInput.Key) {
            case irr::KEY_LEFT:
                key = Rocket::Core::Input::KI_LEFT;
                break;
            case irr::KEY_RIGHT:
                key = Rocket::Core::Input::KI_RIGHT;
                break;
            case irr::KEY_UP:
                key = Rocket::Core::Input::KI_UP;
                break;
            case irr::KEY_DOWN:
                key = Rocket::Core::Input::KI_DOWN;
                break;
            case irr::KEY_BACK:
                key = Rocket::Core::Input::KI_BACK;
                break;
            case irr::KEY_DELETE:
                key = Rocket::Core::Input::KI_DELETE;
                break;
            case irr::KEY_HOME:
                key = Rocket::Core::Input::KI_HOME;
                break;
            case irr::KEY_END:
                key = Rocket::Core::Input::KI_END;
                break;
            case irr::KEY_PRIOR:
                key = Rocket::Core::Input::KI_PRIOR;
                break;
            case irr::KEY_NEXT:
                key = Rocket::Core::Input::KI_NEXT;
                break;
            case irr::KEY_RETURN:
                key = Rocket::Core::Input::KI_RETURN;
                break;
             default: {
                if (event.KeyInput.Char)
                    Context->ProcessTextInput(event.KeyInput.Char);
                    return false;
                    break;
                }
        }
        if (event.KeyInput.PressedDown)
            Context->ProcessKeyDown(key, mod);
        else
            Context->ProcessKeyUp(key, mod);
    }
 
netpipe
Posts: 670
Joined: Fri Jun 06, 2008 12:50 pm
Location: Edmonton, Alberta, Canada
Contact:

Re: The libRocket GUI library

Post by netpipe »

Live long and phosphor!
-- https://github.com/netpipe/Luna Game Engine Status 95%
Post Reply