Ogre 1.2.0RCI Assert

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

d3th n1gG4
Just popping in
Just popping in
Posts: 2
Joined: Thu Apr 06, 2006 21:13
Contact:

Ogre 1.2.0RCI Assert

Postby d3th n1gG4 » Sun Apr 09, 2006 22:06

Hey Guys

I'm having some issues with Ogre 1.2.0 RC1 & Cegui, basically depending on how I initialise my classes I either get a crash in my contructor of my CEGUI controlling class, or I get a ms_singleton assert error

I have posted this on the Ogre forum here and have had no joy. I'm going to paraphrase what I am doing below

here is my initial method


If I dump the same code into my main function it runs fine, the problem seems to be when its hitting the function definition of my class constructor.

anyways heres a simplified version of my class

Code: Select all

namespace bdb{
  namespace gui{
    class GuiHandler{
      private:
         CEGUI::OgreCEGUIRenderer* mGUIRenderer;
         CEGUI::System* mGUISystem;
         CEGUI::WindowManager mRoot;
         CEGUI::Window* mWindow;

      public:
       
        std::vector<guiPageBase*>  mPageList;
        GuiHandler(Ogre::RenderWindow* window, Ogre::SceneManager* sceneMgr);
        ~GuiHandler();   

        void Initialise();

        inline  CEGUI::OgreCEGUIRenderer* getGuiRenderer(){return mGUIRenderer;}
        inline  CEGUI::System*            getGuiSystem(){return mGUISystem;}
        inline  CEGUI::Window*            getGuiWindow(){return mWindow;}
        inline  CEGUI::WindowManager&     getGuiWindowManager(){return mRoot;}
        CEGUI::Window* txCurrentX;
    };
  }
}


and its constructor

Code: Select all

bdb::gui::GuiHandler::GuiHandler(Ogre::RenderWindow* window, Ogre::SceneManager* sceneMgr):mGUIRenderer(0),mGUISystem(0){
   mGUIRenderer
      = new CEGUI::OgreCEGUIRenderer(window, Ogre::RENDER_QUEUE_OVERLAY, false, 3000, sceneMgr);
  mGUISystem
      = new CEGUI::System(mGUIRenderer);
   CEGUI::Logger::getSingleton().setLoggingLevel(CEGUI::Informative);
   CEGUI::SchemeManager::getSingleton().loadScheme((CEGUI::utf8*)"TaharezLook.scheme");
   mGUISystem->setDefaultMouseCursor((CEGUI::utf8*)"TaharezLook", (CEGUI::utf8*)"MouseArrow");
  mGUISystem->setDefaultFont((CEGUI::utf8*)"Tahoma-10");

   // set the mouse cursor initially in the middle of the screen
   mGUISystem->injectMousePosition((float)window->getWidth() / 2.0f, (float)window->getHeight() / 2.0f);
 
  mRoot = CEGUI::WindowManager::getSingleton();

  mWindow = mRoot.createWindow("DefaultWindow","CEGUIROOT");
  mGUISystem->setGUISheet(mWindow);
}


I am crashing somewhere on this line in the constructor

Code: Select all

