2011-02-01 51 views
2

我正在使用Ogre3D編寫遊戲,並且遇到問題。Ogre3D顯示段錯誤

當我啓動程序,它顯示了一個段錯誤錯誤:

*-*-* OGRE Initialising                                                               
*-*-* Version 1.7.2 (Cthugha)                                                             
Creating resource group Essential                                                            
Added resource location '../media/packs/SdkTrays.zip' of type 'Zip' to resource group 'Essential' 
Added resource location '../media' of type 'FileSystem' to resource group 'General' 
Added resource location '../media/materials/scripts' of type 'FileSystem' to resource group 'General' 
Added resource location '../media/materials/textures' of type 'FileSystem' to resource group 'General' 
Added resource location '../media/models' of type 'FileSystem' to resource group 'General' 
Naruszenie ochrony pamięci [This means segfault] 

而且我不知道,爲什麼...

代碼:

#define OGRE_CHANGE1 ((1 << 16) | (1 << 8)) 

#include "Ogre.h" 
#include "ExampleApplication.h" 

#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 
#define WIN32_LEAN_AND_MEAN 
#include "windows.h" 
#else 
#include <iostream> 
#endif 

class MyApp : public ExampleApplication 
{ 
    protected: 
    public: 
    MyApp() 
    { 
    } 

    ~MyApp() 
    { 
    } 
    protected: 
    void createScene(void) 
    { 
    } 
}; 

#ifdef __cplusplus 
extern "C" { 
#endif 

#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 
INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT) 
#else 
int main(int argc, char **argv) 
#endif 
{ 
    MyApp App; 
    try 
    { 
    App.go(); 
    return 0; 
    } 
    catch (Ogre::Exception& e) 
    { 
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 
    MessageBox(NULL, e.getFullDescription().c_str(), "Exception!", 
      MB_OK | MB_ICONERROR | MB_TASKMODAL); 
#else 
    std::cerr <<"Exception:\n"; 
    std::cerr <<e.getFullDescription().c_str() <<"\n"; 
#endif 
    return 1; 
    } 
} 

#ifdef __cplusplus 
} 
#endif 

(代碼部分來自食人魔維基)

resources.cfg

# Resources required by the sample browser and most samples. 
[Essential] 
Zip=../media/packs/SdkTrays.zip 

# Resource locations to be added to the default path 
[General] 
FileSystem=../media 
FileSystem=../media/materials/scripts 
FileSystem=../media/materials/textures 
FileSystem=../media/models 

plugins.cfg

# Defines plugins to load 

# Define plugin folder 
PluginFolder=/usr/lib/OGRE 

# Define plugins 
# Plugin=RenderSystem_Direct3D9 
# Plugin=RenderSystem_Direct3D10 
# Plugin=RenderSystem_Direct3D11 
Plugin=RenderSystem_GL 
# Plugin=RenderSystem_GLES 
Plugin=Plugin_ParticleFX 
Plugin=Plugin_BSPSceneManager 
Plugin=Plugin_CgProgramManager 
Plugin=Plugin_PCZSceneManager 
Plugin=Plugin_OctreeZone 
Plugin=Plugin_OctreeSceneManager 

而且 - 當我在plugins.cfg評論Plugin=Plugin_CgProgramManager ...程序的工作原理,但我需要這個插件。 :)

請幫忙。
在此先感謝。

+1

除非您向我們展示代碼,否則沒有人能提供幫助。 – Asha 2011-02-01 08:08:51

回答

2
  1. 編譯包含調試信息的程序(使用GCC,這意味着確保將-g選項傳遞給編譯器)。
  2. 在調試器中運行它。
  3. 當它崩潰時,你會得到一個堆棧跟蹤。
  4. 調查它是否依賴於你做過的事情(或者沒做過,比如缺少初始化),或者看起來像是Ogre3D本身的崩潰。
    1. 如果是前者,修復它。
    2. 如果是後者,請舉報。