Jump to content

EvilNoodle

Members
  • Posts

    10
  • Joined

  • Last visited

Everything posted by EvilNoodle

  1. 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() ; }
  2. The use of relative scales for components is an option and easy to override when and if required. Is there any way to get access to information on a texture once its loaded such as the alpha value for a pixel? EvilNoodle
  3. I agree with you that there are far better sollutions in the GUI space but for the time being all I need is a very simple implementation. For my needs I have pretty much everything I require for now because all I want is some simple event driven buttons and text elements. In the future I would like additional viewports although I will cross that bridge when I come to it. EvilNoodle
  4. Sorted - Export to tga then convert to dds Thanks all for your help I can make good progress now I think!! EvilNoodle
  5. Thanks!!! That works like a charm!!! Now I have my black blob Do you know if it is possible to set the alpha in a DDS so that the blob is itself partially transparent? I tried to do it in the Gimp but I get told it doesnt support it. EvilNoodle
  6. Hello again... I have now managed to get a dds to export properly with a transparent background (at least the parts that should be transparent appear in bright cyan when the dds is viewed) but I am a little unclear as to where in the render process I should be doing the drawing to get the transparency to work. I am using Framewerk and my test code is pretty much taken from the example as below #include "engine.h" #include "framewerk.h" #define WIN_RES_X 1024 #define WIN_RES_Y 768 int main(int argc, char** argv) { if(!Initialize())return 1; TMesh mesh, ground; TLight light; TMaterial material; RegisterAbstractPath("."); Graphics(WIN_RES_X,WIN_RES_Y); leadwerks::Framewerk fw; if( !fw.Create() ) { MessageBoxA(0,"Failed to initialize engine.",NULL,0); return 1; } fw.GetRenderer().SetSkybox( LoadMaterial("abstract::FullskiesBlueClear0016_2_L.mat") ); fw.GetRenderer().SetSSAO( true ); PositionEntity( fw.GetMain().GetCamera(), Vec3(0,0,-3) ); material = LoadMaterial("abstract::cobblestones.mat"); mesh = CreateCube(); ScaleEntity(mesh, Vec3(0.5, 0.5, 0.5)); PaintEntity( mesh, material ); ground = CreateCube(); ScaleEntity ( ground, Vec3( 10, 1, 10 ) ); PositionEntity( ground, Vec3( 0, -1, 0 ) ); PaintEntity ( ground, material ); light = CreateDirectionalLight(); RotateEntity( light, Vec3(45) ); TTexture testImage = LoadTexture("abstract::test.dds"); do { TurnEntity( mesh, Vec3(AppSpeed()*0.5f) ); if( KeyHit(KEY_ESCAPE) ) break; if( AppTerminate() ) break; fw.Update(); fw.Render(); Flip(0); } while( true ); return Terminate(); } The question is where should I be placing the "DrawImage(testImage, 200, 200, 320, 200);" to get the desired effect? The sensible place from my perspective would be between the "fw.Render();" and "Flip(0)" lines but while that draws the image it is far from transparent. The parts that should be transparent just render in white. Any ideas? Lazlo I will send you a pm about your drawing approach I would like to know more.
  7. Yep just checked out the image I was using and the alpha was not set up properly in the DDS. I won't have a chance to test in engine until later tonight but its looking like that might be the issue. Fingers crossed!!
  8. Thanks for the response. The sorting out of screen coords for the 2D drawing is already done in my ported implementation and works as I want it. Its mainly the transparency that I am having issues with. I made a .png in the Gimp and applied an alpha layer to it so I now have a 50% see through png file. I then saved this as .dds using the Gimp plugin but the dds doesnt seem to have preserved the alpha hence it is not showing up as transparrent in engine. This may be a limitation of the Gimp DDS export plugin or the way I am using it so I will look at it again tonight with a different conversion workflow. If I can get this working there is very little I need to do to complete my lightweight GUI framework. Thanks again. EvilNoodle
  9. Hello all, A while ago when I was working with the DarkGDK from "The Game Creators" I started building a fairly flexible event based GUI system which I am planning to port to Leadwerks. The GDK version used sprites to render simple controls on top of the 3D content which gave them the ability to be made transparent and rotated etc. I have started porting to Leadwerks using the 2D draw commands as a starting point but I can see some problems with continuing this approach... For example The 2D commands work and work well but at the moment I am not seeing any obvious way to make content drawn with them transparent. Do any of you guys know how I can draw 2D content (or 3D that looks like 2D) to the screen for a GUI where I can set transparency on the components? Ideally I would like to be able to treat GUI components like any other entity - materials etc. What I want to do as a starting point is render an image loaded from file to the screen on top of all other content using the following arguments... xPos = 0.25 (25% of the displayable screen from the left) yPos = 0.25 (25% of the displayable screen from the top) width = 0.5 (50% of the displayable screen) height = 0.5 (50% of the displayable screen) alpha = 0.5 (50% transparent) Resulting in an image drawn with 50% transparency exactly half the size of the display and perfectly centred. Thanks EvilNoodle
  10. Hi, I just upgraded to 2.3 from 2.0 although I was away for a while. When I load the editor from the main SDK folder it loads fine and I can do all kinds of cool stuff with it... awesome... I have created a c++ template project which when built results in the following structure Project Dir : [drive]/Projects/C++/Leadwerks/2.3/TestProject Build Dir : [Project Dir]/bin/Release Contains the project .exe and all required dll files Config Dir : [build Dir]/cfg Contains the config files for my game (none so far) Media Dir : [build Dir]/media Contains the media files for my project sorted into folders as required Ideally what I want is for the editor to pick up on the contents of the media directory for this project so that in the selection tree display on the right I get both the normal entities (lights etc) and the stuff in the media folder of the project I am working on. What do I need to do to achieve this. Is it as simple as the editor loading the media on the abstract path from the currrent scene file or do I need to change some config? I really want the entities displayed in the editor to be relevant to the project I am working on to avoid confusion because I sense things are going to get quite busy once I have a lot of test sub-projects on the go. For example I don't want to store everything centrally because then I end up having all my trees and buildings listed in the editor when working on my space game... There are some other reasons I want to keep media on a per-project basis but I wont bore you with them now. Cheers EvilNoodle
×
×
  • Create New...