SFML community forums

Help => General => Topic started by: Kamaitachi on March 08, 2011, 07:29:05 pm

Title: Problem with sf::RenderWindow
Post by: Kamaitachi on March 08, 2011, 07:29:05 pm
How can I create a sf:RenderWindow and set VideoMode after that?
Title: Problem with sf::RenderWindow
Post by: Laurent on March 08, 2011, 07:36:54 pm
What does "create a RenderWindow" mean, without a video mode? If you want to have a sf::RenderWindow instance and later create the window, you can use the default constructor and the Create function.
Title: Problem with sf::RenderWindow
Post by: Kamaitachi on March 08, 2011, 10:35:22 pm
And how can I change the size of the window with Create()? Could you make a example, please?
Title: Problem with sf::RenderWindow
Post by: Laurent on March 09, 2011, 07:55:21 am
Code: [Select]
window.Create(sf::VideoMode(width, height), title);
Title: Problem with sf::RenderWindow
Post by: Kamaitachi on March 09, 2011, 10:08:14 am
Just that?  :P I Okay, thank you very much.
Title: Problem with sf::RenderWindow
Post by: Kamaitachi on March 12, 2011, 08:25:24 pm
I know this is kinda stupid and all, but I still figure it out: Why isn't the following code working?

Code: [Select]
#include <SFML/System.hpp>
#include <SFML/Graphics.hpp>

class Field
{
    int Farray[2][2];
    sf::RenderWindow App(sf::VideoMode(100, 100, 32), "SFML");
    public:
    Field(int x, int y) {App.Create(sf::VideoMode(x, y), "SFML");};
    void FEvent();
    void FDisplay (int, int, int);
};

void Field::FEvent ()
{
}

void Field::FDisplay (int pos1, int pos2, int pl)
{
}

int main()
{
    Field F(315, 315);
}


It says that "App was not declared in this scope"...
Title: Problem with sf::RenderWindow
Post by: Laurent on March 12, 2011, 10:03:21 pm
You can't call a constructor in a class declaration.
Code: [Select]
class Field
{
    int Farray[2][2];
    sf::RenderWindow App;
    public:
    Field(int x, int y) {App.Create(sf::VideoMode(x, y), "SFML");};
    void FEvent();
    void FDisplay (int, int, int);
};
Title: Problem with sf::RenderWindow
Post by: Kamaitachi on March 12, 2011, 10:52:43 pm
Uhm. Now I am getting a lot of undefined references, from "Undefined reference to sf::Window::Close()" to "Undefined reference to sf::RenderWindow::RenderWindow()", using your code...
Title: Problem with sf::RenderWindow
Post by: Laurent on March 12, 2011, 10:57:21 pm
You must link to sfml-window and sfml-graphics.
Title: Problem with sf::RenderWindow
Post by: Kamaitachi on March 12, 2011, 11:23:55 pm
*facepalm* I am an idiot! I thought I did that but... oh well. Anyway, thank you very much! You have been very helpful. Thank you!