bdb::gui::GuiHandler::GuiHandler(Ogre::RenderWindow* window, Ogre::SceneManager* sceneMgr):mGUIRenderer(0),mGUISystem(0){


ok heres my calling code again paraphrased

Code: Select all

  Ogre::Root *ogre;
  Ogre::RenderWindow *window;
  Ogre::SceneManager *sceneMgr;
  Ogre::Camera *camera;
  bdb::techdemo::MudSchool *m_myMudSchool;

  bdb::gui::GuiHandler* myGuiHandler;

  /*... Stuff removed ...*/
 
  Ogre::NameValuePairList opts;
   opts.insert(Ogre::NameValuePairList::value_type("resolution", "1024x768"));
   opts.insert(Ogre::NameValuePairList::value_type("fullscreen", "false"));
   opts.insert(Ogre::NameValuePairList::value_type("vsync", "true"));

   // create a rendering window with the title "BDB"
  window = ogre->createRenderWindow("BDB TechDemo::Mudschool Island", 1024, 768, false, &opts);

 
  sceneMgr = ogre->createSceneManager(Ogre::ST_EXTERIOR_CLOSE, "DefaultScene");
  try{   
    myGuiHandler = new bdb::gui::GuiHandler(window, sceneMgr);
  }
  catch(Ogre::Exception e){
  }


I have a breakpoint on my catch statement but it never reaches it

here is my error message

Code: Select all

---------------------------
Microsoft Visual C++ Debug Library
---------------------------
Debug Error!

Program: I:\BDB_NEW\game\Debug\game.exe



This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.



(Press Retry to debug the application)
---------------------------
Abort   Retry   Ignore   
---------------------------



here is a stack trace, nothing odd in it to my eyes, well except that ceguibase_d.dll seems to be the bugger who is breaking...

Code: Select all

>   msvcr80d.dll!_NMSG_WRITE(int rterrnum=0x0000000a)  Line 198   C
    msvcr80d.dll!abort()  Line 59 + 0x7 bytes   C
    msvcr80d.dll!_wassert(const wchar_t * expr=0x00a7d2b4, const wchar_t * filename=0x00a7d228, unsigned int lineno=0x00000042)  Line 212   C
    CEGUIBase_d.dll!0088bc6b()    
    [Frames below may be incorrect and/or missing, no symbols loaded for CEGUIBase_d.dll]   
    CEGUIBase_d.dll!0088bc13()    
    CEGUIBase_d.dll!00918608()    
    game.exe!bdb::gui::GuiHandler::GuiHandler(Ogre::RenderWindow * window=0x006db840, Ogre::SceneManager * sceneMgr=0x0012e870)  Line 3 + 0x63 bytes   C++


and finally my ogre log which looks fine

Code: Select all

23:21:04: Creating resource group General
23:21:04: Creating resource group Internal
23:21:04: Creating resource group Autodetect
23:21:04: Registering ResourceManager for type Material
23:21:04: Registering ResourceManager for type Mesh
23:21:04: Registering ResourceManager for type Skeleton
23:21:04: MovableObjectFactory for type 'ParticleSystem' registered.
23:21:04: Loading library OgrePlatform_d.dll
23:21:04: OverlayElementFactory for type Panel registered.
23:21:04: OverlayElementFactory for type BorderPanel registered.
23:21:04: OverlayElementFactory for type TextArea registered.
23:21:04: Registering ResourceManager for type Font
23:21:04: ArchiveFactory for archive type FileSystem registered.
23:21:04: ArchiveFactory for archive type Zip registered.
23:21:04: DevIL version: Developer's Image Library (DevIL) 1.6.7 Nov  9 2005
23:21:04: DevIL image formats: bmp dib cut dcx dds gif hdr ico cur jpg jpe jpeg lif mdl mng jng pcx pic pix png pbm pgm pnm ppm psd pdd psp pxr sgi bw rgb rgba tga vda icb vst tif tiff wal xpm raw
23:21:04: Registering ResourceManager for type HighLevelGpuProgram
23:21:04: Registering ResourceManager for type Compositor
23:21:04: MovableObjectFactory for type 'Entity' registered.
23:21:04: MovableObjectFactory for type 'Light' registered.
23:21:04: MovableObjectFactory for type 'BillboardSet' registered.
23:21:04: MovableObjectFactory for type 'ManualObject' registered.
23:21:04: MovableObjectFactory for type 'BillboardChain' registered.
23:21:04: MovableObjectFactory for type 'RibbonTrail' registered.
23:21:04: *-*-* OGRE Initialising
23:21:04: *-*-* Version 1.2.0 (Dagon)
23:21:04: Loading library RenderSystem_GL
23:21:04: OpenGL Rendering Subsystem created.
23:21:04: *** Starting Win32GL Subsystem ***
23:21:04: ResourceBackgroundQueue - threading disabled
23:21:04: Loading library Plugin_CgProgramManager
23:21:04: Loading library Plugin_OctreeSceneManager
23:21:04: Added resource location 'resource' of type 'FileSystem' to resource group 'General'
23:21:04: Creating resource group MudSchool
23:21:04: Added resource location 'resource/mudschool' of type 'FileSystem' to resource group 'MudSchool'
23:21:04: Creating resource group MudSchoolMedia
23:21:04: Added resource location 'resource/mudschool/Media' of type 'FileSystem' to resource group 'MudSchoolMedia'
23:21:04: Creating resource group MudSchoolModels
23:21:04: Added resource location 'resource/mudschool/Models' of type 'FileSystem' to resource group 'MudSchoolModels'
23:21:04: Creating resource group MudSchoolTex
23:21:04: Added resource location 'resource/mudschool/textures' of type 'FileSystem' to resource group 'MudSchoolTex'
23:21:04: Creating resource group Gui
23:21:04: Added resource location 'resource/gui' of type 'FileSystem' to resource group 'Gui'
23:21:04: Creating resource group Fonts
23:21:04: Added resource location 'resource/gui/fonts' of type 'FileSystem' to resource group 'Fonts'
23:21:04: Creating resource group Programs
23:21:04: Added resource location 'resource/scripts/gfx/programs' of type 'FileSystem' to resource group 'Programs'
23:21:04: Creating resource group Shaders
23:21:05: Added resource location 'resource/scripts/gfx/shaders' of type 'FileSystem' to resource group 'Shaders'
23:21:05: Initialising resource group General
23:21:05: Parsing scripts for resource group General
23:21:05: Finished parsing scripts for resource group General
23:21:05: Initialising resource group MudSchool
23:21:05: Parsing scripts for resource group MudSchool
23:21:05: Parsing script mudschool.material
23:21:05: Finished parsing scripts for resource group MudSchool
23:21:05: Initialising resource group MudSchoolMedia
23:21:05: Parsing scripts for resource group MudSchoolMedia
23:21:05: Finished parsing scripts for resource group MudSchoolMedia
23:21:05: Initialising resource group MudSchoolModels
23:21:05: Parsing scripts for resource group MudSchoolModels
23:21:05: Parsing script bush.material
23:21:05: Parsing script sailingboat.material
23:21:05: Parsing script longhouse.material
23:21:05: Finished parsing scripts for resource group MudSchoolModels
23:21:05: Initialising resource group MudSchoolTex
23:21:05: Parsing scripts for resource group MudSchoolTex
23:21:05: Finished parsing scripts for resource group MudSchoolTex
23:21:05: Initialising resource group Gui
23:21:05: Parsing scripts for resource group Gui
23:21:05: Finished parsing scripts for resource group Gui
23:21:05: Initialising resource group Fonts
23:21:05: Parsing scripts for resource group Fonts
23:21:05: Finished parsing scripts for resource group Fonts
23:21:05: Initialising resource group Programs
23:21:05: Parsing scripts for resource group Programs
23:21:05: Finished parsing scripts for resource group Programs
23:21:05: Initialising resource group Shaders
23:21:05: Parsing scripts for resource group Shaders
23:21:05: Finished parsing scripts for resource group Shaders
23:21:05: GLRenderSystem::createRenderWindow "BDB TechDemo::Mudschool Island", 1024x768 windowed  miscParams: fullscreen=false resolution=1024x768 vsync=true
23:21:05: Created Win32Window 'BDB TechDemo::Mudschool Island' : 1024x768, 32bpp
23:21:05: GL_VERSION = 2.0.1
23:21:05: GL_VENDOR = NVIDIA Corporation
23:21:05: GL_RENDERER = GeForce 6600 GT/AGP/SSE2
23:21:05: GL_EXTENSIONS = GL_ARB_color_buffer_float GL_ARB_depth_texture GL_ARB_draw_buffers GL_ARB_fragment_program GL_ARB_fragment_program_shadow GL_ARB_fragment_shader GL_ARB_half_float_pixel GL_ARB_imaging GL_ARB_multisample GL_ARB_multitexture GL_ARB_occlusion_query GL_ARB_pixel_buffer_object GL_ARB_point_parameters GL_ARB_point_sprite GL_ARB_shadow GL_ARB_shader_objects GL_ARB_shading_language_100 GL_ARB_texture_border_clamp GL_ARB_texture_compression GL_ARB_texture_cube_map GL_ARB_texture_env_add GL_ARB_texture_env_combine GL_ARB_texture_env_dot3 GL_ARB_texture_float GL_ARB_texture_mirrored_repeat GL_ARB_texture_non_power_of_two GL_ARB_texture_rectangle GL_ARB_transpose_matrix GL_ARB_vertex_buffer_object GL_ARB_vertex_program GL_ARB_vertex_shader GL_ARB_window_pos GL_ATI_draw_buffers GL_ATI_texture_float GL_ATI_texture_mirror_once GL_S3_s3tc GL_EXT_texture_env_add GL_EXT_abgr GL_EXT_bgra GL_EXT_blend_color GL_EXT_blend_equation_separate GL_EXT_blend_func_separate GL_EXT_blend_minmax GL_EXT_blend_subtract GL_EXT_compiled_vertex_array GL_EXT_Cg_shader GL_EXT_depth_bounds_test GL_EXT_draw_range_elements GL_EXT_fog_coord GL_EXT_framebuffer_object GL_EXT_multi_draw_arrays GL_EXT_packed_depth_stencil GL_EXT_packed_pixels GL_EXT_pixel_buffer_object GL_EXT_point_parameters GL_EXT_rescale_normal GL_EXT_secondary_color GL_EXT_separate_specular_color GL_EXT_shadow_funcs GL_EXT_stencil_two_side GL_EXT_stencil_wrap GL_EXT_texture3D GL_EXT_texture_compression_s3tc GL_EXT_texture_cube_map GL_EXT_texture_edge_clamp GL_EXT_texture_env_combine GL_EXT_texture_env_dot3 GL_EXT_texture_filter_anisotropic GL_EXT_texture_lod GL_EXT_texture_lod_bias GL_EXT_texture_mirror_clamp GL_EXT_texture_object GL_EXT_texture_sRGB GL_EXT_timer_query GL_EXT_vertex_array GL_HP_occlusion_test GL_IBM_rasterpos_clip GL_IBM_texture_mirrored_repeat GL_KTX_buffer_region GL_NV_blend_square GL_NV_copy_depth_to_color GL_NV_depth_clamp GL_NV_fence GL_NV_float_buffer GL_NV_fog_distance GL_NV_fragment_program GL_NV_fragment_program_option GL_NV_fragment_program2 GL_NV_half_float GL_NV_light_max_exponent GL_NV_multisample_filter_hint GL_NV_occlusion_query GL_NV_packed_depth_stencil GL_NV_pixel_data_range GL_NV_point_sprite GL_NV_primitive_restart GL_NV_register_combiners GL_NV_register_combiners2 GL_NV_texgen_reflection GL_NV_texture_compression_vtc GL_NV_texture_env_combine4 GL_NV_texture_expand_normal GL_NV_texture_rectangle GL_NV_texture_shader GL_NV_texture_shader2 GL_NV_texture_shader3 GL_NV_vertex_array_range GL_NV_vertex_array_range2 GL_NV_vertex_program GL_NV_vertex_program1_1 GL_NV_vertex_program2 GL_NV_vertex_program2_option GL_NV_vertex_program3 GL_NVX_conditional_render GL_SGIS_generate_mipmap GL_SGIS_texture_lod GL_SGIX_depth_texture GL_SGIX_shadow GL_SUN_slice_accum GL_WIN_swap_hint WGL_EXT_swap_control
23:21:05: Supported WGL extensions: WGL_ARB_buffer_region WGL_ARB_extensions_string WGL_ARB_make_current_read WGL_ARB_multisample WGL_ARB_pbuffer WGL_ARB_pixel_format WGL_ARB_render_texture WGL_ATI_pixel_format_float WGL_EXT_extensions_string WGL_EXT_swap_control WGL_NV_float_buffer WGL_NV_render_depth_texture WGL_NV_render_texture_rectangle
23:21:05: ***************************
*** GL Renderer Started ***
***************************
23:21:05: Registering ResourceManager for type GpuProgram
23:21:05: GLSL support detected
23:21:05: GL: Using GL_EXT_framebuffer_object for rendering to textures (best)
23:21:05: FBO PF_UNKNOWN depth/stencil support: D16S0 D24S0 D32S0
23:21:05: FBO PF_R5G6B5 depth/stencil support: D0S0 D16S0
23:21:05: FBO PF_B5G6R5 depth/stencil support: D0S0 D16S0
23:21:05: FBO PF_R8G8B8 depth/stencil support: D0S0 D24S0 D32S0
23:21:05: FBO PF_B8G8R8 depth/stencil support: D0S0 D24S0 D32S0
23:21:05: FBO PF_A8R8G8B8 depth/stencil support: D0S0 D24S0 D32S0 D24S8
23:21:05: FBO PF_B8G8R8A8 depth/stencil support: D0S0 D24S0 D32S0 D24S8
23:21:06: FBO PF_A2R10G10B10 depth/stencil support: D0S0 D24S0 D32S0 D24S8
23:21:06: FBO PF_A2B10G10R10 depth/stencil support: D0S0 D24S0 D32S0 D24S8
23:21:06: FBO PF_FLOAT16_RGB depth/stencil support: D0S0 D24S0 D32S0
23:21:06: FBO PF_FLOAT16_RGBA depth/stencil support: D0S0 D24S0 D32S0
23:21:06: FBO PF_FLOAT32_RGB depth/stencil support: D0S0 D24S0 D32S0
23:21:06: FBO PF_FLOAT32_RGBA depth/stencil support: D0S0 D24S0 D32S0
23:21:06: FBO PF_X8R8G8B8 depth/stencil support: D0S0 D24S0 D32S0 D24S8
23:21:06: FBO PF_X8B8G8R8 depth/stencil support: D0S0 D24S0 D32S0 D24S8
23:21:06: FBO PF_SHORT_RGBA depth/stencil support: D0S0 D24S0 D32S0
23:21:06: FBO PF_R3G3B2 depth/stencil support: D0S0 D16S0
23:21:06: [GL] : Valid FBO targets PF_UNKNOWN PF_R5G6B5 PF_B5G6R5 PF_R8G8B8 PF_B8G8R8 PF_A8R8G8B8 PF_B8G8R8A8 PF_A2R10G10B10 PF_A2B10G10R10 PF_FLOAT16_RGB PF_FLOAT16_RGBA PF_FLOAT32_RGB PF_FLOAT32_RGBA PF_X8R8G8B8 PF_X8B8G8R8 PF_SHORT_RGBA PF_R3G3B2
23:21:06: RenderSystem capabilities
23:21:06: -------------------------
23:21:06:  * Hardware generation of mipmaps: yes
23:21:06:  * Texture blending: yes
23:21:06:  * Anisotropic texture filtering: yes
23:21:06:  * Dot product texture operation: yes
23:21:06:  * Cube mapping: yes
23:21:06:  * Hardware stencil buffer: yes
23:21:06:    - Stencil depth: 8
23:21:06:    - Two sided stencil support: yes
23:21:06:    - Wrap stencil values: yes
23:21:06:  * Hardware vertex / index buffers: yes
23:21:06:  * Vertex programs: yes
23:21:06:    - Max vertex program version: vp40
23:21:06:  * Fragment programs: yes
23:21:06:    - Max fragment program version: fp40
23:21:06:  * Texture Compression: yes
23:21:06:    - DXT: yes
23:21:06:    - VTC: yes
23:21:06:  * Scissor Rectangle: yes
23:21:06:  * Hardware Occlusion Query: yes
23:21:06:  * User clip planes: yes
23:21:06:  * VET_UBYTE4 vertex element type: yes
23:21:06:  * Infinite far plane projection: yes
23:21:06:  * Hardware render-to-texture: yes
23:21:06:  * Floating point textures: yes
23:21:06:  * Non-power-of-two textures: yes
23:21:06:  * Volume textures: yes
23:21:06:  * Multiple Render Targets: 4
23:21:06:  * Max Point Size: 63.375
23:21:06: Registering ResourceManager for type Texture
23:21:06: Particle Renderer Type 'billboard' registered
23:21:06: TerrainSceneManager: Registered a new PageSource for type Heightmap



I'm at a loss with this been fighting with it all night :? so any help, or pointers as where to look would be appreciated


I then changed my methodology entirely but now i get the singleton assert

Did a minor change in my methodology, now I get another error

my Class Header, notice I have added the default (empty) contructor as well as the two inline methods CreateGuiRenderer and CreateGuiSystem



Code: Select all

#ifndef __guihandler_h_
#define __guihandler_h_

#ifdef GUI_EXPORTS
#define GUI_API __declspec(dllexport)
#else
#define GUI_API __declspec(dllimport)
#endif

#include "ogre.h"

#include <OgreNoMemoryMacros.h>
#include <CEGUI/CEGUIImageset.h>
#include <CEGUI/CEGUISystem.h>
#include <CEGUI/CEGUILogger.h>
#include <CEGUI/CEGUISchemeManager.h>
#include <CEGUI/CEGUIWindowManager.h>
#include <CEGUI/CEGUIWindow.h>
#include <CEGUI/CEGUIFontManager.h>
#include "OgreCEGUIRenderer.h"
#include "OgreCEGUIResourceProvider.h"
//regular mem handler
#include <OgreMemoryMacros.h>

#include <vector>
#include "guipage.h"

namespace bdb{
  namespace gui{
    class GuiHandler{
      private:
         CEGUI::OgreCEGUIRenderer* mGUIRenderer;
         CEGUI::System* mGUISystem;
         CEGUI::WindowManager mRoot;
         CEGUI::Window* mWindow;

      public:
       
        std::vector<guiPageBase*>  mPageList;
        GuiHandler(Ogre::RenderWindow* window, Ogre::SceneManager* sceneMgr);
        GuiHandler();
        ~GuiHandler();   

        void Initialise();

        inline  CEGUI::OgreCEGUIRenderer* getGuiRenderer(){return mGUIRenderer;}
        inline  CEGUI::System*            getGuiSystem(){return mGUISystem;}
        inline  CEGUI::Window*            getGuiWindow(){return mWindow;}
        inline  CEGUI::WindowManager&     getGuiWindowManager(){return mRoot;}

        inline bool CreateGuiRenderer(Ogre::RenderWindow* window, Ogre::SceneManager* sceneMgr){
          return((mGUIRenderer = new CEGUI::OgreCEGUIRenderer(window, Ogre::RENDER_QUEUE_OVERLAY, false, 3000, sceneMgr)) != NULL);
        }
   
        inline bool CreateGuiSystem(){
          return ((mGUISystem = new CEGUI::System(mGUIRenderer)) != NULL);
        }

        CEGUI::Window* txCurrentX;
    };
  }
}
#endif


and the related cpp file

Code: Select all

#include "guiHandler.h"

bdb::gui::GuiHandler::GuiHandler(Ogre::RenderWindow* window, Ogre::SceneManager* sceneMgr):mGUIRenderer(0),mGUISystem(0){
   mGUIRenderer
      = new CEGUI::OgreCEGUIRenderer(window, Ogre::RENDER_QUEUE_OVERLAY, false, 3000, sceneMgr);
  mGUISystem
      = new CEGUI::System(mGUIRenderer);
   CEGUI::Logger::getSingleton().setLoggingLevel(CEGUI::Informative);
   CEGUI::SchemeManager::getSingleton().loadScheme((CEGUI::utf8*)"TaharezLook.scheme");
   mGUISystem->setDefaultMouseCursor((CEGUI::utf8*)"TaharezLook", (CEGUI::utf8*)"MouseArrow");
  mGUISystem->setDefaultFont((CEGUI::utf8*)"Tahoma-10");

   // set the mouse cursor initially in the middle of the screen
   mGUISystem->injectMousePosition((float)window->getWidth() / 2.0f, (float)window->getHeight() / 2.0f);
 
  mRoot = CEGUI::WindowManager::getSingleton();

  mWindow = mRoot.createWindow("DefaultWindow","CEGUIROOT");
  mGUISystem->setGUISheet(mWindow);
}

bdb::gui::GuiHandler::~GuiHandler(){
  delete mGUIRenderer;
  delete mGUISystem;
  delete mWindow;
}

bdb::gui::GuiHandler::GuiHandler():mGUIRenderer(0),mGUISystem(0){
}



In my main loop it is declared as thus

Code: Select all

bdb::gui::GuiHandler myGuiHandler;
/*More window init code*/
try{
      myGuiHandler.CreateGuiRenderer(window, sceneMgr);
    }
    catch(Ogre::Exception e){
    }


I now get this on startup

i:\BDB_NEW\game\debug\game.exe wrote:Assertion Failed: ms_Singleton, file e:\projects\ogrecvs\branches\dagon\cegui_mk2\include\ceguisingleton.h, line 66



My ogre logs timestamp is from about 30 mins ago as its not getting into my code...

Any Ideas?


OK so I'm pretty stumped and I don't want to write all my gui code in my main loop

Heres what I am using

VC++ 2005 express(was using prof uninstalled it & installed express in case it was a compiler issue)
MS's suggested PSDK
DX Sdk Dec 2005

this works if its put directly in main function however

Code: Select all

//Ok lets try show us a gui bits
 
   CEGUI::OgreCEGUIRenderer* mGUIRenderer
      = new CEGUI::OgreCEGUIRenderer(window, Ogre::RENDER_QUEUE_OVERLAY, false, 3000, sceneMgr);
  CEGUI::System *mGUISystem
      = new CEGUI::System(mGUIRenderer);
   CEGUI::Logger::getSingleton().setLoggingLevel(CEGUI::Informative);
   CEGUI::SchemeManager::getSingleton().loadScheme((CEGUI::utf8*)"TaharezLook.scheme");
   mGUISystem->setDefaultMouseCursor((CEGUI::utf8*)"TaharezLook", (CEGUI::utf8*)"MouseArrow");
  mGUISystem->setDefaultFont((CEGUI::utf8*)"Medusa12");
 
  CEGUI::WindowManager& mRoot = CEGUI::WindowManager::getSingleton();

  CEGUI::Window* mWindow = mRoot.createWindow("DefaultWindow","CEGUIROOT");
  mGUISystem->setGUISheet(mWindow);

  CEGUI::Window* txCurrentFPS = mRoot.createWindow("TaharezLook/StaticText", "StaticX");
  mWindow->addChildWindow(txCurrentFPS);
  txCurrentFPS->setPosition(CEGUI::Point(0.0, 0.1));
  txCurrentFPS->setSize(CEGUI::Size(1,0.05));
  txCurrentFPS->setAlpha(0.5);
   // set the mouse cursor initially in the middle of the screen
   mGUISystem->injectMousePosition((float)window->getWidth() / 2.0f, (float)window->getHeight() / 2.0f);
  txCurrentFPS->setText("");


heres the complete main function for the pure sake of it

The Header

Code: Select all

#ifndef __game_h_
#define __game_h_

#include "input.h"
#include "simulation.h"

#include "Ogre.h"
#include "OgreHardwarePixelBuffer.h"
#include "mudschool.h"
#include "guiHandler.h"
#include <OgreNoMemoryMacros.h>
#include <CEGUI/CEGUIImageset.h>
#include <CEGUI/CEGUISystem.h>
#include <CEGUI/CEGUILogger.h>
#include <CEGUI/CEGUISchemeManager.h>
#include <CEGUI/CEGUIWindowManager.h>
#include <CEGUI/CEGUIWindow.h>
#include <CEGUI/CEGUIFontManager.h>
#include "OgreCEGUIRenderer.h"
#include "OgreCEGUIResourceProvider.h"
//regular mem handler
#include <OgreMemoryMacros.h>
#endif


The CPP file

Code: Select all

#include "game.h"

#if defined(WIN32)
#define NOMINMAX
#include "windows.h"
 //int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
 int main(int argc, char **argv){
#else
int main (int argc, char *argv[]) {
#endif

  Ogre::Root *ogre;
   Ogre::RenderWindow *window;
   Ogre::SceneManager *sceneMgr;
   Ogre::Camera *camera;
  bdb::techdemo::MudSchool *m_myMudSchool;

  //bdb::gui::GuiHandler myGuiHandler;
 
 
  const Ogre::String szCurrFps = "  Current FPS : ";
  const Ogre::String szPosX = "  X : ";
  const Ogre::String szPosY = "  Y : ";
  const Ogre::String szPosZ = "  Z : ";
  const Ogre::String frameNum = "Current Frame: ";
  const Ogre::String szTri    = "  Num Tris : ";


  int iFrameCount = 0;
  m_myMudSchool = new bdb::techdemo::MudSchool(); 
 
   // fire up an Ogre rendering window. Clearing the first two (of three) params will let us
   // specify plugins and resources in code instead of via text file
   ogre = new Ogre::Root("", "");


   // This is a VERY minimal rendersystem loading example; we are hardcoding the OpenGL
   // renderer, instead of loading GL and D3D9. We will add renderer selection support in a
   // future article.

   // I separate the debug and release versions of my plugins using the same "_d" suffix that
   // the Ogre main libraries use; you may need to remove the "_d" in your code, depending on the
   // naming convention you use
   ogre->loadPlugin("RenderSystem_GL");
   Ogre::RenderSystemList *renderSystems = NULL;
   Ogre::RenderSystemList::iterator r_it;

   // we do this step just to get an iterator that we can use with setRenderSystem. In a future article
   // we actually will iterate the list to display which renderers are available.
   renderSystems = ogre->getAvailableRenderers();
   r_it = renderSystems->begin();
   ogre->setRenderSystem(*r_it);
   ogre->initialise(false);

   // load common plugins
   ogre->loadPlugin("Plugin_CgProgramManager");      
   ogre->loadPlugin("Plugin_OctreeSceneManager");

   // load the basic resource location(s)

   Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
      "resource", "FileSystem", "General");
  Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
      "resource/mudschool", "FileSystem", "MudSchool");
  Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
      "resource/mudschool/Media", "FileSystem", "MudSchoolMedia");
  Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
      "resource/mudschool/Models", "FileSystem", "MudSchoolModels");
  Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
      "resource/mudschool/textures", "FileSystem", "MudSchoolTex");
  Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
      "resource/gui", "FileSystem", "Gui");
  Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
      "resource/gui/Overlays", "FileSystem", "GuiOverlays");
  Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
      "resource/gui/fonts", "FileSystem", "Fonts");
  Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
      "resource/scripts/gfx/programs", "FileSystem", "Programs");
  Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
      "resource/scripts/gfx/shaders", "FileSystem", "Shaders");

   Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("General");
   Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("MudSchool");
  Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("MudSchoolMedia");
  Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("MudSchoolModels");
  Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("MudSchoolTex");
  Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("Gui");
  Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("GuiOverlays");
  Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("Fonts");
  Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("Programs");
  Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("Shaders");

  //Set Up Texture Filtering
  Ogre::MaterialManager::getSingleton().setDefaultTextureFiltering(Ogre::TFO_TRILINEAR);
  Ogre::MaterialManager::getSingleton().setDefaultAnisotropy(1);

   // setup main window; hardcode some defaults for the sake of presentation
   Ogre::NameValuePairList opts;
   opts.insert(Ogre::NameValuePairList::value_type("resolution", "1024x768"));
   opts.insert(Ogre::NameValuePairList::value_type("fullscreen", "true"));
   opts.insert(Ogre::NameValuePairList::value_type("vsync", "true"));

   // create a rendering window with the title "BDB"
  window = ogre->createRenderWindow("BDB TechDemo::Mudschool Island", 1024, 768, false, &opts);
 
  //Create our scene manager
  sceneMgr = ogre->createSceneManager(Ogre::ST_EXTERIOR_CLOSE, "DefaultScene");
 
  camera = sceneMgr->createCamera("camera");
   camera->setNearClipDistance(1);
  camera->setRenderingDistance(1000);
  camera->setFarClipDistance(1000);
   Ogre::Viewport* vp = window->addViewport(camera);
   

   // most examples get the viewport size to calculate this; for now, we'll just
   // set it to 4:3 the easy way
   camera->setAspectRatio((Ogre::Real)1.333333);

 
 
  //Seems that its not working so I'm gonna do it manually

  //Our Main Light
  Ogre::Light* light = sceneMgr->createLight("MainLight");
  light->setCastShadows(true);
  light->setPosition(500,100,500);
 
  //Fog
  Ogre::ColourValue fadeColour(0.53, 0.68, 0.98);
  sceneMgr->setFog( Ogre::FOG_LINEAR, fadeColour, .0001, 1000, 2500);
  window->getViewport(0)->setBackgroundColour(fadeColour);

  //Sky
  Ogre::Plane skyPlane;
  skyPlane.d = 2000;
  skyPlane.normal = -Ogre::Vector3::UNIT_Y;
  sceneMgr->setSkyPlane(true, skyPlane, "mudschool/skyplane",1500,10,true, 0.5, 150, 10);
  //sceneMgr->setSkyPlane(true, skyPlane, "mudschool/skyplane",1000, 100, false, 0.5,150,150);
  //sceneMgr->setSkyDome(true, "mudschool/skyplane");
  //Water
  Ogre::Plane waterPlane;
  waterPlane.d = -40;
  waterPlane.normal = Ogre::Vector3::UNIT_Y;
  Ogre::MeshManager::getSingleton().createPlane(
    "OceanPlane",
    Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
    waterPlane,
    10240,
    10240,
    100,
    100,
    true,
    1,100,100,Ogre::Vector3::UNIT_Z);
   
  Ogre::Entity* OceanSurfaceEnity;
  OceanSurfaceEnity = sceneMgr->createEntity( "OceanPlane", "OceanPlane" );
  OceanSurfaceEnity->setMaterialName("mudschool/water01");
  sceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(OceanSurfaceEnity);
  //Shunt the plane to the same size as the scene as its drawn around the origin whereas a terrain
  //scene is positive X & Z from the origin
  //With the translation it seems to be Y relative to the initial position of the plane
 
  sceneMgr->getRootSceneNode()->getChild(0)->translate(2560,20,2560);
 
  //fake an ocean floor
  Ogre::Plane oceanFloorPlane;
  oceanFloorPlane.d = 1;
  oceanFloorPlane.normal = Ogre::Vector3::UNIT_Y;
  Ogre::MeshManager::getSingleton().createPlane(
    "oceanFloorPlane",
    Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
    oceanFloorPlane,
    10240,
    10240,
    100,
    100,
    true,
    1,100,100,Ogre::Vector3::UNIT_Z);
 

  //Add us a ship ;)

  //Ogre::MeshPtr ShipMesh = Ogre::MeshManager::getSingleton().load("sailingboat.mesh", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
 
 
  /*Ogre::Entity* ShipEntity =  sceneMgr->createEntity("SailingShip", "sailingboat.mesh");
  ShipEntity->setMaterialName("mudschool/billboard");
  Ogre::SceneNode* headNode = sceneMgr->getRootSceneNode()->createChildSceneNode();
  headNode->attachObject(ShipEntity);
   //headNode->setScale(0.01,0.01,0.01);
   headNode->setPosition(4733,45,500);
  headNode->setPolygonModeOverrideable(true);
   ShipEntity->setCastShadows(true);
  ShipEntity->setVisible(true);*/
 
  Ogre::Entity* oceanFloorEnity;
  oceanFloorEnity = sceneMgr->createEntity( "oceanFloorPlane", "oceanFloorPlane" );
  oceanFloorEnity->setMaterialName("mudschool/oceanfloor");
  sceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(oceanFloorEnity);
  sceneMgr->getRootSceneNode()->getChild(1)->translate(2560,0,2560);
 
  //mBillBoard = new Ogre::Billboard();
  camera->setCastShadows(true);
 /* mBillboardNode = sceneMgr->getRootSceneNode()->createChildSceneNode();
  mBillboardSet = sceneMgr->createBillboardSet("testForRTT");
  mBillboardSet->setMaterialName("mudschool/billboard");
  mBillBoard = mBillboardSet->createBillboard(Ogre::Vector3(Ogre::Real(3458),Ogre::Real(0), Ogre::Real(0)));
  mBillBoard->setDimensions(Ogre::Real(2048),Ogre::Real(2048));
  mBillboardSet->setRenderQueueGroup(Ogre::RENDER_QUEUE_1);
 
 
  mBillboardNode->attachObject(mBillboardSet);*/
  sceneMgr->setWorldGeometry("mudschool.cfg");
  if(ogre->getRenderSystem()->getCapabilities()->hasCapability(Ogre::RSC_INFINITE_FAR_PLANE)){
    camera->setFarClipDistance(0);
  }
  ogre->setFrameSmoothingPeriod(Ogre::Real(1));
  camera->setPosition(Ogre::Real(4901),Ogre::Real(100),Ogre::Real(2612)); 
  camera->lookAt(Ogre::Real(5410),Ogre::Real(100),Ogre::Real(1224)); 
  m_myMudSchool->SetUpQuery(sceneMgr, camera);
 
 
   // this next bit is for the sake of the input handler
   size_t windowHandle;
