.create("TaharezLook.scheme"); throw exception
Posted: Thu Sep 22, 2011 13:56
Hi
i done all the static linking and the example compile and linked successfully
but now i have run time problem . with example that used to work before .
im getting :
on this function :
it seams that the d_scheme is never set , i also set breakpoint at :
but it never gets there ...
here is my example code what is wrong here :
i done all the static linking and the example compile and linked successfully
but now i have run time problem . with example that used to work before .
im getting :
Code: Select all
Unhandled exception at 0x7c812a5b in glsample.exe: Microsoft C++ exception: CEGUI::InvalidRequestException at memory location 0x0012deec..
on this function :
Code: Select all
Scheme& Scheme_xmlHandler::getObject() const
{
if (!d_scheme)
CEGUI_THROW(InvalidRequestException("Scheme_xmlHandler::getObject: "
"Attempt to access null object."));
d_objectRead = true;
return *d_scheme;
}
it seams that the d_scheme is never set , i also set breakpoint at :
Code: Select all
void Scheme_xmlHandler::elementGUISchemeStart(const XMLAttributes& attributes)
{
const String name(attributes.getValueAsString(NameAttribute));
Logger& logger(Logger::getSingleton());
logger.logEvent("Started creation of Scheme from XML specification:");
logger.logEvent("---- CEGUI GUIScheme name: " + name);
// create empty scheme with desired name
d_scheme = new Scheme(name);
}
but it never gets there ...
here is my example code what is wrong here :
Code: Select all
//
// GLSAMPLE.CPP
// by Blaine Hodge
//
// Includes
#include <windows.h>
#include <gl/gl.h>
#include <CEGUI.h>
#include <RendererModules/OpenGL/CEGUIOpenGLRenderer.h>
#define PATH_MAX 256
//#define CEGUI_DATAPATH "cegui/datafiles"
#define CEGUI_DATAPATH "H:/cpp/3d/glsample/cegui/datafiles"
GLuint base; // Base Display List For The Font Set
GLfloat cnt1; // 1st Counter Used To Move Text & For Coloring
GLfloat cnt2; // 2nd Counter Used To Move Text & For Coloring
// Function Declarations
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
void EnableOpenGL(HWND hWnd, HDC * hDC, HGLRC * hRC);
void DisableOpenGL(HWND hWnd, HDC hDC, HGLRC hRC);
// WinMain
// Win32 MessageProc callback
using namespace CEGUI;
bool d_mouseInWindow = false;
bool bCeguiRender = true;
CEGUI::OpenGLRenderer* d_renderer;
CEGUI::GeometryBuffer* d_fps_geometry;
WNDCLASS wc ;
HWND hWnd =NULL ;
HDC hDC =NULL ;
HGLRC hRC =NULL;
MSG msg;
BOOL quit = FALSE;
float theta = 0.0f;
char *getDataPathPrefix()
{
static char dataPathPrefix[PATH_MAX];
strcpy(dataPathPrefix,CEGUI_DATAPATH);
return dataPathPrefix;
}
void mouseEnters()
{
if (!d_mouseInWindow)
{
d_mouseInWindow = true;
ShowCursor(false);
}
}
void mouseLeaves()
{
if (d_mouseInWindow)
{
d_mouseInWindow = false;
ShowCursor(true);
}
}
bool handleCloseFrame(const CEGUI::EventArgs&)
{
using namespace CEGUI;
FrameWindow * frameWindow = static_cast<CEGUI::FrameWindow*>(CEGUI::WindowManager::getSingleton().getWindow("InputNamewin"));
frameWindow->destroy();
bCeguiRender = false;
ShowCursor(true);
return true;
}
bool handleAddUserName(const CEGUI::EventArgs&)
{
using namespace CEGUI;
Editbox* idbox = static_cast<Editbox*>(WindowManager::getSingleton().getWindow("NewInputIDBox"));
String sStr = idbox->getText();
std::string sStlStr(sStr.c_str());
idbox->setText("");
FrameWindow * frameWindow = static_cast<CEGUI::FrameWindow*>(CEGUI::WindowManager::getSingleton().getWindow("InputNamewin"));
frameWindow->destroy();
bCeguiRender = false;
ShowCursor(true);
return true;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int iCmdShow)
{
int numSec = 100; // number of strip sections
int width = 556, height = 556;
int bpp, flags;
int TWquit = 0;
int n, numCubes = 30;
float color0[] = { 1.0f, 0.5f, 0.0f };
float color1[] = { 0.5f, 1.0f, 0.0f };
float color[] = { 1, 0, 0 }; // strip color
double ka = 5.3, kb = 1.7, kc = 4.1;
// register window class
wc.style = CS_OWNDC;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon( NULL, IDI_APPLICATION );
wc.hCursor = LoadCursor( NULL, IDC_ARROW );
wc.hbrBackground = (HBRUSH)GetStockObject( BLACK_BRUSH );
wc.lpszMenuName = NULL;
wc.lpszClassName = "GLSample";
RegisterClass( &wc );
// create main window
hWnd = CreateWindow(
"GLSample", "OpenGL Sample",
WS_CAPTION | WS_POPUPWINDOW | WS_VISIBLE,
0, 0, width, height,
NULL, NULL, hInstance, NULL );
// enable OpenGL for the window
EnableOpenGL( hWnd, &hDC, &hRC );
d_renderer = &CEGUI::OpenGLRenderer::bootstrapSystem();
// clearing this queue actually makes sure it's created(!)
d_renderer->getDefaultRenderingRoot().clearGeometry(CEGUI::RQ_OVERLAY);
CEGUI::DefaultResourceProvider *drp =
static_cast<CEGUI::DefaultResourceProvider *>
(CEGUI::System::getSingleton().getResourceProvider());
char* dataPathPrefix = getDataPathPrefix();
char resourcePath[PATH_MAX];
// for each resource type, set a resource group directory
sprintf(resourcePath, "%s/%s", dataPathPrefix, "schemes/");
drp->setResourceGroupDirectory("schemes", resourcePath);
sprintf(resourcePath, "%s/%s", dataPathPrefix, "imagesets/");
drp->setResourceGroupDirectory("imagesets", resourcePath);
sprintf(resourcePath, "%s/%s", dataPathPrefix, "fonts/");
drp->setResourceGroupDirectory("fonts", resourcePath);
sprintf(resourcePath, "%s/%s", dataPathPrefix, "layouts/");
drp->setResourceGroupDirectory("layouts", resourcePath);
sprintf(resourcePath, "%s/%s", dataPathPrefix, "looknfeel/");
drp->setResourceGroupDirectory("looknfeels", resourcePath);
/* sprintf(resourcePath, "%s/%s", dataPathPrefix, "lua_scripts/");
drp->setResourceGroupDirectory("lua_scripts", resourcePath);*/
sprintf(resourcePath, "%s/%s", dataPathPrefix, "xml_schemas/");
drp->setResourceGroupDirectory("schemas", resourcePath);
// set the default resource groups to be used
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");
// setup default group for validation schemas
CEGUI::XMLParser* parser = CEGUI::System::getSingleton().getXMLParser();
if (parser->isPropertyPresent("SchemaDefaultResourceGroup"))
parser->setProperty("SchemaDefaultResourceGroup", "schemas");
CEGUI::WindowManager &winMgr = CEGUI::WindowManager::getSingleton();
SchemeManager::getSingleton().create("TaharezLook.scheme"); <----------------------HERE exception !!!!!
System::getSingleton().setDefaultMouseCursor("TaharezLook", "MouseArrow");
DefaultWindow* root = (DefaultWindow*)winMgr.createWindow("DefaultWindow", "Root");
System::getSingleton().setGUISheet(root);
FrameWindow* wnd = (FrameWindow*)winMgr.createWindow("TaharezLook/FrameWindow", "InputNamewin");
wnd->setProperty("AutoRenderingSurface", "false");
root->addChildWindow(wnd);
wnd->setPosition(UVector2(cegui_reldim(0.25f), cegui_reldim( 0.25f)));
wnd->setSize(UVector2(cegui_reldim(0.5f), cegui_reldim( 0.5f)));
wnd->setMaxSize(UVector2(cegui_reldim(1.0f), cegui_reldim( 1.0f)));
wnd->setMinSize(UVector2(cegui_reldim(0.1f), cegui_reldim( 0.1f)));
wnd->setText("Input User Name ");
wnd->setCloseButtonEnabled(true);
Editbox* ebox = static_cast<Editbox*>(winMgr.createWindow("TaharezLook/Editbox", "NewInputIDBox"));
wnd->addChildWindow(ebox);
ebox->setPosition(UVector2(cegui_reldim(0.10f), cegui_reldim( 0.32f)));
ebox->setSize(UVector2(cegui_reldim(0.76f), cegui_reldim( 0.15f)));
PushButton* btnOk = static_cast<PushButton*>(winMgr.createWindow("TaharezLook/Button", "PushButtonOk"));
wnd->addChildWindow(btnOk);
btnOk->setPosition(UVector2(cegui_reldim(0.80f), cegui_reldim( 0.850f)));
btnOk->setSize(UVector2(cegui_reldim(0.15f), cegui_reldim( 0.100f)));
btnOk->setText("Ok");
PushButton* btnCncl = static_cast<PushButton*>(winMgr.createWindow("TaharezLook/Button", "PushButtonCncl"));
wnd->addChildWindow(btnCncl);
btnCncl->setPosition(UVector2(cegui_reldim(0.10f), cegui_reldim( 0.850f)));
btnCncl->setSize(UVector2(cegui_reldim(0.15f), cegui_reldim( 0.100f)));
btnCncl->setText("Cancel");
wnd->subscribeEvent(FrameWindow::EventCloseClicked, Event::Subscriber(&handleCloseFrame));
btnCncl->
subscribeEvent(PushButton::EventClicked, Event::Subscriber(&handleCloseFrame));
btnOk->
subscribeEvent(PushButton::EventClicked, Event::Subscriber(&handleAddUserName));
// program main loop
while ( !quit )
{
// check for messages
if ( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
{
// handle or dispatch messages
if ( msg.message == WM_QUIT )
{
quit = TRUE;
}
else
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
}
else
{
// OpenGL animation code goes here
glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
glClear( GL_COLOR_BUFFER_BIT );
glPushMatrix();
glRotatef( theta, 0.0f, 0.0f, 1.0f );
glBegin( GL_TRIANGLES );
glColor3f( 1.0f, 0.0f, 0.0f ); glVertex2f( 0.0f, 1.0f );
glColor3f( 0.0f, 1.0f, 0.0f ); glVertex2f( 0.87f, -0.5f );
glColor3f( 0.0f, 0.0f, 1.0f ); glVertex2f( -0.87f, -0.5f );
glEnd();
glPopMatrix();
/*glBindTexture(0);
glUseProgram(0);
glActiveTexture(GL_TEXTURE_0);*/
if(bCeguiRender)
CEGUI::System::getSingleton().renderGUI();
SwapBuffers( hDC );
theta += 1.0f;
}
}
// shutdown OpenGL
DisableOpenGL( hWnd, hDC, hRC );
// destroy the window explicitly
DestroyWindow( hWnd );
return msg.wParam;
}
// Window Procedure
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_CHAR:
CEGUI::System::getSingleton().injectChar((CEGUI::utf32)wParam);
break;
case WM_MOUSELEAVE:
mouseLeaves();
break;
case WM_NCMOUSEMOVE:
mouseLeaves();
break;
case WM_MOUSEMOVE:
mouseEnters();
CEGUI::System::getSingleton().injectMousePosition((float)(LOWORD(lParam)), (float)(HIWORD(lParam)));
break;
case WM_LBUTTONDOWN:
CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::LeftButton);
break;
case WM_LBUTTONUP:
CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::LeftButton);
break;
case WM_RBUTTONDOWN:
CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::RightButton);
break;
case WM_RBUTTONUP:
CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::RightButton);
break;
case WM_MBUTTONDOWN:
CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::MiddleButton);
break;
case WM_MBUTTONUP:
CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::MiddleButton);
break;
case 0x020A: // WM_MOUSEWHEEL:
CEGUI::System::getSingleton().injectMouseWheelChange(static_cast<float>((short)HIWORD(wParam)) / static_cast<float>(120));
break;
case WM_CREATE:
return 0;
case WM_CLOSE:
PostQuitMessage( 0 );
return 0;
case WM_DESTROY:
return 0;
case WM_KEYDOWN:
switch ( wParam )
{
case VK_ESCAPE:
PostQuitMessage(0);
return 0;
}
return 0;
default:
return DefWindowProc( hWnd, message, wParam, lParam );
}
}
// Enable OpenGL
void EnableOpenGL(HWND hWnd, HDC * hDC, HGLRC * hRC)
{
PIXELFORMATDESCRIPTOR pfd;
int format;
// get the device context (DC)
*hDC = GetDC( hWnd );
// set the pixel format for the DC
ZeroMemory( &pfd, sizeof( pfd ) );
pfd.nSize = sizeof( pfd );
pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 24;
pfd.cDepthBits = 16;
pfd.iLayerType = PFD_MAIN_PLANE;
format = ChoosePixelFormat( *hDC, &pfd );
SetPixelFormat( *hDC, format, &pfd );
// create and enable the render context (RC)
*hRC = wglCreateContext( *hDC );
wglMakeCurrent( *hDC, *hRC );
}
// Disable OpenGL
void DisableOpenGL(HWND hWnd, HDC hDC, HGLRC hRC)
{
CEGUI::OpenGLRenderer::destroySystem();
wglMakeCurrent( NULL, NULL );
wglDeleteContext( hRC );
ReleaseDC( hWnd, hDC );
}