[Solved] Stuck on tutorial - unable to display anything with CEGUI (OpenGL Renderer, Windows)

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

vordhosbn
Just popping in
Just popping in
Posts: 8
Joined: Sat Sep 05, 2015 18:27

[Solved] Stuck on tutorial - unable to display anything with CEGUI (OpenGL Renderer, Windows)

Postby vordhosbn » Sat Sep 05, 2015 18:52

Hi, there.
First of all - thanks to everyone involved in CEGUI development - it seems like truly universal GUI framework with amazing possibilities for configuration and customization.

Now for my trouble...

Setup:
OS: Windows 10
Compiler: MSVC v14 (Visual Studio 2015) x64
CEGUI version: 0.8.4
Renderer: OpenGL
Image codec: SILLY
XML parser: RapidXML

I am using GLFW to create OpenGL context and open a OpenGL window. I have very limited experience with OpenGL and for example I am not sure if I am requesting the window with the right parameters.

After that I am following the CEGUI in practice tutorial and trying to show a single image on the window, but there is nothing shown...

Code: Select all

    // init GLFW library
    if (!glfwInit())
    {
        ReportErr(L"Can't init GLFW");
    }
    else
    {
        // create an OpenGL window
        if (!glfwOpenWindow(windowWidth, widndowHeight, 8, 8, 8, 8, 0, 0, GLFW_WINDOW))
        {
            ReportErr(L"Unable to create window");
        }
        else
        {
            // set window title
            glfwSetWindowTitle("Main window title");

            CEGUI::OpenGLRenderer * HDTrenderer = &CEGUI::OpenGLRenderer::bootstrapSystem();
            CEGUI::DefaultResourceProvider* rp = static_cast<CEGUI::DefaultResourceProvider*>(
                CEGUI::System::getSingleton().getResourceProvider());
            rp->setResourceGroupDirectory("schemes", "../../data/schemes/");
            rp->setResourceGroupDirectory("imagesets", "../../data/imagesets/");
            rp->setResourceGroupDirectory("fonts", "../../data/fonts/");
            rp->setResourceGroupDirectory("layouts", "../../data/layouts/");
            rp->setResourceGroupDirectory("looknfeels", "../../data/looknfeels/");
            rp->setResourceGroupDirectory("lua_scripts", "../../data/lua_scripts/");
            // set the default resource groups to be used
            CEGUI::ImageManager::setImagesetDefaultResourceGroup("imagesets");
            CEGUI::Font::setDefaultResourceGroup("fonts");
            CEGUI::Scheme::setDefaultResourceGroup("schemes");
            CEGUI::WidgetLookManager::setDefaultResourceGroup("looknfeels");
            CEGUI::WindowManager::setDefaultResourceGroup("layouts");
            CEGUI::ScriptModule::setDefaultResourceGroup("lua_scripts");

            CEGUI::SchemeManager::getSingleton().createFromFile("TaharezLook.scheme");
            // Set the defaults
            CEGUI::System::getSingleton().getDefaultGUIContext().setDefaultFont("DejaVuSans-12");
            CEGUI::System::getSingleton().getDefaultGUIContext().getMouseCursor().setDefaultImage("TaharezLook/MouseArrow");
            CEGUI::Window* myRoot = CEGUI::WindowManager::getSingleton().createWindow("DefaultWindow", "_MasterRoot");
            CEGUI::System::getSingleton().getDefaultGUIContext().setRootWindow(myRoot);

            CEGUI::Window *myImageWindow = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/StaticImage", "PrettyWindow");
            myImageWindow->setPosition(CEGUI::UVector2(CEGUI::UDim(0.5, 0), CEGUI::UDim(0.5, 0)));
            myImageWindow->setSize(CEGUI::USize(CEGUI::UDim(0, 150), CEGUI::UDim(0, 100)));
            myImageWindow->setProperty("Image", "TaharezLook/CloseButtonNormal");
            CEGUI::System::getSingleton().getDefaultGUIContext().getRootWindow()->addChild(myImageWindow);
        }

    }

I get no error messages/exceptions and there is nothing suspicious in CEGUI.log (pastebin)

