-
Unknown Irrlicht Error
I have about 223 lines of code that, when compiled, produce no errors, but when ran, freezes for a moment, and then windows asks me if I want to send the error (that it won't identify) to their help center. There are no errors of any sort identified by the debugger or anything else, and I'm out of ideas... ...If anyone would be so kind as to debug the code for me, I would post it. Please let me know, thanks.
-
200 odd lines doesn't sound so bad - take a chance and attach the source file to your next reply
-
Go to the irrlicht forums, they will help you in no time.
I'm Irrlicht user myself...
-
When that happens, I use a debugger and step through the code untill the program crashes, then I know exactly where the problem is.
If you're loading anything externally, make sure the paths are correct and they're actually being loaded before using them. Also, make sure the pointers to the device, scene manager, driver, etc, are valid as well.
-
Thanks for the replies. I didn't have the graphics in the right folder, but when I put them there (and double checked the paths) it still does the same thing. When I debugged it, it told me it can't watch this variable:
Code:
IAnimatedMesh* Ship1 = scenemgr->getMesh("...GFX/Crafts/Small/Civilian/Shuttle.3ds");
I'm not really sure what that means, but here's the rest of the code, :P.
Code:
// Abiotica- Zero G
// Irrlicht Headers
#include "irrlicht.h"
#include <iostream>
#include <stdlib.h>
#include <string>
#include <stdio.h>
#include <wchar.h>
// Irrlicht Namespaces
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
using namespace std;
// Declaration of Global Variables
int quit = 0;
// Classes
// Irrlicht Initialization Class
class Init_Irrlicht
{
// Private Class Variables/Functions
protected:
// Protected Class Variables/Functions
bool FullScreen;
int FullScreen_Choice;
int VideoMode_Choice;
E_DRIVER_TYPE VideoMode;
public:
// Public Class Variables/Functions
void FuncInit_Irrlicht(void);
E_DRIVER_TYPE FuncVideo_Mode(void);
bool FuncFullScreen(void);
void GFX_Irrlicht(void);
IrrlichtDevice *device;
IVideoDriver* driver;
ISceneManager* scenemgr;
IGUIEnvironment* guienv;
};
// Graphics Display Class
class GFX_Irrlicht: public Init_Irrlicht
{
public:
// Public Class Variables/Functions
bool FuncLoad_All(void);
void FuncLoad_GUI(void);
void FuncDraw_All(void);
IAnimatedMesh* Ship1;
IAnimatedMeshSceneNode* Ship1Node;
};
// Event Handling Class
class Event_Receiver: public IEventReceiver
{
public:
virtual bool OnEvent(SEvent event)
{
if(event.EventType == EET_KEY_INPUT_EVENT &&
!event.KeyInput.PressedDown)
{
switch(event.KeyInput.Key)
{
case KEY_ESCAPE:
{
quit = 1;
}
return true;
}
}
// Exit Without Event Trigger
return false;
}
};
// Main Game Loop
int main()
{
// Initialize Irrlicht
Init_Irrlicht IrrInit_Object;
GFX_Irrlicht IrrGFX_Object;
IrrInit_Object.FuncInit_Irrlicht();
// Load Graphics
IrrGFX_Object.FuncLoad_GUI();
IrrGFX_Object.FuncLoad_All();
// Main Loop
while(quit == 0)
{
IrrGFX_Object.FuncDraw_All();
}
// Exit Main Function And Clean Up Irrlicht
IrrInit_Object.device->drop();
return 0;
}
// Function Declarations
// Irrlicht Initialization Function
void Init_Irrlicht::FuncInit_Irrlicht(void)
{
// Initialize Objects
Event_Receiver Input_Object;
// Initialize Irrlicht Engine
// [Default]OpenGL Driver, 800x600 Display...
// 16 Bit Depth, [Default]FullScreen
device = createDevice(FuncVideo_Mode(),
dimension2d<s32>(800, 600), 16, FuncFullScreen(), false, false, &Input_Object);
// Setup Device Pointers
driver = device->getVideoDriver();
scenemgr = device->getSceneManager();
guienv = device->getGUIEnvironment();
// Exit Function
return;
}
// Video Mode Query
E_DRIVER_TYPE Init_Irrlicht::FuncVideo_Mode()
{
// Ask Video Mode
cout << "Choose Video Mode...\n";
cout << "1: Software.\n";
cout << "2: DirectX9.\n";
cout << "3: DirectX8.\n";
cout << "4: OpenGL.\n";
cin >> VideoMode_Choice;
// Change Character String Accordingly
switch(VideoMode_Choice)
{
case 1:
VideoMode = EDT_SOFTWARE;
break;
case 2:
VideoMode = EDT_DIRECTX9;
break;
case 3:
VideoMode = EDT_DIRECTX8;
break;
case 4:
VideoMode = EDT_OPENGL;
break;
default:
VideoMode = EDT_OPENGL;
}
// Exit Function And Return Video Mode Choice String
return VideoMode;
}
// FullScreen Query
bool Init_Irrlicht::FuncFullScreen()
{
// Initial User Setup
// Ask Fullscreen
cout << "Fullscreen?\n";
cout << "1: Yes.\n";
cout << "2: No.\n";
cin >> FullScreen_Choice;
// If Yes Or No, Change Appropriately; Otherwise, Fullscreen
switch(FullScreen_Choice)
{
case 1:
FullScreen = true;
break;
case 2:
FullScreen = false;
break;
default:
FullScreen = true;
}
// Return Appropriate Boolean Value
return FullScreen;
}
// Load All Graphics (For In-Game Purposes)
bool GFX_Irrlicht::FuncLoad_All(void)
{
IAnimatedMesh* Ship1 = scenemgr->getMesh("...GFX/Crafts/Small/Civilian/Shuttle.3ds");
IAnimatedMeshSceneNode* Ship1Node = scenemgr->addAnimatedMeshSceneNode(Ship1);
Ship1Node->setMaterialFlag(EMF_LIGHTING, false);
scenemgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));
return true;
}
// Load All Graphics (For GUI Purposes)
void GFX_Irrlicht::FuncLoad_GUI(void)
{
return;
}
// Draw All Graphics (GUI Environment And Scene Manager)
void GFX_Irrlicht::FuncDraw_All(void)
{
// Begin Scene Rendering
driver->beginScene(true, true, SColor(0,200,200,200));
// Draw Scene Manager and GUI Environment
scenemgr->drawAll();
guienv->drawAll();
// End Scene Rendering
driver->endScene();
// Exit Function
return;
}
-
Oh, and every other time I do it (which greatly confuses me), it tells me I have an Access Violation (Segmentation Fault). But only every other time...
Also, in the video mode choice function, it doesn't return a string (obviously), it returns an E_DRIVER_TYPE variable. Not that it's particularly important.
-
Do a check after you load anything into memory, for example:
Code:
// Load the ship
IAnimatedMesh* Ship1 = scenemgr->getMesh("...GFX/Crafts/Small/Civilian/Shuttle.3ds");
// Check for existance
if (!Ship1)
{
// Error handling goes here
}
Or something like that. If that doesn't work, hop on over to the Irrlicht forums, and they can help you out.
-
I added that and it still does the same thing... :(. I'll post it over at Irrlicht too, I suppose. Thanks for the replies (again, :P).
-
I revamped the code (a lot), and now it opens and loads the model (and texture), but won't display anything or recognize key strokes. It's only 171 lines now though.
Code:
// Abiotica- Zero G
// Irrlicht Headers
#include "irrlicht.h"
#include <iostream>
#include <stdlib.h>
#include <string>
#include <stdio.h>
#include <wchar.h>
// Irrlicht Namespaces
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
using namespace std;
// Global Variables
int VideoMode_Choice;
int FullScreen_Choice;
bool quit = false;
bool FullScreen;
IrrlichtDevice *device;
IVideoDriver* driver;
ISceneManager* scenemgr;
IGUIEnvironment* guienv;
E_DRIVER_TYPE VideoMode;
IAnimatedMesh* Ship1;
IAnimatedMeshSceneNode* Ship1Node;
// Class Declarations
// Event Handling Class
class Event_Receiver : public IEventReceiver
{
public:
virtual bool OnEvent(SEvent event)
{
if(event.EventType == EET_KEY_INPUT_EVENT &&
!event.KeyInput.PressedDown)
{
switch(event.KeyInput.Key)
{
case KEY_ESCAPE:
{
quit = true;
}
return true;
}
}
// Exit Without Event Trigger
return false;
}
};
// Function Outlines
void FuncDraw_All(void);
void FuncLoad_All(void);
int main()
{
// Ask Fullscreen
cout << "Fullscreen?\n";
cout << "1: Yes.\n";
cout << "2: No.\n";
cin >> FullScreen_Choice;
// If Yes Or No, Change Appropriately; Otherwise, Fullscreen
switch(FullScreen_Choice)
{
case 1:
FullScreen = true;
break;
case 2:
FullScreen = false;
break;
default:
FullScreen = true;
}
// Ask Video Mode
cout << "Choose Video Mode...\n";
cout << "1: Software.\n";
cout << "2: DirectX9.\n";
cout << "3: DirectX8.\n";
cout << "4: OpenGL.\n";
cin >> VideoMode_Choice;
// Change Character String Accordingly
switch(VideoMode_Choice)
{
case 1:
VideoMode = EDT_SOFTWARE;
break;
case 2:
VideoMode = EDT_DIRECTX9;
break;
case 3:
VideoMode = EDT_DIRECTX8;
break;
case 4:
VideoMode = EDT_OPENGL;
break;
default:
VideoMode = EDT_OPENGL;
}
// Initialize Objects
Event_Receiver Input_Object;
// Initialize Irrlicht Engine
// [Default]OpenGL Driver, 800x600 Display...
// 16 Bit Depth, [Default]FullScreen
device = createDevice(VideoMode,
dimension2d<s32>(800, 600), 16, FullScreen, false, false);
device->setEventReceiver(&Input_Object);
// Setup Device Pointers
driver = device->getVideoDriver();
scenemgr = device->getSceneManager();
guienv = device->getGUIEnvironment();
// Load All Graphics
FuncLoad_All();
// Main Loop
while(quit != true)
{
// Graphics Display Function
FuncDraw_All();
}
// Uninitialize Irrlicht
device->drop();
}
// Draw All Graphics (GUI Environment And Scene Manager)
void FuncDraw_All(void)
{
// Begin Scene Rendering
driver->beginScene(true, true, SColor(0,0,0,0));
// Draw Scene Manager and GUI Environment
scenemgr->drawAll();
guienv->drawAll();
// End Scene Rendering
driver->endScene();
// Exit Function
return;
}
// Load All Graphics
void FuncLoad_All(void)
{
Ship1 = scenemgr->getMesh("C:/Dev-Cpp/Abiotica- Zero G/GFX/Crafts/Small/Civilian/Shuttle.x");
Ship1Node = scenemgr->addAnimatedMeshSceneNode(Ship1);
if(Ship1Node)
{
Ship1Node->setMaterialFlag(EMF_LIGHTING, false);
Ship1Node->setMaterialTexture( 0, driver->getTexture("C:/Dev-Cpp/Abiotica- Zero G/GFX/Crafts/Small/Civilian/Shuttle.bmp") );
}
// Add Camera
scenemgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));
}