So I am switching from C# to c++, I managed to compile sfml 2.0 and create a renderwindow. Then I wanted to wrap it inside a world class and for some reason it keeps spitting out these errors :
c:\users\quincy\sfml-2.0\laurentgomila-sfml-79d5217\include\sfml\window\window.hpp(500): error C2248: 'sf::NonCopyable::NonCopyable' : cannot access private member declared in class 'sf::NonCopyable'
1> c:\users\quincy\sfml-2.0\laurentgomila-sfml-79d5217\include\sfml\system\noncopyable.hpp(67) : see declaration of 'sf::NonCopyable::NonCopyable'
1> c:\users\quincy\sfml-2.0\laurentgomila-sfml-79d5217\include\sfml\system\noncopyable.hpp(42) : see declaration of 'sf::NonCopyable'
1> This diagnostic occurred in the compiler generated function 'sf::Window::Window(const sf::Window &)'
1>c:\users\quincy\sfml-2.0\laurentgomila-sfml-79d5217\include\sfml\graphics\rendertarget.hpp(304): error C2248: 'sf::NonCopyable::NonCopyable' : cannot access private member declared in class 'sf::NonCopyable'
1> c:\users\quincy\sfml-2.0\laurentgomila-sfml-79d5217\include\sfml\system\noncopyable.hpp(67) : see declaration of 'sf::NonCopyable::NonCopyable'
1> c:\users\quincy\sfml-2.0\laurentgomila-sfml-79d5217\include\sfml\system\noncopyable.hpp(42) : see declaration of 'sf::NonCopyable'
1> This diagnostic occurred in the compiler generated function 'sf::RenderTarget::RenderTarget(const sf::RenderTarget &)'
Now I have looked at other problems and I am not or at least I think not passing the renderwindow by value anywhere.
My code :
main.cpp
//Some includes
int main()
{
World world = World(sf::VideoMode(1280, 1024, 32), "Sfml is finaly set up properly !");
while(world.GetWindow().IsOpened())
{
double frameTime = world.GetWindow().GetFrameTime() / 1000;
std::cout << "Frametime in sec : " << frameTime;
world.Think(frameTime);
world.Draw(frameTime);
}
return EXIT_SUCCESS;
}
world.cpp / world.h
//.h
#pragma once
#include <SFML\Graphics.hpp>
#include <string>
class World
{
private:
sf::RenderWindow RenderWindow;
public:
sf::RenderWindow &GetWindow() {return RenderWindow;}
void Think(double);
void Draw(double);
World(sf::VideoMode, std::string);
~World();
};
//.cpp
#include "World.h"
World::World(sf::VideoMode videoMode, std::string title)
{
RenderWindow.Create(videoMode, title);
}
World::~World()
{
}
void World::Draw(double frameTime)
{
RenderWindow.Clear();
//Do drawing in between
RenderWindow.Display();
}
void World::Think(double frameTime)
{
sf::Event event;
while (RenderWindow.PollEvent(event))
{
// Close window : exit
if (event.Type == sf::Event::Closed)
RenderWindow.Close();
}
}
Also a small c++ question, I thought this :
sf::RenderWindow &GetWindow() {return RenderWindow;}
Would give a reference of the window and that I had to access its members with -> but it seems I have to do
while(world.GetWindow().IsOpened())
why is that ?