我遇到了食人魔的问题。当我启动渲染器(OpenGL或DirectX)时,我收到错误:
Debug Assertion Failed! C: \ windows \ system32 \ msvcp110d.dll File:
C: \ Program Files (x86) \ Microsoft Visual Studio 11.0 \ VC \ include
\ xtree <- (i dont have anything in this path) Line: 237
Expression: map / set iterator not deferencable
以下是代码:
#include "OGRE\Ogre.h"
#include "OGRE\OgreException.h"
#include "OGRE\OgreRoot.h"
#include "OIS\OIS.h"
Ogre::Root* root;
Ogre::RenderWindow* window;
Ogre::SceneManager* sceneManager;
Ogre::Viewport* viewport;
Ogre::Camera* camera;
Ogre::SceneNode* cameraNode;
OIS::Keyboard* keyboard;
OIS::Mouse* mouse;
OIS::InputManager* im;
bool running = true;
void handlekeyboard()
{
keyboard->capture();
if (keyboard->isKeyDown(OIS::KC_ESCAPE)) running = false;
}
void handlemouse()
{
mouse->capture();
const OIS::MouseState& mouseState = mouse->getMouseState();
}
int main()
{
try{
root = new Ogre::Root("plugins_d.cfg");
if(!root->showConfigDialog()) return 0;
window = root->initialise(true);
sceneManager = root->createSceneManager(Ogre::ST_GENERIC);
camera = sceneManager->createCamera("maincamera");
camera->setNearClipDistance(5);
camera->setFarClipDistance(100);
cameraNode = sceneManager->getRootSceneNode()->createChildSceneNode();
cameraNode->attachObject(camera);
viewport = window->addViewport(camera);
viewport->setClearEveryFrame(true);
size_t windowHnd = 0;
window->getCustomAttribute("window", &windowHnd);
std::string windowhandleassstring ="";
std::ostringstream windowHndstr;
windowHndstr << windowHnd;
windowhandleassstring = windowHndstr.str();
OIS::ParamList LSpecialParameters;
LSpecialParameters.insert(std::make_pair(std::string("window"),windowhandleassstring));
im = OIS::InputManager::createInputSystem(LSpecialParameters);
keyboard = static_cast<OIS::Keyboard*>(im->createInputObject(OIS::OISKeyboard, false));
mouse = static_cast<OIS::Mouse*>(im->createInputObject(OIS::OISMouse, false));
while(window->isClosed() == false && running == true)
{
handlekeyboard();
handlemouse();
root->renderOneFrame();
Ogre::WindowEventUtilities::messagePump();
}
}catch(Ogre::Exception &ex)
{
std::cout << "error"<< ex.getDescription() << std::endl;
}
delete root;
delete window;
delete sceneManager;
delete camera;
delete cameraNode;
delete viewport;
delete keyboard;
delete mouse;
return 0;
}