Main Menu
Menu

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.

Show posts Menu

Topics - conleec

#1
I'm going thru an online SFML tutorial and building a very simple game. I thought as an exercise I would try to use TGUI in the project, just to expand my understanding.

Right off the bat I'm having an issue getting an instance of Gui.

In this tutorial, the small app has a Game class, a method of which creates an SFML RenderWindow dynamically like so:

Code (cpp) Select

void Game::initializeWindow() {
this->videomode.width = GAME_WIDTH;
this->videomode.height = GAME_HEIGHT;
this->window = new sf::RenderWindow(this->videomode, "My first game", sf::Style::Titlebar | sf::Style::Close);
}


Given that I have a pointer to this window object, I thought I might be able to create an accessor to it and feed it straight into the tgui::Gui initializer like so:

Code (cpp) Select

tgui::Gui gui(game.getWindow)


Or maybe even inside the Game class constructor, like this:

Code (cpp) Select

this->window = new sf::RenderWindow(this->videomode, "My first game", sf::Style::Titlebar | sf::Style::Close);
tgui::Gui gui(this->window);


How far off base am I to think that a pointer to a window object is similar to a reference to a window object, as in the online TGUI tutorial?

Code (cpp) Select

int main()
{
sf::RenderWindow window(sf::VideoMode(800, 600), "TGUI window");
window.setFramerateLimit(60);

tgui::Gui gui(&window);
...


How would one go about creating a tgui::Gui instance from a dynamically generated window within a class?

Thanks in advance for putting up with my newby-ness.

Chris