Well, I just downloaded Box2D for a game that I've been planning for awhile now (about 3 hours =)
And I get an error when I run my program, an error that I can't seem to get rid of. Also, no compile erros =\
The error is as follows - I get a warning popup, from "Microsoft Visual C++ Debug Library", called "Debug Error!"
The text is as follows -
And in the console -
Along with some other, normal stuff from the graphics engine - Irrlicht.
So, here is my program -
Help? =) I'm new to this library, so have mercy.
And I get an error when I run my program, an error that I can't seem to get rid of. Also, no compile erros =\
The error is as follows - I get a warning popup, from "Microsoft Visual C++ Debug Library", called "Debug Error!"
The text is as follows -
Code:
Program: ...ments\Visual Studio 2008\Projects\PhyzTris\Debug\PhyzTris.exe
This application has requested the runtime to terminate it in an unusual way. Please contact... Yeah, yeah, that part doesnt matter
This application has requested the runtime to terminate it in an unusual way. Please contact... Yeah, yeah, that part doesnt matter
And in the console -
Code:
Assertion Failed: worldAABB.IsValid(), file ..\..\Source\Collision\b2BroadPhase.cpp, line 70
Along with some other, normal stuff from the graphics engine - Irrlicht.
So, here is my program -
Code:
#include<irrlicht.h>
#include<iostream>
#include<Box2D.h>
#pragma comment(lib, "box2d_d.lib")
#pragma comment(lib, "Irrlicht.lib")
//Namespaces
using namespace std;
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
//Settings
static bool VS=true;
static bool SB=true;
static bool AA=false;
static int SCREENX=640;
static int SCREENY=480;
static int SCREENZ=32;
static E_DRIVER_TYPE DRIVER=EDT_OPENGL;
class MyEventReceiver : public IEventReceiver
{
public:
virtual bool OnEvent(const SEvent& event)
{
if (event.EventType == EET_KEY_INPUT_EVENT)
KeyIsDown[event.KeyInput.Key] = event.KeyInput.PressedDown;
return false;
}
virtual bool IsKeyDown(EKEY_CODE keyCode) const
{
return KeyIsDown[keyCode];
}
MyEventReceiver()
{
for (u32 i=0; i<KEY_KEY_CODES_COUNT; ++i)
KeyIsDown[i] = false;
}
private:
bool KeyIsDown[KEY_KEY_CODES_COUNT];
};
MyEventReceiver receiver;
//Functions
IrrlichtDevice* Setup_Screen();
//Variables
//Globals
//Structures
int main()
{
//Setup
IrrlichtDevice* device=Setup_Screen();
if(device==0)
return 1;
IVideoDriver* driver=device->getVideoDriver();
ISceneManager* smgr=device->getSceneManager();
IGUIEnvironment* gui=device->getGUIEnvironment();
//Setup Physics
b2AABB worldAABB;
worldAABB.lowerBound.Set(-200.0f,-200.0f);
worldAABB.lowerBound.Set(200.0f,200.0f);
b2Vec2 GRAVITY(0.0f,-10.0f);
bool doSleep=true;
b2World nWorld(worldAABB,GRAVITY,doSleep);
b2BodyDef groundBodyDef;
groundBodyDef.position.Set(0.0f,-10.0f);
b2Body* groundBody = nWorld.CreateBody(&groundBodyDef);
b2PolygonDef groundShapeDef;
groundShapeDef.SetAsBox(50.0f,10.0f);
groundBody->CreateShape(&groundShapeDef);
b2BodyDef bodyDef;
bodyDef.position.Set(0.0f,4.0f);
b2Body* body = nWorld.CreateBody(&bodyDef);
b2PolygonDef shapeDef;
shapeDef.SetAsBox(1.0f,1.0f);
shapeDef.density=1.0f;
shapeDef.friction=0.3f;
body->CreateShape(&shapeDef);
body->SetMassFromShapes();
float32 timeStep = 1.0f/60.0f;
int32 iterations = 10;
while(device->run() && driver)
{
//Simple Exit Call
if(receiver.IsKeyDown(KEY_ESCAPE))
break;
//Physics
nWorld.Step(timeStep,iterations);
//Drawing loop
driver->beginScene(true,true,SColor(255,0,0,0));
smgr->drawAll();
gui->drawAll();
driver->endScene();
};
device->drop();
return 0;
}
IrrlichtDevice* Setup_Screen()
{
SIrrlichtCreationParameters params;
params.AntiAlias=AA;
params.Stencilbuffer=SB;
params.Vsync=VS;
params.WindowSize=dimension2d<s32>(SCREENX,SCREENY);
params.Bits=SCREENZ;
params.Fullscreen=false;
params.EventReceiver=&receiver;
params.DriverType=DRIVER;
IrrlichtDevice* device=createDeviceEx(params);
return device;
};
#include<iostream>
#include<Box2D.h>
#pragma comment(lib, "box2d_d.lib")
#pragma comment(lib, "Irrlicht.lib")
//Namespaces
using namespace std;
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
//Settings
static bool VS=true;
static bool SB=true;
static bool AA=false;
static int SCREENX=640;
static int SCREENY=480;
static int SCREENZ=32;
static E_DRIVER_TYPE DRIVER=EDT_OPENGL;
class MyEventReceiver : public IEventReceiver
{
public:
virtual bool OnEvent(const SEvent& event)
{
if (event.EventType == EET_KEY_INPUT_EVENT)
KeyIsDown[event.KeyInput.Key] = event.KeyInput.PressedDown;
return false;
}
virtual bool IsKeyDown(EKEY_CODE keyCode) const
{
return KeyIsDown[keyCode];
}
MyEventReceiver()
{
for (u32 i=0; i<KEY_KEY_CODES_COUNT; ++i)
KeyIsDown[i] = false;
}
private:
bool KeyIsDown[KEY_KEY_CODES_COUNT];
};
MyEventReceiver receiver;
//Functions
IrrlichtDevice* Setup_Screen();
//Variables
//Globals
//Structures
int main()
{
//Setup
IrrlichtDevice* device=Setup_Screen();
if(device==0)
return 1;
IVideoDriver* driver=device->getVideoDriver();
ISceneManager* smgr=device->getSceneManager();
IGUIEnvironment* gui=device->getGUIEnvironment();
//Setup Physics
b2AABB worldAABB;
worldAABB.lowerBound.Set(-200.0f,-200.0f);
worldAABB.lowerBound.Set(200.0f,200.0f);
b2Vec2 GRAVITY(0.0f,-10.0f);
bool doSleep=true;
b2World nWorld(worldAABB,GRAVITY,doSleep);
b2BodyDef groundBodyDef;
groundBodyDef.position.Set(0.0f,-10.0f);
b2Body* groundBody = nWorld.CreateBody(&groundBodyDef);
b2PolygonDef groundShapeDef;
groundShapeDef.SetAsBox(50.0f,10.0f);
groundBody->CreateShape(&groundShapeDef);
b2BodyDef bodyDef;
bodyDef.position.Set(0.0f,4.0f);
b2Body* body = nWorld.CreateBody(&bodyDef);
b2PolygonDef shapeDef;
shapeDef.SetAsBox(1.0f,1.0f);
shapeDef.density=1.0f;
shapeDef.friction=0.3f;
body->CreateShape(&shapeDef);
body->SetMassFromShapes();
float32 timeStep = 1.0f/60.0f;
int32 iterations = 10;
while(device->run() && driver)
{
//Simple Exit Call
if(receiver.IsKeyDown(KEY_ESCAPE))
break;
//Physics
nWorld.Step(timeStep,iterations);
//Drawing loop
driver->beginScene(true,true,SColor(255,0,0,0));
smgr->drawAll();
gui->drawAll();
driver->endScene();
};
device->drop();
return 0;
}
IrrlichtDevice* Setup_Screen()
{
SIrrlichtCreationParameters params;
params.AntiAlias=AA;
params.Stencilbuffer=SB;
params.Vsync=VS;
params.WindowSize=dimension2d<s32>(SCREENX,SCREENY);
params.Bits=SCREENZ;
params.Fullscreen=false;
params.EventReceiver=&receiver;
params.DriverType=DRIVER;
IrrlichtDevice* device=createDeviceEx(params);
return device;
};
Help? =) I'm new to this library, so have mercy.