Wrecked Games

Please login or register.

Login with username, password and session length
Advanced search  

News:

We're just that awesome.

Pages: [1] 2

Author Topic: Exception on InputMgr Creation  (Read 3277 times)

Penguin

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 12
    • View Profile
Exception on InputMgr Creation
« on: March 17, 2008, 06:00:28 AM »

I copied and modified the OIS code from an Ogre3D sample. It compiles correctly but when I try to run it, it hits an exception. Did I copy it correctly?
Code: [Select]
An unhandled exception of type 'System.Runtime.InteropServices.SEHException' occurred in Singleplayer.exe

Additional information: External component has thrown an exception.
My code:
Code: [Select]
#ifdef _DEBUG
Ogre::LogManager::getSingletonPtr()->logMessage("Initializing Input System");
#endif
OIS::ParamList pl;
size_t windowHnd = 0;
std::ostringstream windowHndStr;
//OIS::InputManager mgr;

mWindow->getCustomAttribute("WINDOW", &windowHnd);
windowHndStr << windowHnd;
pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));

mInputManager = OIS::InputManager::createInputSystem( pl );

mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject( OIS::OISKeyboard, true ));
mKeyboard->setEventCallback(this);

mMouse = static_cast<OIS::Mouse*>(mInputManager->createInputObject( OIS::OISMouse, true ));
mMouse->setEventCallback(this);
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +1/-0
  • Posts: 2661
    • View Profile
    • http://www.wreckedgames.com
Re: Exception on InputMgr Creation
« Reply #1 on: March 17, 2008, 06:24:10 AM »

First, you should catch/handle the OIS::Exception message so you can see what error you are dealing with. Also, what version of Ogre are you using?
Logged

Penguin

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 12
    • View Profile
Re: Exception on InputMgr Creation
« Reply #2 on: March 17, 2008, 02:35:05 PM »

OK I'm very new to c++ (not to programming though) so I think I used the correct code:
Code: [Select]
try
{
mInputManager = OIS::InputManager::createInputSystem( pl );
}
catch( OIS::Exception str)
{
str.eType; // I put a breakpoint here
}

I then checked the value for str.
Code: [Select]
eFile = 0x001F3D8C "..\src\win32\Win32InputManager.cpp"
eLine = 71
eText = 0x001F3DB0 "Win32InputManager::Win32InputManager >> The sent HWND is not valid!"
eType = 8
Now that I know what exception is I'll *try* to figure it out.
EDIT: It appears that windowHnd is equal to 0. Now to figure out why.
« Last Edit: March 17, 2008, 03:00:52 PM by Penguin »
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +1/-0
  • Posts: 2661
    • View Profile
    • http://www.wreckedgames.com
Re: Exception on InputMgr Creation
« Reply #3 on: March 17, 2008, 05:57:04 PM »

If you are using a very old version of Ogre, you need to pass "HWND" instead of "WINDOW". Else, if you are using recent version, make sure you have created Ogre & Render Window before trying to get the Window Handle from Ogre.

HTH
Logged

Penguin

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 12
    • View Profile
Re: Exception on InputMgr Creation
« Reply #4 on: March 18, 2008, 03:54:12 AM »

I'm using the latest CVS version of Ogre. I'm creating the window kind of funnily so I'll look at that. Thanks for your help.
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +1/-0
  • Posts: 2661
    • View Profile
    • http://www.wreckedgames.com
Re: Exception on InputMgr Creation
« Reply #5 on: March 18, 2008, 06:28:43 AM »

Also note, you have to pass in a top level window, not a child window.
Logged

Penguin

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 12
    • View Profile
Re: Exception on InputMgr Creation
« Reply #6 on: April 17, 2008, 08:26:44 AM »

Now I'm hitting errors on trying to create a mouse input object. It didn't create the input manager correctly. Also I only created one window.
mInputManager = 0x0188C808
mMouse = 0x005B7558 { mState={...} listener=0x00000000 }
str = {
     eFile = 0x00000000
     eLine = -142189635
     eText = 0x003AE918 "OW"
     str.eType = 2045217990
}
(str is the exception) For now I'm not sure what else to add.
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +1/-0
  • Posts: 2661
    • View Profile
    • http://www.wreckedgames.com
Re: Exception on InputMgr Creation
« Reply #7 on: April 17, 2008, 01:11:18 PM »

No idea what that exception, as OIS does not throw crazy OW strings. Can you try running through the debugger to find out what is happening inside OIS during Mouse creation?
Logged

