SFML community forums

Help => Graphics => Topic started by: Princessjinifer on April 08, 2012, 06:22:27 am

Title: 'class sf::Window' has no member named 'Member' error
Post by: Princessjinifer on April 08, 2012, 06:22:27 am
With "#include SFML\Window.hpp"
Code: [Select]
'class sf::Window' has no member named 'IsOpened'
'class sf::Window' has no member named 'PollEvent'
'class sf::Window' has no member named 'Close'
'class sf::Window' has no member named 'Display'

With "#include SFML\Graphics.hpp"
Code: [Select]
'class sf::RenderWindow' has no member named 'IsOpened'
'class sf::RenderWindow' has no member named 'PollEvent'
'class sf::RenderWindow' has no member named 'Close'
'class sf::RenderWindow' has no member named 'Display'

The errors above are the 4 errors I get when trying to compile my program.. I have been talking with someone who knows about SFML and I have him stumped too. Does anyone here have any ideas for fixes?

This is the source code:

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

int main() {
sf::Window FollowCursor(sf::VideoMode(800, 600, 32), "Follow Cursor - SFML Window");

while (FollowCursor.IsOpened()) {
sf::Event FCEvent;
while (FollowCursor.PollEvent(FCEvent)) {
if (FCEvent.Type == sf::Event::Closed) {
FollowCursor.Close();
}
}

FollowCursor.Display();
}

return EXIT_SUCCESS;
}

Thanks in advance! :)
-Princessjinifer

EDIT: I fixed them... Nevermind.  I looked at http://www.sfml-dev.org/documentation/2.0/ (http://www.sfml-dev.org/documentation/2.0/) and it showed that IsOpened is actually isOpen, and PollEvent is pollEvent.. so on and so forth.. So, here is the corrected code:

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

int main() {
sf::Window FollowCursor(sf::VideoMode(800, 600, 32), "Follow Cursor - SFML Window");

while (FollowCursor.isOpen()) {
sf::Event FCEvent;
while (FollowCursor.pollEvent(FCEvent)) {
if (FCEvent.type == sf::Event::Closed) {
FollowCursor.close();
}
}

FollowCursor.display();
}

return EXIT_SUCCESS;
}
Title: Re: 'class sf::Window' has no member named 'Member' error
Post by: Tex Killer on April 08, 2012, 06:28:56 am
You are probably using a recent SFML2, wich name convention changed to camelCase for member functions.

Display, for example, should now be display, and IsOpened changed to isOpen.

For precise information, read the documentation:
http://www.sfml-dev.org/documentation/2.0/classsf_1_1RenderWindow.php
Title: Re: 'class sf::Window' has no member named 'Member' error
Post by: Princessjinifer on April 08, 2012, 06:30:29 am
You are probably using a recent SFML2, wich name convention changed to camelCase for member functions.

Display, for example, should now be display, and IsOpened changed to isOpen.

For precise information, read the documentation:
http://www.sfml-dev.org/documentation/2.0/classsf_1_1RenderWindow.php

Read the edit on my original post, I got it all figured out within minutes of posting this. Even though I have been trying to figure it out for the last two days.
Title: Re: 'class sf::Window' has no member named 'Member' error
Post by: Tex Killer on April 08, 2012, 07:08:29 am
Ok, glad you solved your problem.
Title: Re: 'class sf::Window' has no member named 'Member' error
Post by: Laurent on April 08, 2012, 08:37:28 am
Two days? The first thing you should ever do when you get an "unknown function name" error, is to check in the header or documentation if the function actually exists ;)