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

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

0 Members and 1 Guest are viewing this topic.

Drakeness

  • 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:

sf::RenderWindow::GetFrameTime()
sf::RenderWindow::GetInput()

Thank you all for helping =D

Nexus

  • 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:

coolhome

  • 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.

Example:
Code: [Select]

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

while(App.IsOpen())
{
    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

HKei

  • 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);
window.SetActive(true);
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:
window.Close();
break;
case sf::Event::KeyPressed:
if (event.Key.Code == sf::Keyboard::Escape)
{
window.Close();
}
break;
default:
break;
}
}
glClearColor(1.0, 0.0, 1.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
window.Display();
}
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+

 

anything