Penguin

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 12
    • View Profile
Re: Exception on InputMgr Creation
« Reply #8 on: April 19, 2008, 01:56:48 PM »

I made a breakpoint at the Mouse Object line, but as soon as I tried to step into it, it hit an exception. I think it's because of the input manager not getting created properly and then it tries to create a mouse object using a non existent object.
Code: [Select]
An unhandled exception of type 'System.AccessViolationException' occurred in Reinforcement 1942.exe

Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

My code:
Code: [Select]
void SharedOgreResources::startInputSystem(void)
{
OIS::ParamList pl;
size_t windowHnd = 0;
std::ostringstream windowHndStr;
//OIS::InputManager mgr;

mWindow->getCustomAttribute("WINDOW", &windowHnd);
windowHndStr << windowHnd;
pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));

try
{
mInputManager = OIS::InputManager::createInputSystem(pl);
}
catch( OIS::Exception str)
{
str.eType;
}

//Create a simple keyboard
mMouse = static_cast<OIS::Mouse*>(mInputManager->createInputObject(OIS::OISMouse, false));
mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject(OIS::OISKeyboard, false));

unsigned int width, height, depth;
int top, left;
mWindow->getMetrics(width, height, depth, left, top);
const OIS::MouseState &ms = mMouse->getMouseState();
ms.width = width;
ms.height = height;

Ogre::LogManager::getSingletonPtr()->logMessage("Input System Created");
}
EDIT: I put a breakpoint at the line "return im;" in the createInputSystem function and the variable "im" does seem to be valid. Now that I'm really looking at this, its not actually hitting an exception in the "createInputSystem()" function. It looks like what that "str" exception was the default values or something.
« Last Edit: April 19, 2008, 02:02:39 PM by Penguin »
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +1/-0
  • Posts: 2661
    • View Profile
    • http://www.wreckedgames.com
Re: Exception on InputMgr Creation
« Reply #9 on: April 19, 2008, 04:04:47 PM »

Can you comment out the mouse initialization and run the app with just the OIS keyboard? To me, it sounds like not an OIS problem at all... Maybe some odd issue with your SharedOgreResources class (like memory overflow/corruption, or something else).
Logged

Penguin

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 12
    • View Profile
Re: Exception on InputMgr Creation
« Reply #10 on: April 19, 2008, 05:37:47 PM »

Nope it crashed on the keyboard. It has to be something I did, but I'm really at a loss of what to do. Thank you.
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +1/-0
  • Posts: 2661
    • View Profile
    • http://www.wreckedgames.com
Re: Exception on InputMgr Creation
« Reply #11 on: April 19, 2008, 07:37:54 PM »

Run through debugger, and inspect all variables in the current method as it is called (ie the 'this' pointer, member vars, etc). Make sure nothing funky goes on there.

Also, try to step backwards a bit. Generate a simple test app and work from there. Ie, start with OIS console app type of code and see what you can figure out.
Logged

OvermindDL1

  • Administrator
  • Veteran
  • *****
  • Karma: +0/-0
  • Posts: 288
    • View Profile
    • http://www.overminddl1.com/forum/
Re: Exception on InputMgr Creation
« Reply #12 on: April 20, 2008, 10:42:00 AM »

If you can give us a minimal repro case then we could help, at the very least see if it happens on other systems.
Logged

Penguin

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 12
    • View Profile
Re: Exception on InputMgr Creation
« Reply #13 on: April 21, 2008, 04:05:10 AM »

Here is my project file that does it. http://www.robertjacques.com/project.zip I've included the object files and everything.
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +1/-0
  • Posts: 2661
    • View Profile
    • http://www.wreckedgames.com
Re: Exception on InputMgr Creation
« Reply #14 on: April 21, 2008, 07:00:35 AM »

Kind of a bigger test case than I would have liked, also seems it is VC9 whereas I only use VC8 still. I do have a VC9 available, but was not really planning on using it now just for this... but, maybe if I get a chance.

I still say you need to do 2 things:
1) Try the OIS Console demo, make sure it runs smoothly for you.
2) Try Ogre demos, make sure they run smoothly for you

Then, if both cases above are true, there is some issue with your code base (most likely). Really, solving this should not be too difficult, and will improve your debugging skillzs ;) I would start by taking what you sent, and stripping out everything except Ogre startup and OIS startup. No GUI, no loading data, etc. Then, if the issue still happens, it will be easier to isolate. If the issue went away, add somethings back until problem shows up again to isolate what causes it.
Logged
Pages: [1] 2