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 - LapertuS

Pages: [1]
1
Yeah completely missed that, this is fixed now, but still same error occurs.

2
        sfml-window-d-2.dll!00007ff8eba77cf3()  Unknown
>       Poker.exe!GUI_Menu::function() Line 40  C++
        [External Code]
        tgui-d.dll!tgui::Signal::operator()(unsigned int __formal) Line 77      C++
        tgui-d.dll!tgui::Signal::operator()<sf::String>(unsigned int count, const sf::String & value) Line 262  C++
        tgui-d.dll!tgui::SignalWidgetBase::sendSignal<sf::String>(std::basic_string<char,std::char_traits<char>,std::allocator<char> > && name, sf::String <args_0>) Line 502   C++
        tgui-d.dll!tgui::Button::leftMouseReleased(float x, float y) Line 216   C++
        tgui-d.dll!tgui::Container::handleEvent(sf::Event & event) Line 741     C++
        tgui-d.dll!tgui::Gui::handleEvent(sf::Event event) Line 206     C++
        Poker.exe!Game::GameLoop() Line 42      C++
        Poker.exe!main() Line 7 C++
        [External Code]
 

3
I'm building a game and currently i'm working on GUI. Problem is that, when I use sf::RenderWindow.close() inside callback, which is called when I click on GUI button, then program crashes and Visual Studio gives me following errors. I'm using TGUI library.

First-chance exception at 0x00007FFC53F57CF3 (sfml-window-d-2.dll) in Poker.exe: 0xC0000005: Access violation reading location 0x0000009900000113.
Unhandled exception at 0x00007FFC53F57CF3 (sfml-window-d-2.dll) in Poker.exe: 0xC0000005: Access violation reading location 0x0000009900000113.

GUI_Menu.cpp, where I call window.close()

#include "GUI_Menu.h"

void GUI_Menu::InitalizeMenuWidgets()
{
        gui.setWindow(this->window);
       
        this->playButton = std::make_shared<tgui::Button>();
        this->quitButton = std::make_shared<tgui::Button>();

        auto _width = tgui::bindWidth(this->gui);
        auto _height = tgui::bindHeight(this->gui);

        auto _buttonHeight = _height / 9;
        auto _buttonWidth = _width / 2;

        this->playButton->setSize(_buttonWidth, _buttonHeight);
        this->quitButton->setSize(_buttonWidth, _buttonHeight);

        this->playButton->setPosition(_width/4, _height * 1.5/10);
        this->quitButton->setPosition(_width / 4, _height * 3/10);
       

        this->playButton->setText("Play");
        this->quitButton->setText("Quit");

        this->quitButton->connect("pressed", &GUI_Menu::function, this);
        gui.add(playButton);
        gui.add(quitButton);

       

}

void GUI_Menu::function() {
        std::cout << "DEBUG";
        this->window.close();
}

 

GUI_Menu.h
#ifndef GUI_MENU_H
#define GUI_MENU_H


#include "GUI.h"
#include <iostream>

class GUI_Menu
{
       
        private:
                void function();

                sf::RenderWindow &window;
                tgui::Gui &gui;
                tgui::Button::Ptr playButton;
                tgui::Button::Ptr quitButton;


        public:
                GUI_Menu(sf::RenderWindow &window, tgui::Gui &gui) : window(window), gui(gui){ InitalizeMenuWidgets(); }
               
                void InitalizeMenuWidgets();
       
};
               

#endif

game.cpp, where my game loop runs.
#include "game.h"


Game::Game()
{
        //Initalization
        window.create(sf::VideoMode(700, 400), "Poker Game");
        gui.setWindow(window);

        GUI_Menu(this->window, this->gui);
       
        this->isFullScreen = true;

}



void Game::GameLoop()
{
        while (window.isOpen())
        {
                sf::Event event;
                while (window.pollEvent(event))
                {
                        switch (event.type)
                        {
                                case sf::Event::KeyReleased:
                                        switch (event.key.code)
                                                case sf::Keyboard::Return:
                                                        this->ToggleFullScreen();
                                        break;


                                case sf::Event::Closed:
                                        window.close();
                                        break;
                               
                                       
                        }
                       
                        gui.handleEvent(event);
                }
                window.clear();
                gui.draw();
                window.display();

        }
}

void Game::ToggleFullScreen()
{
        if (this->isFullScreen){
                window.create(sf::VideoMode(700, 400), "Poker Game", sf::Style::Default);
                this->isFullScreen = false;}
       
       
        else{
                window.create(sf::VideoMode(1920, 1080), "Poker Game", sf::Style::Fullscreen);
                this->isFullScreen = true;}

}


Pages: [1]