Hello! I have recently started using SFML 2.0 with Thor 2.0. I made an example program to learn how the library works and I have correctly running it on my Ubuntu x64 PC in Eclipse:
#include <SFML/System.hpp>
#include <SFML/Audio.hpp>
#include <SFML/Graphics.hpp>
#include <Thor/Animation.hpp>
#include <Thor/Particles.hpp>
#include <iostream>
int main()
{
bool moveText = false;
// Create the main window
sf::RenderWindow Ventana(sf::VideoMode(800, 600), "Prueba Juego con SFML");
// Create a graphical string to display
sf::Font font;
if(!font.loadFromFile("gkfont.ttf")) return EXIT_FAILURE;
sf::Text mText("Hello!! :D", font, 50);
sf::Music miMusica;
if (!miMusica.openFromFile("musica.ogg")) return EXIT_FAILURE;
Ventana.setFramerateLimit(60);
Ventana.clear(sf::Color::Black);
// Start the game loop
while (Ventana.isOpen()){
// Process events
sf::Event Event;
while (Ventana.pollEvent(Event)){
// Close window : exit
if (Event.type == sf::Event::Closed) Ventana.close();
if (Event.type == sf::Event::MouseButtonPressed){
mText.setPosition(Event.mouseButton.x, Event.mouseButton.y);
Ventana.draw(mText);
moveText = true;
}
if(Event.type == sf::Event::MouseMoved && moveText == true){
Ventana.clear(sf::Color::Black);
mText.setPosition(Event.mouseMove.x, Event.mouseMove.y);
Ventana.draw(mText);
}
if(Event.type == sf::Event::MouseButtonReleased){
Ventana.clear(sf::Color::Black);
moveText = false;
}
if(Event.type == sf::Event::KeyPressed && moveText){
if(Event.key.code == sf::Keyboard::A) mText.setCharacterSize(mText.getCharacterSize()-2);
if(Event.key.code == sf::Keyboard::S) mText.setCharacterSize(mText.getCharacterSize()+2);
Ventana.clear(sf::Color::Black);
Ventana.draw(mText);
}
if(Event.type == sf::Event::KeyPressed){
if(Event.key.code == sf::Keyboard::P) miMusica.pause();
if(Event.key.code == sf::Keyboard::O) miMusica.play();
}
}
// Update the window
Ventana.display();
}
return EXIT_SUCCESS;
}
The program simply shows a text where the mouse pointer is, you can change its size pressing keys A and S and play music pressing O and P, everything ok.
The problem is when I try to run it on my netbook with Windows XP x86, Intel GMA3150, 1Gb RAM and Intel Athom even this very simple program is very slow and choppy:
- I can see the window refreshing (the window flashs white)
- Text movement is slow and not smooth as in my other PC
- Even if I don't show any text screen flash unless I delete Ventana.display() from the loop
The graphics card have OpenGL v1.4 I think it should be ok to display a simple text. I already updated the drivers to the latest version. Hope you can help me