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

Author Topic: Do I need to set a GLSL version from the SFML library?  (Read 1381 times)

0 Members and 1 Guest are viewing this topic.

IronAttorney

  • Newbie
  • *
  • Posts: 2
    • View Profile
Do I need to set a GLSL version from the SFML library?
« on: September 22, 2020, 09:26:40 pm »
For about a month on and off I've been trying to find out how GLSL versions work in SFML. Do I need to use something in the SFML API to set a GLSL version? Or is SFML built to use a specific GLSL version? I've tried googling this for a while, and have just been searching this forum, and the closest I get to answers never seem to shed any light on this. I've tried just setting arbitrary versions of GLSL using the `#version` preprocessor in my shaders as well, but every one I've tried throws an error...

First post here, thanks in advance for your patience,

Pete

fallahn

  • Sr. Member
  • ****
  • Posts: 492
  • Buns.
    • View Profile
    • Trederia
Re: Do I need to set a GLSL version from the SFML library?
« Reply #1 on: September 23, 2020, 12:37:05 pm »
Assuming you're talking about the graphics part of SFML (ie not just using it to create a window/context, but to draw things too) I always use #version 120 as the GLSL preprocessor. In my experience Windows can be quite forgiving with version numbers (and compatability contexts) but macOS and linux are pretty strict about adhering to OpenGL 2.1 / GLSL 120.

IronAttorney

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Do I need to set a GLSL version from the SFML library?
« Reply #2 on: September 24, 2020, 03:07:22 pm »
That's right yeah, using the SFML graphics library but writing custom shaders to call `draw()` with.

Is there something in the way SFML library is written or compiled that means it relies on GLSL version 120 when using the SFML graphics library on unix OS's?

fallahn

  • Sr. Member
  • ****
  • Posts: 492
  • Buns.
    • View Profile
    • Trederia
Re: Do I need to set a GLSL version from the SFML library?
« Reply #3 on: September 24, 2020, 04:06:39 pm »
As I understand it, it's down to the graphics driver implementation. SFML requests that it uses OpenGL 2.1 and, arguably quite correctly, that's all macOS and linux drivers will give you (when working with SFML graphics specifically). Linux drivers may vary however, but Apple have always been quite strict. On windows it seems that GPU manufacturers are willing to just return the highest, backwardly compatible, OpenGL context available. As long as you make sure to target OpenGL 2.1 / GLSL 120 in your own code you shouldn't run in to problems. As an example I once spent some time writing OpenGL3.2 code on Windows which ran fine, only to discover my application wouldn't run on macOS or linux... :(

 

anything