Jump to content

CEGUI Integration - Working kinda...


EvilNoodle
 Share

Recommended Posts

Hi,

 

I followed the information in this forum and the CEGUI site to get CEGUI working in Leadwerks. The GUI renders OK and the window is fine except for the title text that is totally illegible.

 

The code is below and I suspect the issue is due to where I have the renderGUI() command in the render loop.

 

Any suggestions would be greatly appreciated.

 

Cheers

 

EvilNoodle

 


#include "engine.h"
#include <CEGUI.h>
#include <RendererModules/OpenGL/CEGUIOpenGLRenderer.h>

int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd ) 
{
Initialize() ;
RegisterAbstractPath("./media");
SetAppTitle( "LWTest" ) ;
Graphics( 800, 600 ) ;
AFilter() ;
TFilter() ;

CEGUI::OpenGLRenderer & renderer = CEGUI::OpenGLRenderer::create();
       CEGUI::System & sys = CEGUI::System::create(renderer);

       CEGUI::DefaultResourceProvider* rp = static_cast<CEGUI::DefaultResourceProvider*>(CEGUI::System::getSingleton().getResourceProvider());

const char* dataPathPrefix = "media/cegui";
char resourcePath[MAX_PATH];
_snprintf(resourcePath, MAX_PATH - 1, "%s/%s", dataPathPrefix, "schemes/");
rp->setResourceGroupDirectory("schemes", resourcePath);
_snprintf(resourcePath, MAX_PATH - 1, "%s/%s", dataPathPrefix, "imagesets/");
rp->setResourceGroupDirectory("imagesets", resourcePath);
_snprintf(resourcePath, MAX_PATH - 1, "%s/%s", dataPathPrefix, "fonts/");
rp->setResourceGroupDirectory("fonts", resourcePath);
_snprintf(resourcePath, MAX_PATH - 1, "%s/%s", dataPathPrefix, "layouts/");
rp->setResourceGroupDirectory("layouts", resourcePath);
_snprintf(resourcePath, MAX_PATH - 1, "%s/%s", dataPathPrefix, "looknfeel/");
rp->setResourceGroupDirectory("looknfeels", resourcePath);
_snprintf(resourcePath, MAX_PATH - 1, "%s/%s", dataPathPrefix, "lua_scripts/");
rp->setResourceGroupDirectory("lua_scripts", resourcePath);
_snprintf(resourcePath, MAX_PATH - 1, "%s/%s", dataPathPrefix, "xml_schemas/");
rp->setResourceGroupDirectory("schemas", resourcePath);  

CEGUI::Imageset::setDefaultResourceGroup("imagesets");
CEGUI::Font::setDefaultResourceGroup("fonts");
CEGUI::Scheme::setDefaultResourceGroup("schemes");
CEGUI::WidgetLookManager::setDefaultResourceGroup("looknfeels");
CEGUI::WindowManager::setDefaultResourceGroup("layouts");
CEGUI::ScriptModule::setDefaultResourceGroup("lua_scripts");
CEGUI::XMLParser* parser = CEGUI::System::getSingleton().getXMLParser();
if(parser->isPropertyPresent("SchemaDefaultResourceGroup"))
{
	parser->setProperty("SchemaDefaultResourceGroup", "schemas");
}

CEGUI::SchemeManager::getSingleton().create( "TaharezLook.scheme" );
CEGUI::FontManager::getSingleton().create( "DejaVuSans-10.font" );
CEGUI::System::getSingleton().setDefaultFont( "DejaVuSans-10" );
CEGUI::System::getSingleton().setDefaultMouseCursor( "TaharezLook", "MouseArrow" );
CEGUI::System::getSingleton().setDefaultTooltip( "TaharezLook/Tooltip" );

CEGUI::Window* guiRoot = CEGUI::WindowManager::getSingleton().createWindow("DefaultWindow", "root");
CEGUI::System::getSingleton().setGUISheet(guiRoot);

CEGUI::FrameWindow* wnd = static_cast<CEGUI::FrameWindow*>(CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/FrameWindow", "window"));
guiRoot->addChildWindow(wnd);
wnd->setText("Test Window");
wnd->setPosition(CEGUI::UVector2(CEGUI::UDim(0.1f, 0), CEGUI::UDim(0.1f, 0)));
wnd->setSize(CEGUI::UVector2(CEGUI::UDim(0.8f, 0), CEGUI::UDim(0.8f, 0)));


TWorld	world;
TBuffer gbuffer;
TCamera camera;
TMesh	mesh;
TLight	light;
TMesh	ground;
TMaterial material;

world = CreateWorld() ;

if (!world) 
{
	MessageBoxA(0,"Error","Failed to create world.",0);
	return Terminate();
}

gbuffer=CreateBuffer(GraphicsWidth(),GraphicsHeight(),BUFFER_COLOR|BUFFER_DEPTH|BUFFER_NORMAL);

camera=CreateCamera();
PositionEntity(camera,Vec3(0,0,-2));

material=LoadMaterial("abstract::cobblestones.mat");

mesh=CreateCube();
PaintEntity(mesh,material);

ground=CreateCube();
ScaleEntity(ground,Vec3(10,1,10));
PositionEntity(ground,Vec3(0,-2,0));
PaintEntity(ground,material);

light=CreateDirectionalLight();
RotateEntity(light,Vec3(45,45,45));

UpdateAppTime();
float startTime = AppTime();

// Game loop
while( !KeyHit() && !AppTerminate() )
{
	if( !AppSuspended() ) // We are not in focus!
	{
		// Rotate cube
		TurnEntity( mesh, Vec3( 0.5f*AppSpeed() ) ) ;

		// Update timing and world
		UpdateAppTime();
		UpdateWorld(AppSpeed()) ;

		float curTime = AppTime() - startTime;

		// Render
		SetBuffer(gbuffer);
		RenderWorld();
		SetBuffer(BackBuffer());
		RenderLights(gbuffer);

		CEGUI::System::getSingleton().renderGUI();

		CEGUI::System::getSingleton().injectMousePosition(MouseX(), MouseY());

		Flip(0) ;
	}
}

CEGUI::System::destroy();
       CEGUI::OpenGLRenderer::destroy(renderer);

// Done
return Terminate() ;
}

post-209-055572700 1281388197_thumb.png

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...