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

Author Topic: SFML 2.1 and OpenGL 4.2 Cube Function  (Read 2042 times)

0 Members and 1 Guest are viewing this topic.

TriforceOfKirby

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
SFML 2.1 and OpenGL 4.2 Cube Function
« on: November 20, 2014, 02:25:56 am »
So first of all are there any good tutorials for using SFML 2.1 and OpenGL 4.2? Most seem to be pretty outdated, so I figured I would ask here for help.

So far I have a basic program that creates a window and outputs OpenGL settings used:
(click to show/hide)
If there are any tips to improve my code; that would be greatly appreciated.

I would like to start out by making a cube function, that takes a position(x,y,z), a color(RGBA), and a texture(png) as input.

Using a geometry shader, I would like to take the position to transform it into a cube; does sf::shader support geometry shaders currently?

As for the color and texture, I would like these to be optional if the other is given, or if both are given, the color is multiplied to the texture. So if only a color is given, the cube would simply be a solid color, or if just a texture is given, the texture is used as is. So I would assume I would do this using overloaded functions right?

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: SFML 2.1 and OpenGL 4.2 Cube Function
« Reply #1 on: November 20, 2014, 02:37:56 am »
So first of all are there any good tutorials for using SFML 2.1 and OpenGL 4.2? Most seem to be pretty outdated, so I figured I would ask here for help.
There are tutorials for SFML 2.1, and tutorials for OpenGL 4. There just aren't any that do both at the same time. The SFML tutorials get your environment up and running for OpenGL operation, and from there, the OpenGL tutorials will guide you through the rest. Most if not all OpenGL tutorials I consider worth reading always assume you have some sort of environment set up already and don't hold your hand through that part of the journey. You will just have to read SFML and OpenGL tutorials separately and combine them into a whole yourself, but that is the minimum that is expected of any capable programmer.

does sf::shader support geometry shaders currently?
Currently not, but in the coming weeks to month(s), after SFML 2.2 is released and when work on SFML 2.3 begins, OpenGL support is going to be enhanced a bit, and that includes geometry shader support.
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

TriforceOfKirby

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Re: SFML 2.1 and OpenGL 4.2 Cube Function
« Reply #2 on: November 20, 2014, 03:38:48 am »
There are tutorials for SFML 2.1, and tutorials for OpenGL 4. There just aren't any that do both at the same time. The SFML tutorials get your environment up and running for OpenGL operation, and from there, the OpenGL tutorials will guide you through the rest. Most if not all OpenGL tutorials I consider worth reading always assume you have some sort of environment set up already and don't hold your hand through that part of the journey. You will just have to read SFML and OpenGL tutorials separately and combine them into a whole yourself, but that is the minimum that is expected of any capable programmer.
Ok, so do you have some OpenGL 4 tutorials that you would recommend? SFML is pretty well documented here, so I don't think I will need a tutorial for that.

Currently not, but in the coming weeks to month(s), after SFML 2.2 is released and when work on SFML 2.3 begins, OpenGL support is going to be enhanced a bit, and that includes geometry shader support.
That's good news. Will there also be support for other shaders as well, such as tessellation, evaluation, and compute shaders?

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: SFML 2.1 and OpenGL 4.2 Cube Function
« Reply #3 on: November 20, 2014, 10:57:35 am »
Ok, so do you have some OpenGL 4 tutorials that you would recommend?
Just search for them with Google. The top few results should suffice. Google isn't dumb, it assigns a higher PageRank value to popular/important pages.

Will there also be support for other shaders as well, such as tessellation, evaluation, and compute shaders?
Support for geometry shaders was long overdue. Most hardware in use these days (including IGPs) support geometry shaders to some extent. Because tessellation and compute shaders became core in OpenGL 4, they require the next generation of graphics hardware in order to be supported. Hardware support for them therefore isn't as widespread as it is for geometry shaders yet.

Another point is that tessellation shaders don't really provide much functionality for 2D graphics applications. You must remember that sfml-graphics is designed almost exclusively around the assumption that it is used for 2D graphics. The very few "effects" you might be able to achieve with tessellation shaders in a 2D graphics application you would also be able to achieve through other means, and with much lower resource consumption. For the time being, there are no plans to add support for tessellation shaders or compute shaders but this might change in the distant future.

If you are really desperate for those additional shader types, just create them yourself. If you already bother reading through OpenGL 4 tutorials, you will undoubtedly encounter a section that explains how to create and manage shader and program objects on your own, not to mention the "relatively" new extension ARB_separate_shader_objects which SFML does not support. You shouldn't worry about or even use sf::Shader if you are going down the OpenGL route from the start anyway. It really isn't that hard to do that stuff yourself...
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).