Ogre Version: ogre-14.2.6
Operating System: Windows 10
Render System: not selected yet.
I have struggling with Ogre Initailization issue.
I have tried with Current Stable Release: v14.2.6 – 2. June 2024 and my custom build with CMake.
When I tried to build with the below sample code. (Mostly I follow the tutorial of https://ogrecave.github.io/ogre/api/latest/setup.html)
Code: Select all
#include <Ogre.h>
#include <OgreApplicationContext.h>
#include <iostream>
int main(int argc, char** argv) {
OgreBites::ApplicationContext ctx("OgreTutorialApp");
ctx.initApp();
Ogre::Root* root = ctx.getRoot();
Ogre::RenderWindow* window = ctx.getRenderWindow();
Ogre::SceneManager* sceneMgr = root->createSceneManager();
Ogre::RTShader::ShaderGenerator* shadergen = Ogre::RTShader::ShaderGenerator::getSingletonPtr();
shadergen->addSceneManager(sceneMgr);
Ogre::Light* light = sceneMgr->createLight("MainLight");
Ogre::SceneNode* lightNode = sceneMgr->getRootSceneNode()->createChildSceneNode();
lightNode->setPosition(0, 10, 15);
lightNode->attachObject(light);
Ogre::SceneNode* camNode = sceneMgr->getRootSceneNode()->createChildSceneNode();
camNode->setPosition(0, 0, 15);
camNode->lookAt(Ogre::Vector3(0, 0, -1), Ogre::Node::TS_PARENT);
Ogre::Camera* cam = sceneMgr->createCamera("myCam");
cam->setNearClipDistance(5);
cam->setAutoAspectRatio(true);
camNode->attachObject(cam);
window->addViewport(cam);
Ogre::Entity* ent = sceneMgr->createEntity("Sinbad.mesh");
Ogre::SceneNode* node = sceneMgr->getRootSceneNode()->createChildSceneNode();
node->attachObject(ent);
try {
root->startRendering();
}
catch (const Ogre::Exception& e) {
std::cerr << "An exception has occurred: " << e.getFullDescription().c_str() << std::endl;
}
ctx.closeApp();
return 0;
}
When I run ths code, Unhanlded exception occurs at this line.
OgreBites::ApplicationContext ctx("OgreTutorialApp");
Exception thrown at 0x00007FFC0FC8B699 in OgreTest.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x000000D4800FEEC0.
Unhandled exception at 0x00007FFC0FC8B699 in OgreTest.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x000000D4800FEEC0.
It seems to be related to Ogre::String Encoding issue.
In OgreApplicationContextBase.cpp, when it is initialized, the appName is delivered as
- appName "0\x1d¥\xe\x1" const std::string &
- mAppName is emptry.
Code: Select all
ApplicationContextBase::ApplicationContextBase(const Ogre::String& appName)
{
mAppName = appName;
mFSLayer = new Ogre::FileSystemLayer(mAppName);
if (char* val = getenv("OGRE_CONFIG_DIR"))
{
Ogre::String configDir = Ogre::StringUtil::standardisePath(val);
mFSLayer->setConfigPaths({ configDir });
}
mRoot = NULL;
mOverlaySystem = NULL;
mFirstRun = true;
#ifdef OGRE_BUILD_COMPONENT_RTSHADERSYSTEM
mMaterialMgrListener = NULL;
mShaderGenerator = NULL;
#endif
}
Are there any points I should be aware of, or settings needed when building the library or configuring the project related to this issue?