rendering with opengl (all fixed)

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

duindain
Just popping in
Just popping in
Posts: 19
Joined: Sat Jun 09, 2007 08:51

rendering with opengl (all fixed)

Postby duindain » Mon Jun 11, 2007 17:36

Hey im trying to add the cegui system into our own graphics engine which uses opengl im kindof cheating and using the cegui opengl system at the moment though ive been using these two forum posts so far
http://www.cegui.org.uk/wiki/index.php/ ... _Rendering
http://www.cegui.org.uk/phpBB2/viewtopic.php?t=1270

ok it all compiles when i run it with the menu system enabled it crashs and says
Microsoft C++ exception: CEGUI::InvalidRequestException at memory location 0x0012d948

i figure im not including something i should in the system could someone look over my implementation briefly and give me a few pointers please :)

this is my header for cegui inside the engine

Code: Select all

#ifndef GUIINTERFACE_H
#define GUIINTERFACE_H

#define CEGUI_SAMPLES_USE_OPENGL
#include <CEGUI.h>
#include "openglrenderer.h"

using namespace CEGUI;

#pragma comment (lib, "CEGUIBase_d.lib")
#pragma comment (lib, "OpenGLGUIRenderer_d.lib")

class guiInterface
{
public:
   guiInterface();
   ~guiInterface() {cleanUp();}
   void initilise();
   void Render();
   void cleanUp();
private:
   FrameWindow* wnd;
   System* cegui;
   OpenGLRenderer* ceguir;

};
#endif

implementation file

Code: Select all

#include "gui.h"

void guiInterface::initilise()
{
   ceguir = new OpenGLRenderer(500);

//   CEGUI::Logger().getSingleton().setLoggingLevel(Insane );
   cegui = new System(ceguir);
 
}
guiInterface::guiInterface()
{
   wnd = 0;
   cegui = 0;
   ceguir = 0;
}
void guiInterface::cleanUp()
{
   delete System::getSingletonPtr();
}
void guiInterface::Render()
{
   if(cegui)
      cegui->renderGUI();
}


im using a modified version of sample 7 to initilise the gui object and to call render frame by frame in a while loop since i need to do some other networking stuff too

header for sample

Code: Select all

#ifndef _Sample_Demo7_h_
#define _Sample_Demo7_h_

#include "gui.h"
#include "CEGUI.h"
#include <string>
#include <vector>
#include <iostream>
#include "ServerClient.h"

namespace std {}
using namespace std;

// Sample class
class Demo7Sample
{
private:
   bool network_active;
   int difficulty;
public:
   
   int getDifficulty() { return difficulty;}
   ServerClient network;
    // method to initialse the samples windows and events.
    bool initialiseSample();
   bool getNetworkStatus() { return network_active;}
    // method to perform any required cleanup operations.
    void cleanupSample(void);
   bool run();

protected:
    // initialisation helpers
   bool quit;
   bool updateServers;
   bool renderMenu;

   void createListContent(void);
    void initDemoEventWiring(void);
   void initWindows(void);

    // methods that process GUI events
    bool handleQuit(const CEGUI::EventArgs& e);
    bool handleSlider(const CEGUI::EventArgs& e);
    bool handleRadio(const CEGUI::EventArgs& e);
    bool handleCheck(const CEGUI::EventArgs& e);
   bool handleButtonClick(const CEGUI::EventArgs& e);

   void swapWindows(string vis,string invis);

   guiInterface gui;
   
};
#endif


implementation file

Code: Select all

#include "Sample_Demo7.h"
#include "CEGUI.h"
#include "CEGuiBaseApplication.h"

#include <cstdlib>

bool Demo7Sample::run()
{
   gui.initilise();

   initialiseSample();

   while(renderMenu)
   {
      if(getNetworkStatus())
      {
         network.process();
         if(updateServers)
         {

         }
      }
      gui.Render();
   }
   if(quit)
      return 1;
   else
      return 0;
}

bool Demo7Sample::initialiseSample()
{
   difficulty = 0;
   updateServers = true;
   quit = false;
   renderMenu = true;
   network_active = false;
    using namespace CEGUI;

    // we will use of the WindowManager.
    WindowManager& winMgr = WindowManager::getSingleton();

    // load scheme and set up defaults
    SchemeManager::getSingleton().loadScheme("TaharezLook.scheme");
    System::getSingleton().setDefaultMouseCursor("TaharezLook", "MouseArrow");
    FontManager::getSingleton().createFont("Commonwealth-10.font");

    // load an image to use as a background
    ImagesetManager::getSingleton().createImagesetFromImageFile("BackgroundImage", "GPN-2000-001437.tga");

    // here we will use a StaticImage as the root, then we can use it to place a background image
    Window* background = winMgr.createWindow("TaharezLook/StaticImage", "background_wnd");
    // set position and size
    background->setPosition(UVector2(cegui_reldim(0), cegui_reldim( 0)));
    background->setSize(UVector2(cegui_reldim(1), cegui_reldim( 1)));
    // disable frame and standard background
    background->setProperty("FrameEnabled", "false");
    background->setProperty("BackgroundEnabled", "false");
    // set the background image
    background->setProperty("Image", "set:BackgroundImage image:full_image");
    // install this as the root GUI sheet
    System::getSingleton().setGUISheet(background);

    // load the windows for Demo7 from the layout file.
    Window* sheet = winMgr.loadWindowLayout("Demo7Windows.layout");
    // attach this to the 'real' root
    background->addChildWindow(sheet);
   initWindows();
    // set-up the contents of the list boxes.
    createListContent();
    // initialise the event handling.
    initDemoEventWiring();

    // success!
    return true;
}
void Demo7Sample::initWindows(void)
{
//sets all windows invisible but one
}
void Demo7Sample::cleanupSample()
{
    // nothing to do here!
   gui.cleanUp();
}
void Demo7Sample::initDemoEventWiring(void)
{
    //adds event callbacks
}

