Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: sf::RenderWindow doesn't work  (Read 4200 times)

0 Members and 1 Guest are viewing this topic.

sw

  • Newbie
  • *
  • Posts: 8
    • View Profile
sf::RenderWindow doesn't work
« on: July 03, 2016, 12:05:59 pm »
Hello,

i've used sfml with Visual Studio now for a while. Now i wanted to use sfml with Code::Blocks.
I installed everything and followed the SFML and Code::Blocks (MinGW) tutorial. I installed the GCC 4.8.1 TDM (SJLJ) - 64-bit sfml version and the TDM 4.8.1 (64-bit) compiler linked on the sfml download page.

I compiled the example from the SFML and Code::Blocks (MinGW) tutorial and there were no errors. But when i start the programm it doesn't work. The sfml window pops up with a white screen and the correct text but there come directly a windows window which say that the program doesn't work any longer (the exact text in german: Testing.exe funktioniert nicht mehr).
Here is the code i compiled (i just copied it from the tutorial):

Code: [Select]
#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
    sf::CircleShape shape(100.f);
    shape.setFillColor(sf::Color::Green);

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.clear();
        window.draw(shape);
        window.display();
    }

    return 0;
}

If i now compile this code:

Code: [Select]
#include <SFML/Graphics.hpp>

int main()
{
    sf::Vector2f vec;
    vec.x = 8;
    std::cout << vec.x << std::endl;

    return 0;
}

everything works and the "8" is showing up in the console window.
I also just compiled this:

Code: [Select]
#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");

    return 0;
}

the same "Testing.exe doesn't work any longer" window pops up when i start the program (there were again no errors when i compiled it).

It seems that the problem is the sf::RenderWindow, but what exactly is wrong here?
« Last Edit: July 03, 2016, 12:13:07 pm by sw »

sw

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: sf::RenderWindow doesn't work
« Reply #1 on: July 09, 2016, 12:15:25 pm »
Has nobody an idea? I could post some screenshots of my compiler settings or something else if this would help.

sw

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: sf::RenderWindow doesn't work
« Reply #2 on: July 09, 2016, 03:12:47 pm »
I tried it now with the GCC 4.9.2 MinGW compiler and everything work fine. So probably i made a mistake with the compiler settings.

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: sf::RenderWindow doesn't work
« Reply #3 on: July 09, 2016, 04:28:37 pm »
Glad to hear that you got it sorted :)
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*