Wrecked Games

Please login or register.

Login with username, password and session length
Advanced search  

News:

We're just that awesome.

Author Topic: Problem while integrating OIS  (Read 781 times)

fest

  • Guest
Problem while integrating OIS
« on: December 23, 2005, 03:33:27 AM »

Hello all.
I'm trying to integrate OIS in my game.
The game is using OGRE.
I'm on windows xp and i use VC++2005 express and OIS from CVS (downloaded that about week and a half ago)
I'm having a strange crash only in release mode. Everything works fine in debug mode. On IRC pjcast told me about unintialised pointer, but I can't figure out which is that unintialised pointer.
Before trying to integrate OIS, my app  was working fine in both modes.
But now it's crashing. I am sure something with my code is wrong because demos compile and run fine ( at least Console demo).
My class 'Application' has protected members:
Code: [Select]

OIS::Mouse *g_m;
OIS::Keyboard *g_kb;

Then I have a function: Application::StartOIS() where I'm intializing OIS:
Code: [Select]
void Application::StartOIS()
{
HWND hwnd=NULL;
EventHandler handler;
mWindow->getCustomAttribute("HWND", &hwnd);
g_kb=0;
g_m=0;
OIS::ParamList pl;
std::stringstream wnd;
wnd << (size_t)hwnd;
Application::Instance().AddToLog(wnd.str());
pl.insert(std::make_pair( std::string("WINDOW"), wnd.str() ));
pl.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_FOREGROUND" )));
pl.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_NONEXCLUSIVE")));
OIS::InputManager &im = *OIS::InputManager::createInputSystem(pl);
Application::Instance().AddToLog("Input system: "+im.inputSystemName());
g_kb = (OIS::Keyboard*)im.createInputObject( OIS::OISKeyboard, true );
g_kb->setEventCallback(&handler);
g_m = (OIS::Mouse*)im.createInputObject( OIS::OISMouse, true );
g_m->setEventCallback( &handler );
Application::Instance().AddToLog("OIS started");
}


When I set Basic Runtime Checks to Both, i get this error:
Quote

Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call.  This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.

at this line: g_kb = (OIS::Keyboard*)im.createInputObject( OIS::OISKeyboard, true )
;
Class EventHandler is defined as follows: class EventHandler: public OIS::KeyListener, public OIS::MouseListener
I can't find any error, but it crashes.
I even tried to
Code: [Select]

try
{

StartOIS();


} catch( const OIS::Exception &ex )
{

 MessageBox( NULL, ex.eText, "An exception has occured!", MB_OK |
MB_ICONERROR | MB_TASKMODAL);
}

in my Application::Run() method, but it still crashes. I turned all compiler optimizations off.
Logged