#if defined OIS_WIN32_PLATFORM
   window->getCustomAttribute("HWND", &windowHandle);
#elif defined OIS_LINUX_PLATFORM
   window->getCustomAttribute("GLXWINDOW", &windowHandle);
#endif

 
   // set up the input handlers
   Simulation *sim = new Simulation();
  bdb::input::InputHandler::getSingleton().Initialise(sim, windowHandle);
  sim->requestStateChange(SIMULATION);
 
  //Ok lets try show us a gui bits
 
   CEGUI::OgreCEGUIRenderer* mGUIRenderer
      = new CEGUI::OgreCEGUIRenderer(window, Ogre::RENDER_QUEUE_OVERLAY, false, 3000, sceneMgr);
  CEGUI::System *mGUISystem
      = new CEGUI::System(mGUIRenderer);
   CEGUI::Logger::getSingleton().setLoggingLevel(CEGUI::Informative);
   CEGUI::SchemeManager::getSingleton().loadScheme((CEGUI::utf8*)"TaharezLook.scheme");
   mGUISystem->setDefaultMouseCursor((CEGUI::utf8*)"TaharezLook", (CEGUI::utf8*)"MouseArrow");
  mGUISystem->setDefaultFont((CEGUI::utf8*)"Medusa12");
 
  CEGUI::WindowManager& mRoot = CEGUI::WindowManager::getSingleton();

  CEGUI::Window* mWindow = mRoot.createWindow("DefaultWindow","CEGUIROOT");
  mGUISystem->setGUISheet(mWindow);

  CEGUI::Window* txCurrentFPS = mRoot.createWindow("TaharezLook/StaticText", "StaticX");
  mWindow->addChildWindow(txCurrentFPS);
  txCurrentFPS->setPosition(CEGUI::Point(0.0, 0.1));
  txCurrentFPS->setSize(CEGUI::Size(1,0.05));
  txCurrentFPS->setAlpha(0.5);
   // set the mouse cursor initially in the middle of the screen
   mGUISystem->injectMousePosition((float)window->getWidth() / 2.0f, (float)window->getHeight() / 2.0f);
  txCurrentFPS->setText("");
 
  /*myOverlay = Ogre::OverlayManager::getSingleton().getByName("BDBGUI/GamePanel");
  myOverlay->show();*/

  // Create a panel
  Ogre::OverlayContainer* panel = static_cast<Ogre::OverlayContainer*>(
    Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "PanelName"));
  panel->setMetricsMode(Ogre::GMM_PIXELS);
  panel->setPosition(0, 0);
  panel->setDimensions(1024, 768);
  panel->setMaterialName("BDBUI/gameOverlay1024"); // Optional background material
  // Create an overlay, and add the panel
  Ogre::Overlay* overlay = Ogre::OverlayManager::getSingleton().create("OverlayName");
  overlay->add2D(panel);

  // Show the overlay
  overlay->show();
  while (sim->getCurrentState() != SHUTDOWN) {
    
    Ogre::RenderTarget::FrameStats Stats = window->getStatistics();
    iFrameCount++;
       
    txCurrentFPS->setText(
      frameNum    +   Ogre::StringConverter::toString(iFrameCount) +
      szCurrFps   +   Ogre::StringConverter::toString(Stats.lastFPS).c_str() +
      szPosX      +   Ogre::StringConverter::toString(camera->getPosition().x) +
      szPosY      +   Ogre::StringConverter::toString(camera->getPosition().y) +
      szPosZ      +   Ogre::StringConverter::toString(camera->getPosition().z) +
      szTri       +   Ogre::StringConverter::toString(Stats.triangleCount));
    
    bdb::input::InputHandler::getSingleton().capture();
    //we move
    m_myMudSchool->TranslateCamera(camera, sim->getCurrentState());
   
#if defined (WIN32)
      {
         MSG msg;
         while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
        if (msg.message == WM_QUIT){
                sim->requestStateChange(SHUTDOWN);
        }
       
             else {
                TranslateMessage(&msg);
                DispatchMessage(&msg);
             }
         }
      }
