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

Author Topic: Missing Methods in SFML v2.0  (Read 2620 times)

0 Members and 1 Guest are viewing this topic.


  • Newbie
  • *
  • Posts: 1
    • View Profile
Missing Methods in SFML v2.0
« on: January 31, 2012, 02:43:19 am »
Hi there! I'm new with videogame programming and decided to give SFML a shot because I like the C++ programming language and the OOP.

However, I tried to start with the 1.6 version of the library but, I don't know why, it didn't work (when I tried to create a common Window it just didn't start).

So I take the version 2.0 that did work in my computer. But, the thing is, the latest tutorial is for the 1.6 version, the 2.0 version's tutorial only describe how to compile SFML source code.

Doesn't matter.

The thing is, now that I'm following the 1.6 version's tutorial, it happen to me that there are several methods that doesn't seem to exist anymore and I can't find methods to replace them =/.

I'm in the Displaying a sprite part of the tutorial, and so far I couldn't find a replacement for neither of these methods:


Thank you all for helping =D


  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Missing Methods in SFML v2.0
« Reply #1 on: January 31, 2012, 06:57:29 am »
Instead of GetFrameTime(), you have to use a sf::Clock and measure the time on your own.

sf::Input has been replaced by sf::Mouse, sf::Keyboard and sf::Joystick. Look them up in the documentation.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:


  • Jr. Member
  • **
  • Posts: 59
    • View Profile
Missing Methods in SFML v2.0
« Reply #2 on: January 31, 2012, 07:07:09 am »
Hello welcome to SFML programming.

For GetFrameTime(), it was just removed due to the new Time api. To get the escaped time you will have to use sf::Clock & sf::Time.

Code: [Select]

//Window construction
sf::Clock clock;
sf::Time escapedTime;

    escapedTime = clock.Restart();
    float fps = 1.f / escapedTime.AsSEconds();

Now for GetInput()... this one is tricky. The input has been totally remapped into sf::Keyboard, sf::Mouse, sf::Joystick. Take a look at those classes.

Best of luck.

p.s. Nexus beat me :P
CoderZilla - Everything Programming


  • Newbie
  • *
  • Posts: 23
    • View Profile
Missing Methods in SFML v2.0
« Reply #3 on: February 01, 2012, 12:37:27 pm »
I think the SFML 1.6 seem to work for the most part (at least it looks that way to me), but you have to look up the SFML 2.0 documentation for changes. SFML is actually rather simple to use, got this minimal thingy to work within like 5 minutes:

Code: [Select]

#include <SFML/Window.hpp>
#include <SFML/OpenGL.hpp>
#include <iostream>

int main()
sf::ContextSettings cs;
cs.MajorVersion = 3;
cs.MinorVersion = 3;
sf::VideoMode mode(800, 600, 32);
sf::Window window(mode, "Test", sf::Style::Default, cs);
std::cout << "Version: " << glGetString(GL_VERSION) << std::endl
<< "Shader Version: " << glGetString(GL_SHADING_LANGUAGE_VERSION)
<< std::endl;
while (window.IsOpen())
sf::Event event;
while (window.PollEvent(event))
switch (event.Type)
case sf::Event::Closed:
case sf::Event::KeyPressed:
if (event.Key.Code == sf::Keyboard::Escape)
glClearColor(1.0, 0.0, 1.0, 1.0);
return 0;

This should give you a purple-ish window (800x600) that closes on pressing escape, Oh, and you should get

Version: 3.3.<something> Compatibility Profile Context
Shader Version: 3.3<something>

on your stdout. That is, IF have a graphics card that supports OpenGL 3.3+