SFML Installation Problem

I'm having a problem with part of the Window part of SFML.
I can create windows and I can use window.isOpen window.pollEvent window.display(). But window.clear() and window.draw(whatever) are showing as undefined. The rest of SFML is working though.

Here's my dependencies. It goes left to right just like in visual studio:
sfml-audio-d.lib;sfml-graphics-d.lib;sfml-window-d.lib;sfml-system-d.lib;kernel32.lib;etc;etc;etc;

I'm using Microsoft Visual Studio 2013 with SFML 2.3.2 Visual C++ 12 (2013) - 32 Bit

Here's the code I'm using
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "SFML/Graphics.hpp"
using namespace sf;
int main()
{
	Window window(VideoMode(800, 600), "sfml");

	CircleShape ball(10.f);
	ball.setFillColor(Color(0, 0, 0));

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

		window.draw(ball);

		window.display();
	}

	return 0;
}


Any help is appreciated, thanks.
Last edited on
Line 1: I fully doubt this is the case, but maybe you are linking to SFML incorrectly. If this is the case: change #include "SFML/Graphics.hpp" to #include <SFML/Graphics.hpp>

Line 5: Change Window window(VideoMode(800, 600), "sfml"); to RenderWindow window(VideoMode(800, 600), "sfml")


Also, I highly recommend you exclude using namespace sf; from your program. I'm not very good at explaining, so you might want to check this out to see why: http://stackoverflow.com/questions/1452721/why-is-using-namespace-std-considered-bad-practice
Last edited on
A sf::Window doesn't have a clear or draw method.

Perhaps you meant to define an object of type sf::RenderWindow.
Line 1: This may not be the case, but might work: change #include "SFML/Graphics.hpp" to #include <SFML/Graphics.hpp>

Line 5: Change Window window(VideoMode(800, 600), "sfml"); to RenderWindow window(VideoMode(800, 600), "sfml")


Also, I highly recommend you exclude using namespace sf; from your program. Pretend I have two librarys included in my code. One is #include "Average.hpp" and another is #include <Maths.hpp> . Both have a function called calculate();. If you include using namespace someObject; for both librarys in your code, then try to call the calculate(); function, your compiler won't know to use the calculate(); function from Math.hpps, or Average.hpp. If you exclude using namespace std;, you can specify which object the function (or variable) belongs to.

Sadly your suggestion did not work, but thanks for the tip!

A sf::Window doesn't have a clear or draw method.

Perhaps you meant to define an object of type sf::RenderWindow.

Yep, that was it. My bad!
Topic archived. No new replies allowed.