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

Author Topic: Annoying error when I try to build my game, help please  (Read 2810 times)

0 Members and 1 Guest are viewing this topic.

louie

  • Newbie
  • *
  • Posts: 19
    • View Profile
    • Email
Annoying error when I try to build my game, help please
« on: September 02, 2015, 12:06:35 pm »
So I get this weird error:
||=== Build: Debug in test (compiler: GNU GCC Compiler) ===|
C:\Games\SFML Games\Test\main.cpp||In function 'int main()':|
C:\Games\SFML Games\Test\main.cpp|15|error: use of deleted function 'sf::RenderWindow::RenderWindow(const sf::RenderWindow&)'|
C:\Program Files\SFML-2.3.1\include\SFML\Graphics\RenderWindow.hpp|44|note: 'sf::RenderWindow::RenderWindow(const sf::RenderWindow&)' is implicitly deleted because the default definition would be ill-formed:|
C:\Program Files\SFML-2.3.1\include\SFML\Graphics\RenderWindow.hpp|44|error: use of deleted function 'sf::Window::Window(const sf::Window&)'|
C:\Program Files\SFML-2.3.1\include\SFML\Window\Window.hpp|57|note: 'sf::Window::Window(const sf::Window&)' is implicitly deleted because the default definition would be ill-formed:|
C:\Program Files\SFML-2.3.1\include\SFML\System\NonCopyable.hpp|67|error: 'sf::NonCopyable::NonCopyable(const sf::NonCopyable&)' is private|
C:\Program Files\SFML-2.3.1\include\SFML\Window\Window.hpp|57|error: within this context|
C:\Program Files\SFML-2.3.1\include\SFML\Graphics\RenderWindow.hpp|44|error: use of deleted function 'sf::RenderTarget::RenderTarget(const sf::RenderTarget&)'|
C:\Program Files\SFML-2.3.1\include\SFML\Graphics\RenderTarget.hpp|51|note: 'sf::RenderTarget::RenderTarget(const sf::RenderTarget&)' is implicitly deleted because the default definition would be ill-formed:|
C:\Program Files\SFML-2.3.1\include\SFML\System\NonCopyable.hpp|67|error: 'sf::NonCopyable::NonCopyable(const sf::NonCopyable&)' is private|
C:\Program Files\SFML-2.3.1\include\SFML\Graphics\RenderTarget.hpp|51|error: within this context|
C:\Games\SFML Games\Test\gameloop.hpp|10|error:   initializing argument 1 of 'void MAIN_GAME_LOOP(sf::RenderWindow)'|
||=== Build failed: 8 error(s), 0 warning(s) (0 minute(s), 1 second(s)) ===|
 
This is my code:
main.cpp:
#include <SFML/Graphics.hpp>
#include "states.hpp"
#include "menus.hpp"
#include "gameloop.hpp"

#define WINDOW_WIDTH 640
#define WINDOW_HEIGHT 480

int main()
{
    sf::RenderWindow window(sf::VideoMode(WINDOW_WIDTH, WINDOW_HEIGHT), "Game");

    INIT_MENUS();

    MAIN_GAME_LOOP(window);

    return EXIT_SUCCESS;
}
 
gameloop.cpp(where the MAIN_GAME_LOOP and INIT_MENUS functions come from)
#include "gameloop.hpp"

void INIT_MENUS()
{
    Game::MenuButton start_button1("Start", 25, 150, 35, 20, Game::State::States::MAIN_MENU);

    manager.addButton(start_button1);
}

void MAIN_GAME_LOOP(sf::RenderWindow w)
{
    while (w.isOpen())
    {
        sf::Event e;
        while (w.pollEvent(e))
        {
            if (e.type == sf::Event::Closed)
            {
                w.close();
            }
        }
        manager.Update(w);
    }
}
 
I have no idea why I get this error, help please?

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Annoying error when I try to build my game, help please
« Reply #1 on: September 02, 2015, 12:15:57 pm »
Please post in the help forum, the description of General Discussions is explicitly "For everything that is not a help request".

You cannot copy sf::RenderWindow, pass it to the function by reference.

I would also avoid #define for constants, global variables and ALL_CAPS for function names...
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

louie

  • Newbie
  • *
  • Posts: 19
    • View Profile
    • Email
Re: Annoying error when I try to build my game, help please
« Reply #2 on: September 03, 2015, 03:35:04 am »
Please post in the help forum, the description of General Discussions is explicitly "For everything that is not a help request".

You cannot copy sf::RenderWindow, pass it to the function by reference.

I would also avoid #define for constants, global variables and ALL_CAPS for function names...
Sorry.
Well, thanks, I passed it by reference and now it's working. I changed the parameters of those functions from:
void MAIN_GAME_LOOP(sf::RenderWindow w)
to
void MAIN_GAME_LOOP(sf::RenderWindow& w)

 

anything