# Helping the new guy

## Recommended Posts

[smile]Hi guys i'm new here and this seems to be the section to go to and i need some help access violation reading locations with my game using irrlicht and msvc express 2008... So i guess i'll post some code and see what you guys think... the problem
void level_manager::load_level01()
{
level_mesh = glevel_manager->getSceneMgr()->getMesh("media/level.x"); //<--the violation
glevel_manager->getSceneMgr()->getMeshManipulator()->makePlanarTextureMapping(level_mesh->getMesh(0), 0.004f);
level_node->setMaterialTexture(0, glevel_manager->getVideo()->getTexture("media/level.jpg"));
level_node->getMaterial(0).SpecularColor.set(0,0,0,0);

}


the game manager of all the managers
#include "game_manager.h"
#include "game_entity.h"
#include "level_manager.h"

game_manager::game_manager()
{
initalizeDevice();
initalizeDrivers();
init();
}

game_manager::~game_manager()
{
//closes the engine
}

void game_manager::initalizeDevice()
{
gDevice = createDevice(EDT_DIRECT3D9,dimension2d<s32>(640,640),32,false,true,true,this);
if(gDevice == NULL)
gDevice = createDevice(EDT_OPENGL,dimension2d<s32>(640,640),32,false,true,true,this);
}

void game_manager::initalizeDrivers()
{
gVideo = gDevice->getVideoDriver();
gSceneMgr = gDevice->getSceneManager();
gGUIEnv = gDevice->getGUIEnvironment();
gDevice->setWindowCaption(L"Project_METAL    Irrevelant Studios");

//dwarfmesh = gSceneMgr->getMesh("media/dwarf.x");

}

void game_manager::init()
{
//to be coded
}

IrrlichtDevice* game_manager::getDevice()
{
return gDevice;
}

IVideoDriver* game_manager::getVideo()
{
return gVideo;
}

ISceneManager* game_manager::getSceneMgr()
{
return gSceneMgr;
}

IGUIEnvironment* game_manager::getGUIEnv()
{
return gGUIEnv;
}

game_entity* game_manager::get_entity_manager()
{
return entity_manager;
}

level_manager* game_manager::get_level_manager()
{
return mlevel_manager;
}

bool game_manager::OnEvent(const SEvent &event)
{
if (event.EventType == EET_KEY_INPUT_EVENT && !event.KeyInput.PressedDown)
{
switch (event.KeyInput.Key)
{
case irr::KEY_ESCAPE:
gDevice->closeDevice();
break;
case irr::KEY_KEY_0:
break;
case irr::KEY_KEY_1:
gDevice->closeDevice();
break;
default:
break;
}
}
return false;
}


i know not all of you are familiar with irrlicht and access violations are tricky but i really need some help and i keep staring at the debugger trying to solve this for hours. Anyhow thanks in advance for any help. (p.s.)i can post more code if it will make things easier to solve. [Edited by - thatdudeoverthere on April 30, 2009 8:00:02 PM]

##### Share on other sites
level_mesh = glevel_manager->getSceneMgr()->getMesh("media/level.x"); //<--the violation

Just a shot in the dark but are you sure none of those pointers are invalid?
glevel_manager - is this valid?
glevel_manager->getSceneMgr() - does this return a valid pointer?
glevel_manager->getSceneMgr() - Have you stepped through this with a debugger?
glevel_manager->getSceneMgr()->getMesh("media/level.x") - have you stepped through this with a debugger?

In msvc just place a break point next to that first line (left click in the margin on the left of the code) and run with debugging. The program will stop on this line before it executes and you can use the debugging toolbar to step in, step over, or step out of a code block. You can use the windows at the bottom to view variables current values as you walk through the code.

The debugger can be used for so much more however if this is all you ever use it for it will still be the best tool in msvc.

##### Share on other sites
i'm redesigning my code as we speak(well as we type) the code i posted seemed too cubersome and bugged obviously. but thanks evillive2http://www.gamedev.net/community/forums/images/icons/icon92.gif

## Create an account

Register a new account

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627682
• Total Posts
2978623

• 9
• 14
• 12
• 10
• 12