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

Author Topic: sf::Window and sf::RenderWindow confusion  (Read 11502 times)

0 Members and 1 Guest are viewing this topic.

wmbuRn

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
    • Email
sf::Window and sf::RenderWindow confusion
« on: July 08, 2013, 03:27:54 am »
what is the difference between sf::Window and sf::RenderWindow ? In past tutorials [the Window module i used sf::Window command and now i switched to sf::RenderWindow). Why? Will that means that i didnt have to use sf::Window in first place and that i can simply start window tutorial with sf::RenderWindow ? And if that is true what is the point of using sf::Window in the first place when every program will need to render stuff on screen ?

with respect
wmbuRn

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: sf::Window and sf::RenderWindow confusion
« Reply #1 on: July 08, 2013, 03:50:16 am »
Did you even read through the tutorials or API documentation?

http://sfml-dev.org/tutorials/2.0/graphics-draw.php
http://sfml-dev.org/documentation/2.0/classsf_1_1RenderWindow.php

If you still don't understand, then I don't know....
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

wmbuRn

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
    • Email
Re: sf::Window and sf::RenderWindow confusion
« Reply #2 on: July 08, 2013, 04:01:08 am »
No i havent read the api, becouse i am the idiot who gets the code out of  his head. Ofcourse i read the api thousand times.

The question is why do we need sf::Window when sf::RenderWindow is much more powerfull and have everything that sf::Window have + more?

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: sf::Window and sf::RenderWindow confusion
« Reply #3 on: July 08, 2013, 04:20:31 am »
sf::Window is if someone wants to use pure opengl and just wants input and windowing, sf::RenderWindow is that plus easy to use graphics api, but if you want to use opengl in render window there will be hassle with context switching and what-not
Back to C++ gamedev with SFML in May 2023

wmbuRn

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
    • Email
Re: sf::Window and sf::RenderWindow confusion
« Reply #4 on: July 08, 2013, 04:30:55 am »
That is the answer i was looking for. Thank you FRex, you helped a lot

G.

  • Hero Member
  • *****
  • Posts: 1593
    • View Profile
Re: sf::Window and sf::RenderWindow confusion
« Reply #5 on: July 08, 2013, 05:48:51 am »
FRex's answer is pretty much what's written at the start of the tutorial linked by binary1248. ;)
Quote
Everything that you've learnt about sf::Window (creation, event handling, controlling the framerate, mixing with OpenGL, etc.) is applicable to sf::RenderWindow.
On top of that, sf::RenderWindow adds high-level functions to help you draw things easily.

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: sf::Window and sf::RenderWindow confusion
« Reply #6 on: July 08, 2013, 06:28:58 am »
The question is why do we need sf::Window when sf::RenderWindow is much more powerfull and have everything that sf::Window have + more?
If you don't understand what you just said then there is no point explaining good software development practices to you. Sometimes you don't want to use classes just because they can do more things than another class...

but if you want to use opengl in render window there will be hassle with context switching and what-not
Since sf::RenderWindow inherits from sf::Window and the only virtual function overrides are the ones that set up the RenderTarget and View, from a functionality point-of-view, sf::RenderWindow is a superset of sf::Window. As such this hassle can not exist, otherwise it would be caused by sf::Window as well. In fact because these classes support polymorphism, accessing the sf::RenderWindow by its sf::Window interface is perfectly valid.

The only TRUE difference if you only intend on using OpenGL to draw, is that sf::RenderWindow takes up more memory and requires linking in sfml-graphics as well. But since the op seems not to care about memory or linker differences, there is for the op visually no difference.
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

wmbuRn

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
    • Email
Re: sf::Window and sf::RenderWindow confusion
« Reply #7 on: July 08, 2013, 03:06:03 pm »
Quote from: binary1248
If you don't understand what you just said then there is no point explaining good software development practices to you.


Thats becouse i am an idiot and i know everything about sfml after learning it for less than 4hrs. Thank you for beeing conctructive and thank you for using good assumptions. If you understanded i was cynical.
« Last Edit: July 08, 2013, 03:08:15 pm by wmbuRn »