#endif
    ogre->renderOneFrame();
   }

   
 
   delete sim;
  delete ogre;

   return 0;
}


Please ignore the commented out bits as I have been noodling a bit and unless I'm being severly retarded it does pretty much what I was doing in my class. Any help on this dooesy would really be appreciated.

Pretty impressive first post :?

Thanks

n1g

d3th n1gG4
Just popping in
Just popping in
Posts: 2
Joined: Thu Apr 06, 2006 21:13
Contact:

Postby d3th n1gG4 » Mon Apr 10, 2006 17:24

After that long and winding post I have tried to create the bearest of gui classes

here is my class in full, i haven't bothered with preprocessor guards or anything like that, shoot me if you must

Code: Select all

#include <OgreNoMemoryMacros.h>
#include <CEGUI/CEGUIImageset.h>
#include <CEGUI/CEGUISystem.h>
#include <CEGUI/CEGUILogger.h>
#include <CEGUI/CEGUISchemeManager.h>
#include <CEGUI/CEGUIWindowManager.h>
#include <CEGUI/CEGUIWindow.h>
#include <CEGUI/CEGUIFontManager.h>
#include "OgreCEGUIRenderer.h"
#include "OgreCEGUIResourceProvider.h"

//regular mem handler
#include <OgreMemoryMacros.h>


