The libRocket GUI library
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
Re: The libRocket GUI library
'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.
Re: The libRocket GUI library
New day, fresh thoughts.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.
I can just add openGL to IrrRocketRenderer and call very same Opengl functions like in SFML Rocket renderer without having to change the Irrlicht
This goes to includes
Code: Select all
#include <GL/gl.h>
Code: Select all
void IrrRocketRenderer::EnableScissorRegion(bool enable){
if (enable) glEnable(GL_SCISSOR_TEST); else glDisable(GL_SCISSOR_TEST);
}
Code: Select all
void IrrRocketRenderer::SetScissorRegion(int x, int y, int width, int height){
glScissor(x, Driver->getScreenSize().Height-(y+height), width, height);
}
Now it works OK, except the input (unable to use delete, arrows and backspace keys), I'll try to fix them too.
Re: The libRocket GUI library
Following your idea we can do this for both opengl and directx without modifying irrlicht sources!
Include the headers
IrrRocketRenderer.cpp
then replaced the Enable and SetScissorRegion functions
IrrRocketRenderer.cpp
Finally link with the opengl and directx libraries.
Include the headers
IrrRocketRenderer.cpp
Code: Select all
#include <d3d9.h>
#include <GL/gl.h>
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;
}
}
Re: The libRocket GUI library
Oh, and to get the keys working properly i did this:
in file CIrrRocketEventReceiver.cpp replaced this part
with
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);
}
Re: The libRocket GUI library
Live long and phosphor!
-- https://github.com/netpipe/Luna Game Engine Status 95%
-- https://github.com/netpipe/Luna Game Engine Status 95%