You have to ask yourself: Which class should be the owner of the render window?
There can't be two windows thus it's logical that you can't copy them around.
Now if your WindowEngine is the owner of the render window, then you just have to declare it as member variable and return it as reference.
Somewhere in the WindowEngine.hpp file:
class WindowEngine
{
// ...
sf::RenderWindow mWindow;
// ...
};
And then you'll have to change the function signature to use a reference and make use of the member variable.
sf::RenderWindow& WindowEngine::LaunchEngineWindow(void)
{
int Height = 0;
int Width = 0;
GetScreenResolution(Height,Width);
mWindow.create(sf::VideoMode(Width,Height,32),"Genesis",sf::Style::Fullscreen);
mWindow.setMouseCursorVisible(false);
mWindow.setVerticalSyncEnabled(true);
return mainWindow;
}
Also since you probably don't understand the concept of passing stuff around by-value or by-reference, I advice you to pick up a C++ and read it or at least that section. It's basic and crucial knowledge.
Thank you very much! I was still unable to get it working without a non copyable error though. >_> I'm not sure if its something having to do with the way I try to retrieve the mainWindow from the main class, or if its the method of returning it in the WindowEngine.
![Huh ???](https://www.sfml-dev.org/forums/Smileys/default/huh.gif)
I'm new to C++ in general and have been learning it for a bit now, "used to program everything in java". I understand references when sending things between methods, but sending references between classes is fairly new to me. Well, I guess. Returning something as a reference between classes is very new. As For books... I'm going to college in a month for this stuff, xD I'll get books then... providing their books are actually decent and not a complete waste of money that is.
So theres nothing I have to change to my main class then? Because it seems like its still returning the mainWindow with "return mainWindow;" and its still getting the main window with, "sf::RenderWindow mainWindow = windowEngine.LaunchEngineWindow();" Correct me if I'm wrong "and I probably am" but doesn't that still make a copy of it? I mean, At the top of the method it does say reference with the "&" but it doesn't seem to be referencing because it still throws a nice litter error into my debug box. :/
Anyways, bit thanks for the help so far! I look foreward to hearing from you again.
:EDIT:
So after some snooping, light reading, looking over examples, more light reading, and tinkering. I wound up with this:
WindowEngine.cpp
#include "stdafx.h"
#include "WindowEngine.h"
#include <WTypes.h>
sf::RenderWindow& WindowEngine::LaunchEngineWindow(void)
{
int Height = 0;
int Width = 0;
GetScreenResolution(Height,Width);
mWindow.create(sf::VideoMode(Width,Height,32),"Genesis",sf::Style::Fullscreen);
mWindow.setMouseCursorVisible(false);
mWindow.setVerticalSyncEnabled(true);
return mWindow;
}
sf::RenderWindow WindowEngine::ApplyResolutionChanges(int&Height,int&Width)
{
//Something will be here soon enough.
}
void WindowEngine::GetScreenResolution(int&Height,int&Width)
{
RECT desktop;
const HWND hDesktop = GetDesktopWindow();
GetWindowRect(hDesktop, &desktop);
Width = desktop.right;
Height = desktop.bottom;
}
WindowEngine.hpp
#ifndef WINDOWENGINE_H
#define WINDOWENGINE_H
class WindowEngine
{
sf::RenderWindow & mWindow;
public:
sf::RenderWindow& LaunchEngineWindow();
sf::RenderWindow ApplyResolutionChanges(int&Height,int&Width);
private:
void GetScreenResolution(int&Height,int&Width);
};
#endif
Fortunettely it doesn't complain about things being copied anymore. Now it just has an error about having no suitable constructor. xD "no appropriate default constructor available" *sigh something else to learn about......Gotta love these learning expiriences xD