class GuiHandler{
  private:
     CEGUI::OgreCEGUIRenderer* mGUIRenderer;
     CEGUI::System* mGUISystem;
     CEGUI::WindowManager mRoot;
     CEGUI::Window* mWindow;

  public:
       
    GuiHandler(Ogre::RenderWindow* window, Ogre::SceneManager* sceneMgr);
     ~GuiHandler(){}   

    void Initialise(){}

    inline  CEGUI::OgreCEGUIRenderer* getGuiRenderer(){return mGUIRenderer;}
    inline  CEGUI::System*            getGuiSystem(){return mGUISystem;}
    inline  CEGUI::Window*            getGuiWindow(){return mWindow;}
    inline  CEGUI::WindowManager&     getGuiWindowManager(){return mRoot;}

    inline bool CreateGuiRenderer(Ogre::RenderWindow* window, Ogre::SceneManager* sceneMgr){
      return((mGUIRenderer = new CEGUI::OgreCEGUIRenderer(window, Ogre::RENDER_QUEUE_OVERLAY, false, 3000, sceneMgr)) != NULL);
    }

    inline bool CreateGuiSystem(){
      return ((mGUISystem = new CEGUI::System(mGUIRenderer)) != NULL);
    }

     CEGUI::Window* txCurrentX;
};

