Skip to main content
GameDev.net gamedev.net
🔒 Locked

Some SFML issues

Started by KHearts May 23, 2011 at 7:09 AM 7 replies 3.5k views
Original Post
KHearts
KHearts
I'm currently attempting to set up my SFML environment. I've been using SDL for the past couple of years, and I have decided to move on. Currently, I seemingly have everything set up; however, when I use:

sf::Window -- the window appears but weird, unwanted images appear and cannot get it to be plain black.

or

sf::RenderWindow -- the window goes blank white for about 10 seconds and then crashes even though I clear the screen and display it afterward.

I've been using tutorial source code in order to troubleshoot these issues but nothing is working too far. I'm currently using SFML 1.6 and Visual Studio 2008.
Servant of the Lord
Servant of the Lord

I'm currently attempting to set up my SFML environment. I've been using SDL for the past couple of years, and I have decided to move on. Currently, I seemingly have everything set up; however, when I use:

sf::Window -- the window appears but weird, unwanted images appear and cannot get it to be plain black.

or

sf::RenderWindow -- the window goes blank white for about 10 seconds and then crashes even though I clear the screen and display it afterward.

I've been using tutorial source code in order to troubleshoot these issues but nothing is working too far. I'm currently using SFML 1.6 and Visual Studio 2008.


Use the RenderWindow one. Post your code (not just the tutorial's, but the actual code that you yourself tried to compile), and post what linker settings you are using. That way we can look over it and see if we spot anything wrong.
KHearts
KHearts


////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics.hpp>

int main()
{
// Create the main rendering window
sf::RenderWindow App(sf::VideoMode(800, 600, 32), "SFML Graphics");

// Start game loop
while (App.IsOpened())
{
// Process events
sf::Event Event;
while (App.GetEvent(Event))
{
// Close window : exit
if (Event.Type == sf::Event::Closed)
App.Close();

// A key has been pressed
if (Event.Type == sf::Event::KeyPressed)
{
// Escape key : exit
if (Event.Key.Code == sf::Key::Escape)
App.Close();

// F1 key : capture a screenshot
if (Event.Key.Code == sf::Key::F1)
{
sf::Image Screen = App.Capture();
Screen.SaveToFile("screenshot.jpg");
}
}
}

// Clear the screen with red color
App.Clear(sf::Color(200, 0, 0));

// Display window contents on screen
App.Display();
}

return EXIT_SUCCESS;
}


Linking:
sfml-system-s.lib
sfml-graphics-s.lib
sfml-window-s.lib
sfml-network-s.lib
sfml-audio-s.lib
Sir Funk
Sir Funk
Sorry to not contribute to your topic, but if I may ask, why did you move on from SDL to SFML?
KHearts
KHearts
I'm not abandoning SDL or anything; I just want to get my feet wet in more libraries just in case.
KHearts
KHearts
My video card is actually onboard since I'm working from a small netbook.
Servant of the Lord
Servant of the Lord

My video card is actually onboard since I'm working from a small netbook.

Try updating your video driver.
Try your program on a friend/family computer, and if it works, scour the SFML forums looking for people with similar problems. It's not your code that's wrong.

I had a similar problem earlier this year, with SFML. It happed to alot of SFML users who were using ATI cards with the Catalyst drivers. I ended up having to statically link to the SFML libraries to solve the issue, instead of dynamically linking. However, since you are already statically linking, maybe try the opposite? mellow.gif
KHearts
KHearts
So, apparently something might be wrong with SFML 1.6...After installing SFML 2.0, it worked beautifully.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.