The CEGUI samples also seem to work just fine (except for some input glitches in Release but that's another story).

I would be very grateful for any advice you have to how to debug my problem.
Last edited by vordhosbn on Thu Sep 10, 2015 15:07, edited 1 time in total.

lucebac
Just can't stay away
Just can't stay away
Posts: 193
Joined: Sat May 24, 2014 21:55

Re: Stuck on tutorial - unable to display anything with CEGUI (OpenGL Renderer, Windows)

Postby lucebac » Sat Sep 05, 2015 21:11

You can get an idea how to use GLFW with CEGUI here (the code is split over a number of files because of the code layout of the SamplesFramework):
https://bitbucket.org/cegui/cegui/src/6 ... pp?at=v0-8

I can also provide some more straightforward code on how to use GLFW3 together with CEGUI:
https://bitbucket.org/lucebac/cegui/src ... pp?at=v0-8

YaronCT
CEGUI Team
Posts: 448
Joined: Fri Jun 19, 2015 12:18
Location: Kiryat-Bialik, Israel

Re: Stuck on tutorial - unable to display anything with CEGUI (OpenGL Renderer, Windows)

Postby YaronCT » Sun Sep 06, 2015 11:50

I tried your code on Linux and it works, I only had to change:

Code: Select all

rp->setResourceGroupDirectory("looknfeels", "../../data/looknfeels/");


to:

Code: Select all

rp->setResourceGroupDirectory("looknfeels", "../../data/looknfeel/");

So plz just make sure that the paths to the resources r correct, and if u still have a problem, plz upload somewhere ur full code, or even your whole project and I'll look at it.

lucebac
Just can't stay away
Just can't stay away
Posts: 193
Joined: Sat May 24, 2014 21:55

Re: Stuck on tutorial - unable to display anything with CEGUI (OpenGL Renderer, Windows)

Postby lucebac » Sun Sep 06, 2015 12:11

Yeah - the paths can be different. I just used the standard CEGUI folder names, but there might be some typo, though.

vordhosbn
Just popping in
Just popping in
Posts: 8
Joined: Sat Sep 05, 2015 18:27

Re: Stuck on tutorial - unable to display anything with CEGUI (OpenGL Renderer, Windows)

Postby vordhosbn » Mon Sep 07, 2015 16:54

Thanks for the answers

@yaronct, I am sure that the paths are ok, because otherwise I would have an exception when I am loading the scheme. Also I changed the looknfeel folder to looknfeels, for consistency (to be plural :)).

@lucebac, I was looking for an easy way to setup OpenGL and just chose GLFW after little research. Its a pleasant surprise that the Samples framework is also using it for OpenGL initialization. I have begun setting proper input callbacks and other stuff that are implemented in .\samples_framework\src\CEGuiGLFWSharedBase.cpp .

Strange, however that the code I provided works on linux, but not on windows - I would have not expected platform differences after the OpenGL window was created, but maybe some missing callback is to blame. I will continue experiments and will post an update soon.

vordhosbn
Just popping in
Just popping in
Posts: 8
Joined: Sat Sep 05, 2015 18:27

Re: Stuck on tutorial - unable to display anything with CEGUI (OpenGL Renderer, Windows)

Postby vordhosbn » Wed Sep 09, 2015 16:57

Hey, guys.

I've made a repo to demonstrate my issues, if someone wishes to take a look:
git@bitbucket.org:vordhosbn/cegui-test.git
Zip DL if you don't have git

The solution is made with VS2015 Community.

lucebac
Just can't stay away
Just can't stay away
Posts: 193
Joined: Sat May 24, 2014 21:55

Re: Stuck on tutorial - unable to display anything with CEGUI (OpenGL Renderer, Windows)

Postby lucebac » Wed Sep 09, 2015 18:13

Looking into your code, it's obvious why you don't see anything: there's no code that actually renders something.
Please adapt my main loop from this source file and tell me if that helped.

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Stuck on tutorial - unable to display anything with CEGUI (OpenGL Renderer, Windows)

Postby Ident » Wed Sep 09, 2015 19:46

What made you think that CEGUI would magically render anything without you calling anything?
CrazyEddie: "I don't like GUIs"

vordhosbn
Just popping in
Just popping in
Posts: 8
Joined: Sat Sep 05, 2015 18:27

Re: Stuck on tutorial - unable to display anything with CEGUI (OpenGL Renderer, Windows)

Postby vordhosbn » Thu Sep 10, 2015 08:39

Image

Thanks a bunch guys! All works now.
I just needed to add:

Code: Select all

    CEGUI::System::getSingleton().injectTimePulse(elapsed);
    CEGUI::System::getSingleton().getDefaultGUIContext().injectTimePulse(elapsed);
    CEGUI::System::getSingleton().renderAllGUIContexts();


I was a bit mislead by the tutorial, because it uses Ogre Renderer, which I guess already does this?
Thanks a lot for your help.

lucebac
Just can't stay away
Just can't stay away
Posts: 193
Joined: Sat May 24, 2014 21:55

Re: Stuck on tutorial - unable to display anything with CEGUI (OpenGL Renderer, Windows)

Postby lucebac » Thu Sep 10, 2015 09:20

I highly recommend putting renderer->beginRendering() before and renderer->endRendering() after your CEGUI::System::getSingleton().renderAllGuiContexts(). Since this might set up some OpenGL states that are needed for CEGUI.

vordhosbn
Just popping in
Just popping in
Posts: 8
Joined: Sat Sep 05, 2015 18:27

Re: [Solved] Stuck on tutorial - unable to display anything with CEGUI (OpenGL Renderer, Windows)

Postby vordhosbn » Thu Sep 10, 2015 15:17

Yes, I will look trough your glfw application template and will post if I have any questions/issues.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 6 guests