GuiHandler::GuiHandler(Ogre::RenderWindow* window, Ogre::SceneManager* sceneMgr){
   mGUIRenderer
      = new CEGUI::OgreCEGUIRenderer(window, Ogre::RENDER_QUEUE_OVERLAY, false, 3000, sceneMgr);
  mGUISystem
      = new CEGUI::System(mGUIRenderer);
   CEGUI::Logger::getSingleton().setLoggingLevel(CEGUI::Informative);
   CEGUI::SchemeManager::getSingleton().loadScheme((CEGUI::utf8*)"TaharezLook.scheme");
   mGUISystem->setDefaultMouseCursor((CEGUI::utf8*)"TaharezLook", (CEGUI::utf8*)"MouseArrow");
  mGUISystem->setDefaultFont((CEGUI::utf8*)"Tahoma-10");

   // set the mouse cursor initially in the middle of the screen
   mGUISystem->injectMousePosition((float)window->getWidth() / 2.0f, (float)window->getHeight() / 2.0f);
 
  mRoot = CEGUI::WindowManager::getSingleton();

  mWindow = mRoot.createWindow("DefaultWindow","CEGUIROOT");
  mGUISystem->setGUISheet(mWindow);
}


And here is my executing code

Code: Select all

#include "Ogre.h"

