Page 1 of 1

Insuffient memory at the second CEGUI call

Posted: Tue Jan 09, 2007 13:11
by abel.bernabeu
I have problems with CEGUI for Windows.

I have downloaded the sources of 0.5 stable version. I have compiled them and linked against the DirectX 9 SDK of December 2006.

Now I am sucessful compiling and linking with my "hello world" program for OpenGl, but when I execute the first two CEGUI calls I get a problem of insufficient memory:

Code: Select all


   CEGUI::OpenGLRenderer *cegui_renderer = new CEGUI::OpenGLRenderer(0);
   CEGUI::System *sys = new CEGUI::System(cegui_renderer);    // Fails


Any ideas?

The complete program is the following:

Code: Select all

#include <Windows.h>
#include <GL/glut.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <CEGUI.h>
#include <RendererModules/OpenGLGUIRenderer/openglrenderer.h>

void display ()
{
   // clear framebuffer
   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

   // draw teapot
   glFrontFace(GL_CW);
   glutSolidTeapot(2.5);
   glFrontFace(GL_CCW);

   // swap front and back buffers
   glutSwapBuffers();
}

void reshape (int width, int height)
{
   glViewport(0, 0, width, height);
}

void mouse (int button, int state, int x, int y)
{
}

void motion (int x, int y)
{
}

void main()
{
    int argc = 1;
    char* argv = "SampleApp";
   glutInit(&argc, &argv);
    glutInitDisplayMode(GLUT_DEPTH|GLUT_DOUBLE|GLUT_RGBA);
    glutInitWindowSize(800, 600);
    glutInitWindowPosition(100, 100);
    glutCreateWindow("Crazy Eddie's GUI Mk-2 - Sample Application");
    glutSetCursor(GLUT_CURSOR_NONE);

   CEGUI::OpenGLRenderer *cegui_renderer;
   cegui_renderer = new CEGUI::OpenGLRenderer(0);
   CEGUI::System *sys = new CEGUI::System(cegui_renderer);    // The memory allocation fails

   // register callback functions
   glutDisplayFunc(display);
   glutReshapeFunc(reshape);
   glutMouseFunc(mouse);
   glutMotionFunc(motion);

   // hand over event processing to GLUT
   glutMainLoop();
}

Posted: Tue Jan 09, 2007 13:37
by Pompei2
Does CEGUI write something in the log file ?

Posted: Tue Jan 09, 2007 14:23
by abel.bernabeu
Pompei2 wrote:Does CEGUI write something in the log file ?


No, the CEGUI.log file does not even get created.

In order to activate the logging I should be able to execute the call:

CEGUI::Logger::getSingleton().setLoggingLevel(CEGUI::Informative);

But prior to that call, I'm not even able to create the CGUI::System object due to the mentioned premature memory fault (not enough memory).

Posted: Tue Jan 09, 2007 16:31
by Das Gurke
Never worked with OpenGL and CEGUI, but what about passing some arguments to the renderer constructor?

Edit:
Sorry, that was bullshit :oops:

Posted: Tue Jan 09, 2007 17:55
by abel.bernabeu
Never worked with OpenGL and CEGUI, but what about passing some arguments to the renderer constructor?


The default values are right and there is no need no specify your own ones.

But, you know? I've discovered the problem by myself after more than tree days wasted :(

My linking options were not coherent because I was mixing the use of debug dlls with release libraries.

In instance the executable not running due to a memory fault imports the following libraries according to TDUMP output:

Imports from OpenGLGUIRenderer_d.dll
Imports from freeglut.dll
Imports from OPENGL32.dll
Imports from CEGUIBase.dll
Imports from MSVCR80.dll
Imports from KERNEL32.dll

Notice that I was mixing OpenGLGUIRenderer_d.dll (the debug version) with freeglut.dll and CEGUIBase.dll (release versions).

After some time wasted debugging the CEGUI code I tried another thing: starting a new clean project based on a .prj supplied with the standar SDK. I saw that worked, and then by dumping the final executable I can understand why it works:

Imports from CEGUIBase_d.dll
Imports from OpenGLGUIRenderer_d.dll
Imports from freeglut_d.dll
Imports from OPENGL32.dll
Imports from MSVCR80D.dll
Imports from KERNEL32.dll

The executable running properly uses the _d postfixed dlls.

Moral: Be coherent in the use of debug or release libraries. Do not mix them O:)