bool Demo7Sample::handleButtonClick(const CEGUI::EventArgs& e)
{
  //swaps windows
   // event was handled
    return true;
}
//accepts window to make visible, window to make invisible
void Demo7Sample::swapWindows(string vis,string invis)
{
//   switchs windows
}
bool Demo7Sample::handleQuit(const CEGUI::EventArgs& e)
{
    // signal quit
    quit = true;
   renderMenu = false;
    // event was handled
    return quit;
}

the crash occurs in this statement at the throw invalidrequest line in file
ceguidefualtresourceprovider.cpp

Code: Select all

std::ifstream dataFile(final_filename.c_str(), std::ios::binary|std::ios::ate);
        if( dataFile.fail())
        {
            throw InvalidRequestException(
                "DefaultResourceProvider::load - " + filename + " does not exist");
        }


it sounds like im missing some file the debug filenames are all numbers so i couldnt get any clues from there

the layout file is modified but it all compiled and displayed fine before i started integrating it to the new engine

these are the only things i use to interact with the cegui system
thankyou for looking at the code if you do :)
Last edited by duindain on Fri Jun 15, 2007 15:01, edited 2 times in total.

Pompei2
Home away from home
Home away from home
Posts: 489
Joined: Tue May 23, 2006 16:31

Postby Pompei2 » Mon Jun 11, 2007 18:53

Did you take a look in the log file ? it often contains precious informations.

CEGUI::InvalidRequestException

means that CEGUI threw an exception that you didn't catch, AFAIK.
You should surround all code-blocks that deal with CEGUI by the following:

Code: Select all

try {
   // Some CEGUI code here
} catch( CEGUI::Exception& e ) {
   fprintf( stderr, "CEGUI error: %s\n", e.getMessage( ).c_str( ) );
}


Then you will get a more accruate error, hopefully. Trying to find where an Exception comes from using the debugger is horrible - or maybe I am stupid ? :)

User avatar
scriptkid
Home away from home
Home away from home
Posts: 1178
Joined: Wed Jan 12, 2005 12:06
Location: The Hague, The Netherlands
Contact:

Postby scriptkid » Mon Jun 11, 2007 18:58

Hi,

yeah it looks like you are missing a file. You can try this trick in the debugger (assuming you are using VC): cast the 'filename' as (char*)filename.c_str() in the stack view, then you should be able to see its content. If you did not change the sample base class then your resources should be setup correctly. You can try to trim your 'initialiseSample' method and start uncommenting stuff until you get the error. Otherwise can you try to put a breakpoint in the beginning of the 'initialiseSample' and step from there?

Good luck! :)

Pompei2
Home away from home
Home away from home
Posts: 489
Joined: Tue May 23, 2006 16:31

Postby Pompei2 » Mon Jun 11, 2007 19:02

scriptkid wrote:You can try this trick in the debugger (assuming you are using VC): cast the 'filename' as (char*)filename.c_str() in the stack view, then you should be able to see its content.

Heh, nice trick, I was always grumbling about these CEGUI::Strings where I can't see the content :P

ppl
Not too shy to talk
Not too shy to talk
Posts: 31
Joined: Tue May 15, 2007 16:37
Location: Canada

Postby ppl » Mon Jun 11, 2007 19:05

Pompei2 wrote:Heh, nice trick, I was always grumbling about these CEGUI::Strings where I can't see the content :P


If only I could figure out VC++ 2003 autoexp.dat format... That would allow one to simply hover on the CEGUI::String to see the content.

Anyone have an autoexp.dat entry for CEGUI::String?

duindain
Just popping in
Just popping in
Posts: 19
Joined: Sat Jun 09, 2007 08:51

Postby duindain » Mon Jun 11, 2007 21:01

thx for everyones quick responses using the try catch statement i found that it wasent loading any of the schemas or layouts or anything heh ive droped them all into the excutable folder and now its loading them all

the graphics window however isnt coming up anyone got any ideas the code is still the same as the original post

no errors the dos window loads and nothing else happens can anyone see any obvious fogetting to tell the window to come up or something

maybe theres a pointer to the window thats going out of scope or something anyway thankyou for helping everyone

Pompei2
Home away from home
Home away from home
Posts: 489
Joined: Tue May 23, 2006 16:31

Postby Pompei2 » Tue Jun 12, 2007 07:46

oh yes, now i see it. you don't create a window :) CEGUI doesn't create a window itself, you have to create one using SDL, windows.g, wxwindows or whatever. Create it the same way as you create a window to render some OpenGL into it.

In the tutorials section, every tutorial under the "Window System Examples" treats this.

If you wanted to inherit from the samples projects framework, I see no place where you inherit the class :)

Or do I completely misunderstand you ?

duindain
Just popping in
Just popping in
Posts: 19
Joined: Sat Jun 09, 2007 08:51

maybe working

Postby duindain » Tue Jun 12, 2007 09:16

ok ive got a window to come up still working on it ill post again soon with my next idiotic question thx everyone

at the moment its loading the window but nothing in it ill figure it out i hope

Pompei2
Home away from home
Home away from home
Posts: 489
Joined: Tue May 23, 2006 16:31

Postby Pompei2 » Fri Jun 15, 2007 11:00

there is no idiotic question, i was a noob in CEGUI too when i began :P


Return to “Help”

Who is online

Users browsing this forum: No registered users and 20 guests