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

Author Topic: SFML Window Won't Draw Anything  (Read 1926 times)

0 Members and 1 Guest are viewing this topic.

Erikelelf

  • Newbie
  • *
  • Posts: 2
    • View Profile
SFML Window Won't Draw Anything
« on: August 10, 2019, 03:23:42 pm »
First of all I'd just like to say I greatly appreciate any answers to this question. I know you probably get this question all the time and I'm just doing something dumb but I really can't figure out what I'm doing wrong. I've downloaded SFML and followed the tutorial to get it working with Codeblocks. After some initial trouble, I've managed to link the libraries and get everything setup. With that done, I copy pasted the example code in the tutorial into my file and hit build and run.

The code runs completely fine, but it doesn't work how it should at all. The window to draw the shape appears, but absolutely nothing appears in it. Not a background, not the shape, just a blank white box. I've tried everything, drawing different shapes, making changes to various parts of the code, finding other examples online. I've researched the problem and gone through over two google pages, but the most I could find was something to do with Intel not working well with RenderWindow. I don't think I've made a mistake linking the libraries because the code works just fine and autocomplete pops up with SFML syntax so it's got to be connected. Here's the code.

#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;
}

As you can see, it's copied exactly from the tutorial. This is all that pops up when I build and run:



Can anyone help me?

Hapax

  • Hero Member
  • *****
  • Posts: 3351
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: SFML Window Won't Draw Anything
« Reply #1 on: August 10, 2019, 08:43:00 pm »
It doesn't look like the window is even getting cleared (as it, by default, clears to black) so it's failing quite early on in the setup.

I suppose the first question is: do you have the very latest graphics driver?
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Erikelelf

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: SFML Window Won't Draw Anything
« Reply #2 on: August 10, 2019, 10:10:26 pm »
It doesn't look like the window is even getting cleared (as it, by default, clears to black) so it's failing quite early on in the setup.

I suppose the first question is: do you have the very latest graphics driver?

Probably not, my computers very old and bad and on its way out in a few months.

 

anything