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

Author Topic: Problem with sf::RenderWindow  (Read 2552 times)

0 Members and 1 Guest are viewing this topic.

Kamaitachi

  • Newbie
  • *
  • Posts: 28
    • View Profile
Problem with sf::RenderWindow
« on: March 08, 2011, 07:29:05 pm »
How can I create a sf:RenderWindow and set VideoMode after that?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Problem with sf::RenderWindow
« Reply #1 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.
Laurent Gomila - SFML developer

Kamaitachi

  • Newbie
  • *
  • Posts: 28
    • View Profile
Problem with sf::RenderWindow
« Reply #2 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?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Problem with sf::RenderWindow
« Reply #3 on: March 09, 2011, 07:55:21 am »
Code: [Select]
window.Create(sf::VideoMode(width, height), title);
Laurent Gomila - SFML developer

Kamaitachi

  • Newbie
  • *
  • Posts: 28
    • View Profile
Problem with sf::RenderWindow
« Reply #4 on: March 09, 2011, 10:08:14 am »
Just that?  :P I Okay, thank you very much.

Kamaitachi

  • Newbie
  • *
  • Posts: 28
    • View Profile
Problem with sf::RenderWindow
« Reply #5 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"...

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Problem with sf::RenderWindow
« Reply #6 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);
};
Laurent Gomila - SFML developer

Kamaitachi

  • Newbie
  • *
  • Posts: 28
    • View Profile
Problem with sf::RenderWindow
« Reply #7 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...

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Problem with sf::RenderWindow
« Reply #8 on: March 12, 2011, 10:57:21 pm »
You must link to sfml-window and sfml-graphics.
Laurent Gomila - SFML developer

Kamaitachi

  • Newbie
  • *
  • Posts: 28
    • View Profile
Problem with sf::RenderWindow
« Reply #9 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!

 

anything