Jump to content
  • Advertisement
Sign in to follow this  
Adam West

debug assertion help? with input manager

This topic is 2269 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hey there,

im having trouble with the input manager i have implemented, its throwing an unhandeled exception:

main.cpp

#include "main.h"
#include "luamanager.h"
#include "physicsmanager.h"
LuaManager * LUA = new LuaManager;
//newtonManager* PHYS = new newtonManager;
redNovember* SYS = new redNovember;


int redNovember::shutdown()
{
LUA->DropLua();

//PHYS->drop();
device->drop();
delete LUA;
//delete PHYS;
delete SYS;
return 0;
}
int main()
{
SYS->initIrrlicht();

//PHYS->init();
SYS->LoadScene();
SYS->initShader();

SYS->initFPSCamera();



//SYS->initRain();
SYS->initFog();

LUA->loadScript("assets/scripts/test.lua");

///put main shit in here
//put gui loop here

SYS->initSkydome("assets/skydome/storm1.jpg");

/*
SYS->initSkybox("assets/skybox/citystorm/up.jpg",
"assets/skybox/citystorm/down.jpg",
"assets/skybox/citystorm/left.jpg",
"assets/skybox/citystorm/right.jpg",
"assets/skybox/citystorm/back.jpg",
"assets/skybox/citystorm/front.jpg");*/


SYS->renderScene();

SYS->shutdown();
}
void redNovember::initIrrlicht()
{
device = createDevice(EDT_OPENGL, dimension2d<u32>(800, 600), 32,
false, false, true, 0);
device->setWindowCaption(L"Project: Red November");
driver = device->getVideoDriver();
smgr = device->getSceneManager();
guienv = device->getGUIEnvironment();
device->getCursorControl()->setVisible(false); //hide cursor
fader = device->getGUIEnvironment()->addInOutFader();
// Then create the event receiver, giving it that context structure.
// And tell the device to use our custom event receiver.
}

void redNovember::renderScene()
{
int lastFPS = -1;
while(device->run())
{
if (device->isWindowActive())
{
driver->beginScene(true, true, video::SColor(255,200,200,200));

//menu key handler
if(IsKeyDown(irr::KEY_ESCAPE))
showGameMenu = true;

//menu shit
if (showGameMenu = true)
{
SYS->showInGameMenu();
}
else
SYS->hideInGameMenu();
smgr->drawAll();
driver->endScene();
int fps = driver->getFPS();
if (lastFPS != fps)
{
core::stringw str = L"[";
str += driver->getName();
str += "] FPS:";
str += fps;
device->setWindowCaption(str.c_str());
lastFPS = fps;
}
}
else
device->yield();
}
}


main.h

#ifndef MAIN_H_
#define MAIN_H_
#include <irrlicht.h>
#include <iostream>
#include <string.h>

using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;


//globals
class redNovember
{
public:
// always initialize class-members in the constructor - especially set pointers to 0!
redNovember() : device(0), driver(0), smgr(0),guienv(0)
{}

IrrlichtDevice *device;
IVideoDriver* driver;
ISceneManager* smgr;
IGUIEnvironment* guienv;
ICameraSceneNode * camera;
IMetaTriangleSelector * meta;
IGPUProgrammingServices* gpu;
scene::IParticleSystemSceneNode* ps;
gui::IGUIInOutFader* fader;

void initIrrlicht();
void initFPSCamera();
void renderScene();
int shutdown();
//for the game scenes
void LoadScene(); // const chars for maps
void initSkybox(const char* up,const char* down,const char* left, const char* right, const char* front, const char* back);
void initSkydome(const char* skydomefile);
//shader stuff
void initShader();
void VertexShader(const char* VertexShaderFilename, const char* VertexShaderFunction);
void PixelShader(const char* PixelShaderFilename, const char* PixelShaderFunction);
void GeoShader(const char* GeoShaderFilename, const char* GeoShaderFunction);
void initRain();
void initFog();
void initBloom();
void initHDR();
void initSSAO();
void initBokehDOF();
//user interface and effects
bool showGameMenu;
void fadeInTransition();
void fadeOutTransition();
void showInGameMenu();
void hideInGameMenu();
//material and shader ID's

s32 bloomMaterial;
s32 bokehDOFMaterial;
//s32 CgExampleMaterialType;
//for shaders

// You can put any other variables you want in here.
// For example driver, scenemanger although you can also always get them from device
// Note that the clean solution is making variables private and use public
// get-functions to access them from other classes as you can see when looking at Irrlicht classes.
// You can for example also create a function like that:
//irr::scene::ISceneManager* getSceneManager() const { return device ? device->getSceneManager() : 0; }
virtual bool OnEvent(const SEvent& event)
{
//remeber each key is down or up
if(event.EventType == irr::EET_KEY_INPUT_EVENT)
KeyIsDown[event.KeyInput.Key] =
event.KeyInput.PressedDown;
return false;
}
// This is used to check whether a key is being held down
virtual bool IsKeyDown(EKEY_CODE keyCode) const
{
return KeyIsDown[keyCode];
}
void MyEventReceiver()
{
for (u32 i=0; i<KEY_KEY_CODES_COUNT; ++i)
KeyIsDown = false;
}
private:
bool KeyIsDown[irr::KEY_KEY_CODES_COUNT];

};



// every other global you would need can instead of being global just be put in here.

#endif


thanks!

Share this post


Link to post
Share on other sites
Advertisement
that is not an "unhandled" exception, its an assertion failure (yes, there is a difference!), and what its trying to tell you is that you called delete (or free) on non-existant/already freed memory. in a case like this, you generally want to use debugger to help you backtrace the stack to the point where the delete (or free) call is, so you can see why its failing.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!