SFML community forums
General => General discussions => Topic started by: kolofsson on April 03, 2008, 08:04:36 pm
-
Hello.
Q1: When should I expect v1.3?
Q2: In case the answer is "in may/june" can somebody please treat me with a nightly build of the latest SVN? I really can't get this thing to work and i really need latest features/bugfixes.
I'm using Windows, and the IDE is CodeBlocks (MinGW).
-
Q1: In may / june :D
Q2: I'll try to do it for you. But why don't you just build the dynamic version ?
-
I downloaded TortoiseSVN, checked out the SFML SVN, and then built the whole workspace in Code::Blocks.
It created 5 libraries except sfml-main, which i had to builda separately.
Then i placed the libs and includes in the right place, changed the code of my app to meet the new method names (the sprite class it much altered) and bulit the project.
This is what i got:
C:\SFML\lib\mingw\static\libsfml-graphics.a
(Sprite.o):Sprite.cpp:(.text+0x872)||
undefined reference to `_glBegin@4'|
and much more _gl**** errors. what am I doing wrong?
-
You seem not to link with the OpenGL libs.
I'm not a big fan of MinGW anyway.
MinGW is imho outdated for windows development (and has some limitations on vista, as far as I can remember).
It is based on the gcc 3.4.x series and those would be even outdated on Linux.
It had a huge boost back in the days when it was one of the best (in terms of standard-compliance and speed) free c++ compilers available for windows.
But the visual c compilers are now even faster, also quite standard compliant, integrate better into windows
and since the Windows SDK is now free to download and use, I recommend using the included vc++ compiler.
I think CodeBlocks supports it as well. Or go with the VisualC++-Express editions.
You will have less problems building sfml after all.:wink:
-
EDIT: I successfully compiled SFML libs under VC2008. However, when trying to compile any example i had to add the sfml-main library. Besides something is not working in my sample program.
#include <SFML/Graphics.hpp>
int main()
{
// Create the main rendering window
sf::RenderWindow App(sf::VideoMode(800,600,32), "SFML");
// Load the sprite image from a file
sf::Image Image;
if (!Image.LoadFromFile("image.jpg")) return EXIT_FAILURE;
// Create the sprite
sf::Sprite Sprite(Image);
App.Draw(Sprite);
App.Display();
(...some idle loop...)
It loads, shows the image, but there is an hourglass instead of a normal cursor. When i click on the image, it disappears and the program freezes.
-
You need to call App.Display() inside the loop, otherwise no events will be received and the window will not be refreshed.
Just look how this is done in the examples.
-
it was inside the loop, but i simplified it to find the source of the error. There were the key bindings too but the app does not respond (even to ALT+F4) or clicking X.
-
What happens if you compile and run any of the samples?
-
I compared the sample and my project, and got it to work by adding this:
#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow App(sf::VideoMode::GetDesktopMode(), "SFML", sf::Style::Fullscreen);
App.UseVerticalSync(true);
sf::Image Image;
if (!Image.LoadFromFile("image.jpg")) return EXIT_FAILURE;
sf::Sprite Sprite(Image);
Sprite.SetCenter(1280, 960);
while (App.IsOpened())
{
/////////////////////////////////////////////////////START
sf::Event Event;
while (App.GetEvent(Event))
{
if (Event.Type == sf::Event::Closed) { App.Close(); break; }
}
/////////////////////////////////////////////////////END
float Time = App.GetFrameTime();
if (App.GetInput().IsKeyDown(sf::Key::Left)) Sprite.SetX(Sprite.GetPosition().x - Time * Sprite.GetSize().x);
if (App.GetInput().IsKeyDown(sf::Key::Right)) Sprite.SetX(Sprite.GetPosition().x + Time * Sprite.GetSize().x);
if (App.GetInput().IsKeyDown(sf::Key::Up)) Sprite.SetY(Sprite.GetPosition().y - Time * Sprite.GetSize().y);
if (App.GetInput().IsKeyDown(sf::Key::Down)) Sprite.SetY(Sprite.GetPosition().y + Time * Sprite.GetSize().y);
if (App.GetInput().IsKeyDown(sf::Key::C)) Sprite.Rotate(- 180 * Time);
if (App.GetInput().IsKeyDown(sf::Key::V)) Sprite.Rotate(+ 180 * Time);
if (App.GetInput().IsKeyDown(sf::Key::Z)) Sprite.SetScale(Sprite.GetScale().x * (Time + 1), Sprite.GetScale().y * (Time + 1));
if (App.GetInput().IsKeyDown(sf::Key::X)) Sprite.SetScale(Sprite.GetScale().x / (Time + 1), Sprite.GetScale().y / (Time + 1));
if (App.GetInput().IsKeyDown(sf::Key::Escape)) App.Close();
App.Draw(Sprite);
App.Display();
}
return EXIT_SUCCESS;
}
Before it worked without handling events, but i guess now the events, when unhandled, flood the processor or something and cause this error i've experienced.
-
[EDIT]
Sorry, I previously answered in french without even noticing that I was on the english forum :oops:
So, I think there's no problem, querying events is not required (SFML can do without it), but you need it if you don't want your window to be kind of frozen.
-
Just in case, there's a MinGW build I made today here :
http://www.sfml-dev.org/temp/SFML-rev575.zip
-
Bless you! It works tip top.
However, i would still like to point out, that i had to modify my program and add this to the main loop:
sf::Event Event;
while (App.GetEvent(Event)) {};
Without it the program was kind of blocked. My assumption is that the unhandled events wait to be handled or something (?). Anyway, i dont know if it should be treated as a bug, but i'd just like you to know.
Thanks again for the marvellous build for MinGW!
-
Ok, I see. I think the window is frozen if you don't process its events on the OS side.