#include "ceguiclass.h"
#if defined(WIN32)
#define NOMINMAX
#endif


int main(int argc, char** argv){
   
  Ogre::Root *ogre;
   Ogre::RenderWindow *window;
   Ogre::SceneManager *sceneMgr;
   Ogre::Camera *camera;

  ogre = new Ogre::Root("", "");
   ogre->loadPlugin("RenderSystem_GL");
   Ogre::RenderSystemList *renderSystems = NULL;
   Ogre::RenderSystemList::iterator r_it;

   renderSystems = ogre->getAvailableRenderers();
   r_it = renderSystems->begin();
   ogre->setRenderSystem(*r_it);
   ogre->initialise(false);

   ogre->loadPlugin("Plugin_CgProgramManager");      
   ogre->loadPlugin("Plugin_OctreeSceneManager");

  Ogre::ResourceGroupManager::getSingleton().addResourceLocation("resource/gui", "FileSystem", "Gui");
  Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("Gui");

  Ogre::NameValuePairList opts;
   opts.insert(Ogre::NameValuePairList::value_type("resolution", "800x600"));
   opts.insert(Ogre::NameValuePairList::value_type("fullscreen", "false"));
   opts.insert(Ogre::NameValuePairList::value_type("vsync", "true"));

  window = ogre->createRenderWindow("BDB::GuiTest", 800, 600, false, &opts);
  sceneMgr = ogre->createSceneManager(Ogre::ST_GENERIC, "DefaultScene");
  camera = sceneMgr->createCamera("camera");
   camera->setNearClipDistance(1);
  camera->setRenderingDistance(1000);
  camera->setFarClipDistance(1000);
   Ogre::Viewport* vp = window->addViewport(camera);
   camera->setAspectRatio((Ogre::Real)1.333333);

  GuiHandler* mGui = new GuiHandler(window, sceneMgr);
  while(true){
    //Just loop we just want this gui uo
  }
  //Create a window
  return 0;
}


at this line

Code: Select all

 GuiHandler* mGui = new GuiHandler(window, sceneMgr);


i get this error

---------------------------
Microsoft Visual C++ Debug Library
---------------------------
Debug Error!

Program: i:\BDB_NEW\game\debug\GuiTest.exe


Code: Select all

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.



(Press Retry to debug the application)
---------------------------
Abort   Retry   Ignore   
---------------------------


and my output window gives me this

Code: Select all


Assertion Failed: ms_Singleton, file e:\projects\ogrecvs\branches\dagon\cegui_mk2\include\ceguisingleton.h, line 66



Can somebody please explain...


Return to “Help”

Who is online

Users browsing this forum: No registered users and 24 guests