Stack overflow.
that`s all the stack has
I commented out the recursion so it never gets called. That should stop it being the cause if it was. Im still getting the error though. P.S its a irrlicht wanna be game with more or less code in it, I have no clue what`s causing the error so I dont know how can I isolate the problem in a minimal example )
P.P.S being an irrlicht program it starts out as a console which then creates the window, however it breaks before any console is displayed.
Sounds like you may have over run an array inside a function, which will screw up the return address and stack.
Or just written to a bad address.
Difficult to tell without seeing the code.
Or just written to a bad address.
Difficult to tell without seeing the code.
It's also possible that you have a huge (1MB or so) array on the stack. What does your main() function look like?
ok, here it is the programmers nightmare
int main(){ // let user select driver type video::E_DRIVER_TYPE driverType = video::EDT_DIRECT3D9; printf("Please select the driver you want for this example:\n" " (a) Direct3D 9.0c\n (b) Direct3D 8.1\n (c) OpenGL 1.5\n" " (d) Software Renderer\n (e) Burning's Software Renderer\n" " (f) NullDevice\n (otherKey) exit\n\n"); char i; std::cin >> i; switch(i) { case 'a': driverType = video::EDT_DIRECT3D9;break; case 'b': driverType = video::EDT_DIRECT3D8;break; case 'c': driverType = video::EDT_OPENGL; break; case 'd': driverType = video::EDT_SOFTWARE; break; case 'e': driverType = video::EDT_BURNINGSVIDEO;break; case 'f': driverType = video::EDT_NULL; break; default: return 1; } // create device and exit if creation failed IrrlichtDevice* _device = createDevice(driverType, core::dimension2d<s32>(800, 800), 16, false, false); if (_device == 0) return 1; // could not create selected driver. video::IVideoDriver* _driver = _device->getVideoDriver(); scene::ISceneManager* _smgr = _device->getSceneManager(); gui::IGUIEnvironment* _env = _device->getGUIEnvironment(); // add white light _smgr->addLightSceneNode(0, core::vector3df(-15,5,-105), video::SColorf(1.0f, 1.0f, 1.0f)); // set ambient light _smgr->setAmbientLight(video::SColor(0,60,60,60)); /* The next is just some standard stuff: Add a user controlled camera to the scene, disable mouse cursor, and add a test cube and let it rotate to make the scene more interesting. */ // add fps camera irr::scene::ICameraSceneNode * _GameCamera = _smgr->addCameraSceneNode(0, core::vector3df(-100,0,100), core::vector3df(-100,0,0)); // disable mouse cursor _device->getCursorControl()->setVisible(false); // create test cube scene::ISceneNode* _test = _smgr->addCubeSceneNode(160); scene::ISceneNode* _unitlayer = _smgr->addCubeSceneNode(160); // let the cube rotate and set some light settings /*scene::ISceneNodeAnimator* anim = smgr->createRotationAnimator( core::vector3df(0.3f, 0.3f,0));*/ _test->setPosition(core::vector3df(-100,0,-100)); _unitlayer->setPosition(core::vector3df(-100,0,-90)); _test->setMaterialFlag(video::EMF_LIGHTING, false); // disable dynamic lighting _test->setMaterialFlag(video::EMF_ANISOTROPIC_FILTER, false); _test->setMaterialFlag(video::EMF_BILINEAR_FILTER, false); _test->setMaterialFlag(video::EMF_TRILINEAR_FILTER, false); _unitlayer->setMaterialFlag(video::EMF_LIGHTING, false); _unitlayer->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL); /*node->setMaterialFlag(video::EMF_BILINEAR_FILTER, true);*/ /*test->addAnimator(anim); anim->drop();*/ // set window caption //_device->setWindowCaption(L"Irrlicht Engine - Render to Texture and Specular Highlights example"); /********************************************** *********************************************** render texture ***********************************************/ // create render target video::ITexture* _rt = _driver->addTexture(core::dimension2d<s32>(256,256), "RTT1",irr::video::ECOLOR_FORMAT::ECF_R8G8B8); irr::video::ECOLOR_FORMAT F = _rt->getColorFormat(); video::ITexture* _rtulayer = _driver->addTexture(core::dimension2d<s32>(256,256), "RTT2",irr::video::ECOLOR_FORMAT::ECF_A8R8G8B8); if (_driver->queryFeature(video::EVDF_RENDER_TO_TARGET)) { _test->setMaterialTexture(0, _rt); // set material of cube to render target _unitlayer->setMaterialTexture(0,_rtulayer); } /*********************************************** *********************************************** GUI ***********************************************/ irr::gui::IGUIWindow* _wnd = _env->addWindow(core::rect<s32>(0,600,800,800), false, L"Console", 0, 5000); //_wnd->setDraggable(false); _wnd->setAlignment(irr::gui::EGUI_ALIGNMENT::EGUIA_CENTER,irr::gui::EGUI_ALIGNMENT::EGUIA_CENTER,irr::gui::EGUI_ALIGNMENT::EGUIA_CENTER,irr::gui::EGUI_ALIGNMENT::EGUIA_CENTER); irr::gui::IGUIButton * _b1 = _env->addButton(core::rect<s32>(10,100,85,130), _wnd, GUI_ID_NEW_WINDOW_BUTTON, L"New Win"); irr::gui::IGUIButton * _m1 = _env->addButton(core::rect<s32>(20,150,60,170), _wnd, GUI_ID_NEW_WINDOW_BUTTON, L"North"); irr::gui::IGUIButton * _m2 = _env->addButton(core::rect<s32>(60,150,100,170), _wnd, GUI_ID_NEW_WINDOW_BUTTON, L"South"); irr::gui::IGUIButton * _m3 = _env->addButton(core::rect<s32>(100,150,140,170), _wnd, GUI_ID_NEW_WINDOW_BUTTON, L"East"); irr::gui::IGUIButton * _m4 = _env->addButton(core::rect<s32>(140,150,180,170), _wnd, GUI_ID_NEW_WINDOW_BUTTON, L"West"); irr::gui::IGUIButton * _r1 = _env->addButton(core::rect<s32>(20,70,40,90), _wnd, GUI_R1, L"1"); irr::gui::IGUIButton * _r2 = _env->addButton(core::rect<s32>(40,70,60,90), _wnd, GUI_R2, L"2"); irr::gui::IGUIButton * _d1 = _env->addButton(core::rect<s32>(60,120,120,140), _wnd, GUI_ID_NEW_WINDOW_BUTTON, L"Open"); irr::gui::IGUIButton * _d2 = _env->addButton(core::rect<s32>(120,120,180,140), _wnd, GUI_ID_NEW_WINDOW_BUTTON, L"Close"); irr::gui::IGUIButton * _r3 = _env->addButton(core::rect<s32>(60,70,80,90), _wnd, GUI_ID_NEW_WINDOW_BUTTON, L"3"); irr::gui::IGUIButton * _r4 = _env->addButton(core::rect<s32>(80,70,100,90), _wnd, GUI_ID_NEW_WINDOW_BUTTON, L"4"); irr::gui::IGUIButton * _r5 = _env->addButton(core::rect<s32>(100,70,120,90), _wnd, GUI_ID_NEW_WINDOW_BUTTON, L"5"); irr::gui::IGUIButton * _r6 = _env->addButton(core::rect<s32>(120,70,140,90), _wnd, GUI_ID_NEW_WINDOW_BUTTON, L"6"); irr::gui::IGUIButton * _r7 = _env->addButton(core::rect<s32>(140,70,160,90), _wnd, GUI_ID_NEW_WINDOW_BUTTON, L"7"); irr::gui::IGUIButton * _r8 = _env->addButton(core::rect<s32>(160,70,180,90), _wnd, GUI_ID_NEW_WINDOW_BUTTON, L"8"); irr::gui::IGUIButton * _r9 = _env->addButton(core::rect<s32>(180,70,200,90), _wnd, GUI_ID_NEW_WINDOW_BUTTON, L"7"); irr::gui::IGUIButton * _r10 = _env->addButton(core::rect<s32>(200,70,220,90), _wnd, GUI_ID_NEW_WINDOW_BUTTON, L"8"); irr::gui::IGUIListBox* _listbox =_env->addListBox(irr::core::rect<s32>(20, 30, 100, 60),_wnd); _listbox->addItem(L"Test"); /* _m1->setVisible(false); _m2->setVisible(false); _m3->setVisible(false); _m4->setVisible(false);*/ // Map.AddRoom(); SAppContext context; context._device = _device; context._listbox = _listbox; context.counter = 0; context._b1 = _b1; context._m1 = _m1; context._m2 = _m2; context._m3 = _m3; context._m4 = _m4; // Then create the event receiver, giving it that context structure. MyEventReceiver receiver(context); // And tell the device to use our custom event receiver. _device->setEventReceiver(&receiver); int lastFPS = -1; int width = 256;/**********************************************************************************************Map and characters***********************************************/ map Map; Map.Tile(6); Map.Room(0,2,2,4,4,0,0,2,0); Map.Room(1,6,2,4,4,0,1,3,2); Map.Room(2,9,2,2,4,0,0,3,3); Map.Room(3,11,2,2,4,1,1,1,3); Map.Room(4,2,6,4,4,0,0,1,0); Map.Room(5,6,6,4,4,1,0,1,1); Map.Room(6,10,7,4,6,1,0,0,1); lights Lights; chars Chars; Chars.Character(50000,20000,4000,4000,Lights,20); Chars.Character(50000,40000,4000,4000,Lights,20); Chars.Character(40000,20000,4000,4000,Lights,20); tcounter Timer; __int64 MSElapsed =0; __int64 MSFreq =0; __int64 MSElapsedSinceStart =0; int color1d = 256; int color2d = 65536; int color3d = 16777216; while(_device->run()) if (_device->isWindowActive()) { Timer.Loop(MSElapsed,MSElapsedSinceStart,MSFreq); Chars.Logic((int)MSElapsed); core::stringw str; //str = L"0"; //Chars.Left(0,Map); if(receiver.IsKeyDown(irr::KEY_LEFT)) { Chars.Left(0,Map,Lights); } if(receiver.IsKeyDown(irr::KEY_RIGHT)) { Chars.Right(0,Map,Lights); } if(receiver.IsKeyDown(irr::KEY_UP)) { Chars.North(0,Map,Lights); } if(receiver.IsKeyDown(irr::KEY_DOWN)) { Chars.South(0,Map,Lights); } _driver->beginScene(true, true, irr::video::SColor(0,200,200,200)); if (_rt) { s32* p = (s32*)_rt->lock (); for(int i =0; i < Map.RoomCount; i++) { for(int z =Map.Rooms.NWy*Map.TileSize; z < Map.Rooms.SEy*Map.TileSize; z++) { for(int x =Map.Rooms.NWx*Map.TileSize; x < Map.Rooms.SEx*Map.TileSize; x++) { p[z * width + x] = 0*color2d + (255/(i+1))*color1d + 0; } } } for(int z = 0; z < Map.Pixels; z++) { for(int x =0; x < Map.Pixels; x++) { if(Map.WallMap[z][x]) { p[z * width + x] = 255*color2d + 255*color1d + 255; } } } for(int i =0; i < Chars.CrCount; i++) { for(int z =Chars.Creatures.NWy/1000; z < Chars.Creatures.SEy/1000; z++) { for(int x =Chars.Creatures.NWx/1000; x < Chars.Creatures.SEx/1000; x++) { p[z * width + x] = 0*color2d + 0*color1d + (255/(i+1)); } } } _rt->unlock(); _test->setVisible(true); _smgr->setActiveCamera(_GameCamera); } if(_rtulayer) { s32* p = (s32*)_rtulayer->lock(); for(int z =0; z < width; z++) { for(int x =0; x < width; x++) { p[z * width + x] = Lights.LightMap[z][x].a*color3d + Lights.LightMap[z][x].r *color2d + Lights.LightMap[z][x].g*color1d + Lights.LightMap[z][x].b; } } /*for(int i =0; i < Chars.CrCount; i++) { for(int z =Chars.Creatures.NWy; z < Chars.Creatures.SEy; z++) { for(int x =Chars.Creatures.NWx; x < Chars.Creatures.SEx; x++) { p[z * width + x] = 100*color3d + 0*color2d + 0*color1d + (255/(i+1)); } } } */ _rtulayer->unlock(); } // draw scene normally _smgr->drawAll(); _env->drawAll(); core::position2d<s32> m = _device->getCursorControl()->getPosition(); _driver->draw2DRectangle(video::SColor(100,255,255,255), core::rect<s32>(m.X-5, m.Y-5, m.X+5, m.Y+5)); _driver->endScene(); // display frames per second in window title int fps = _driver->getFPS(); if (lastFPS != fps) { /*core::stringw str;*/ /*if(F == irr::video::ECOLOR_FORMAT::ECF_R5G6B5) str = L"ECF_R5G6B5 - Render to Texture and Specular Highlights example"; if(F == irr::video::ECOLOR_FORMAT::ECF_R8G8B8) str = L"ECF_R8G8B8 - Render to Texture and Specular Highlights example"; if(F == irr::video::ECOLOR_FORMAT::ECF_A1R5G5B5) str = L"ECF_A1R5G5B5 - Render to Texture and Specular Highlights example"; if(F == irr::video::ECOLOR_FORMAT::ECF_A8R8G8B8) str = L"ECF_A8R8G8B8 - Render to Texture and Specular Highlights example";*/ str += " ms: "; str += (int)MSElapsed; str += " FPS:"; str += fps; _device->setWindowCaption(str.c_str()); lastFPS = fps; } } _device->drop(); // drop device return 0;}/***/
Quote:Original post by Calin
map Map;
Map.Tile(6);
Map.Room(0,2,2,4,4,0,0,2,0);
Map.Room(1,6,2,4,4,0,1,3,2);
Map.Room(2,9,2,2,4,0,0,3,3);
Map.Room(3,11,2,2,4,1,1,1,3);
Map.Room(4,2,6,4,4,0,0,1,0);
Map.Room(5,6,6,4,4,1,0,1,1);
Map.Room(6,10,7,4,6,1,0,0,1);
At a guess, Map.Tile(6) creates 6 tiles, and you are adding 7.
Quote:At a guess, Map.Tile(6) creates 6 tiles, and you are adding 7.
-no thats the width of a tile in pixels, arguments 2 and 3 in Room() are used to tell the number of tiles )
Quote:Original post by CalinAh, I didn't realise it's happening before you even get into main()...
It brings the asm file right away
One thing I could suggest is commenting out bits of code until the bug goes away, then you'll be able to track down what caused the bug (It'll be the last bit you commented out). That, and adding some printf() / cout lines will let you see if it's even getting into main().
It's also possible that you just have a crapload of data on the stack in main() - in which case you need to switch to allocating some data elsewhere (I.e. on the heap).
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement