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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - GrimSkull

Pages: [1]
1
Window / Re: sf::NonCopyable
« on: February 06, 2013, 01:12:40 pm »
Thanks, missed that... =)

2
Window / sf::NonCopyable
« on: February 06, 2013, 11:42:08 am »
I'm trying to create one window in a static variable and using a static function to return this variable to other classes and put them in reference-variables. But I keep getting:
(error C2248: 'sf::NonCopyable::NonCopyable' : cannot access private member declared in class 'sf::NonCopyable'   ...\sfml-2.0-rc\include\sfml\window\window.hpp   476)
and:
(error C2248: 'sf::NonCopyable::NonCopyable' : cannot access private member declared in class 'sf::NonCopyable'    ...\sfml-2.0-rc\include\sfml\graphics\rendertarget.hpp   369)

Window.h
#include <SFML/Graphics.hpp>

class Window
{
public:
   Window();

   static sf::RenderWindow getWindow();

private:
   void loadWindow();
   static sf::RenderWindow mWindow;
};

Window.cpp
#include "Window.h"

sf::RenderWindow Window::mWindow;

Window::Window()
{
   loadWindow();
}

void Window::loadWindow()
{
   mWindow.create(sf::VideoMode(1280, 768), "Robot split");
}

sf::RenderWindow Window::getWindow()
{
   return mWindow;
}

In the class where I'm trying to call the function Window::getWindow() looks like this:

Game.h
sf::RenderWindow& mWindow;

Game.cpp
#include "Window.h"
Game::Game(): mWindow(Window::getWindow())

In my mind this should give the adress from the static variable in Window.cpp to a reference-variable in Game.cpp, and thus Game.cpp should be able to access the window I create in Window.cpp. Or am I totally off course?

Pages: [1]