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

Pages: [1]
1
Window / Control RenderWindow from another function.
« on: March 22, 2013, 08:20:22 pm »
Hi guy,  this may sound as a really simple question, but I have SFML 1.6 and I want to control my RenderWindow from another function...

////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Window.hpp>
#include <SFML/System.hpp>
#include <SFML/Graphics.hpp>
#include <iostream>

using namespace std;



int main()
{

    // Create the main window
    sf::RenderWindow App(sf::VideoMode(800, 600, 32), "Guessing Game");
    App.SetFramerateLimit(60); //Set FPS limit to 60 FPS
    //Variables
    bool atmainmenu = true;
    //End Variables

    // Start main loop
    while (App.IsOpened())
    {
        printmessage(atmainmenu);
        // Process events
        sf::Event Event;
        while (App.GetEvent(Event))
        {
            // Close window : exit
            if (Event.Type == sf::Event::Closed)
                App.Close();

            // Escape key : exit
            if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
                App.Close();
            if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::M)){

            }
            if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::F)){

            }
        }
        // Display window on screen
        App.Display();

    }
    return EXIT_SUCCESS;
}

void printmessage(bool atmainmenu)
{
    if(atmainmenu){
        //$$$$$$$################# HERE <----
    }
}
 

That is my code, but I want to control 'App' from atmainmenu. Is there anything I have to do? thanks :D

waco001

Pages: [1]