SFML community forums

Help => Graphics => Topic started by: TheTud69 on September 09, 2016, 06:11:41 pm

Title: Where to learn GLSL for sfml?
Post by: TheTud69 on September 09, 2016, 06:11:41 pm
The SFML tutorial doesn't cover writing GLSL programs, and I couldn't find any on google that don't try to sink me into the depths of OpenGL. Does anyone have any source/tutorial where can I learn it fast? Only for 2D in sfml, beacause I have no idea how OpenGL looks like
Title: Re: Where to learn GLSL for sfml?
Post by: Hapax on September 10, 2016, 01:04:18 am
Why fast?

You don't need to "sink [...] into the depths of OpenGL" to write some shaders. You could look at examples and learn from those as well as constantly looking up references for things you don't understand. This method can be slower overall and you only learn what you find but it can get the initial things up and running quite quickly. You must also expect a lot of trial and error (mostly error) with this method.

The first thing you'll need to realise is that you should probably start from the minimal shaders in the SFML shaders tutorial (http://www.sfml-dev.org/tutorials/2.4/graphics-shader.php#minimal-shaders) and build from there. SFML uses some things that aren't present in most shader example, especially newer ones.

There are a couple of shader examples on the SFML wiki (https://github.com/SFML/SFML/wiki/Sources#shaders) and there are some really rather simple shaders here (https://github.com/Hapaxia/Lens/tree/master/Lens) that might help.

Consider also having a look through these:
OpenGL Shader documentation (https://www.opengl.org/documentation/glsl/)
GLSL on Wikipedia (https://en.wikipedia.org/wiki/OpenGL_Shading_Language)
GLSL tutorial (http://nehe.gamedev.net/article/glsl_an_introduction/25007/)
but note that you most probably will need to use a lower version of the language if used with SFML's Graphics module.

Why do you need shaders, if you don't mind me asking? What are you doing in 2D that you can't do without shaders? Is there a specific shader you need because it might already exist?