#include <Box2D\Box2D.h>
#include <SFML\Graphics.hpp>
#include <SFML\window.hpp>
int main()
{
sf::RenderWindow game(sf::VideoMode(800, 600, 32), "game");
sf::Shape box = sf::Shape::Rectangle(0, 0, 2, 2, sf::Color(255,0,0));
b2Vec2 gravity(0.0f, -10.0f);
bool doSleep = true;
b2World world(gravity, doSleep);
b2BodyDef groundBodyDef;
groundBodyDef.position.Set(0.0f, -10.0f);
b2Body* groundBody = world.CreateBody(&groundBodyDef);
b2PolygonShape groundBox;
groundBox.SetAsBox(50.0f, 10.0f);
groundBody->CreateFixture(&groundBox, 0);
b2BodyDef bodyDef;
bodyDef.type = b2_dynamicBody;
bodyDef.position.Set(0.0f, 4.0f);
b2Body* body = world.CreateBody(&bodyDef);
b2PolygonShape dynamicBox;
dynamicBox.SetAsBox(1.0f, 1.0f);
b2FixtureDef fixtureDef;
fixtureDef.shape = &dynamicBox;
fixtureDef.density = 1.0f;
fixtureDef.friction = 0.3f;
body->CreateFixture(&fixtureDef);
float32 timeStep = 1.0f / 60.0f;
int32 velIter = 6;
int32 posIter = 2;
b2Vec2 pos = body->GetPosition();
float32 an = body->GetAngle();
box.SetPosition(pos.x, pos.y);
box.SetRotation(an);
bool quit = false;
while(quit == false)
{
world.Step(timeStep, velIter, posIter);
world.ClearForces();
b2Vec2 pos = body->GetPosition();
float32 angle = body->GetAngle();
box.SetPosition(pos.x, pos.y);
box.SetRotation(angle);
if(game.GetInput().IsKeyDown(sf::Key::Escape))
{
quit = true;
}
game.Clear(sf::Color(0,0,0));
game.Draw(box);
game.Display();
}
game.Close();
return EXIT_SUCCESS;
}
so there is my code.
I have been trying to get this thing to work but every time i start it up the renderWindow crashes. the program keeps going but the renderwindow crashes.
I switched it to static by changing SFML_DYNAMIC to SFML_STATIC in the compiler settings and i changes all the linker commands to -libsfml-<whatever goes here>-s
Everything is linked right ( i think)
and if i switch it to static i get 50 + errors.
I am using mingw 4.4.1 on codeblocks.
most of the errors say undefined reference to '_Unwind_Resume'.
and again that only happens in static mode but in dynamic mode it freezes.
thanks a lot,
dartos

New Topic/Question
Reply




MultiQuote





|