Error:
...is on line 15, where I try to initialize window:
#include <iostream>
#include <SFML/Graphics.hpp>
static class Renderer {
public:
static sf::RenderWindow window;
};
sf::RenderWindow Renderer::window = sf::RenderWindow(sf::VideoMode(1200, 1000), "Proj");
class Quad {
public:
sf::Vector2<float> Scale;
sf::Vector2<float> Pos;
public:
Quad(sf::Vector2<float> P, sf::Vector2<float> S) {
Pos = P;
Scale = S;
}
sf::RectangleShape RenderMe() {
sf::RectangleShape s;
s.setScale(Scale);
s.setPosition(Pos);
return s;
}
};
int main()
{
std::cout << "Hello World!\n";
new Renderer;
Quad s(sf::Vector2<float>(40,40), sf::Vector2<float>(20,20));
while (Renderer::window.isOpen())
{
sf::Event event;
while (Renderer::window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
Renderer::window.close();
}
Renderer::window.clear();
Renderer::window.draw(s.RenderMe());
Renderer::window.display();
}
return 0;
return 0;
}
Everything else in the script works.
As far as I can tell, I have set up my filesystems correctly, and all issues are with my script (I think)
I have mostly tried moving around the init, as well as changing certain bits, like not including all of it, but those all caused different errors and this seemed the most correct.
Remove everything to do with class Renderer
and Renderer::window
.
Put a single definition at the top of your main function:
sf::RenderWindow window(sf::VideoMode(1200, 1000), "Proj");
and use window
wherever you used Renderer::window
.
If you insist on having a Renderer object, it should look like this:
class Renderer {
public:
sf::RenderWindow window;
Renderer() : window(sf::VideoMode(1200, 1000), "Proj")) {}
};
and a simple Renderer r;
in your main function will suffice.