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

Author Topic: OSX - failed to compile fragment shader  (Read 3400 times)

0 Members and 1 Guest are viewing this topic.

achpile

  • Full Member
  • ***
  • Posts: 231
    • View Profile
    • Achpile's homepage
    • Email
OSX - failed to compile fragment shader
« on: December 29, 2020, 09:32:16 am »
Good day. I'm not expirienced OSX user, so have no idea about it.

I'm getting this error:
Failed to compile fragment shader:
ERROR: 0:1: 'f' : syntax error: syntax error

Failed to compile fragment shader:
ERROR: 0:1: 'f' : syntax error: syntax error

Failed to compile fragment shader:
ERROR: 0:1: 'f' : syntax error: syntax error
 

SFML version is 2.5.1

There's no such error on Linux 32/64 nor Windows 32/64

Shaders are:

#define SHADER_INVERT                                         \
        "uniform sampler2D texture;                             " \
        "                                                       " \
        "void main() {                                          " \
        "    vec4 pixel = texture2D(texture, gl_TexCoord[0].xy);" \
        "                                                       " \
        "    pixel.r = 1.0f - pixel.r;                          " \
        "    pixel.g = 1.0f - pixel.g;                          " \
        "    pixel.b = 1.0f - pixel.b;                          " \
        "                                                       " \
        "    gl_FragColor = pixel;                              " \
        "}                                                      "



#define SHADER_WHITE                                          \
        "uniform sampler2D texture;                             " \
        "                                                       " \
        "void main() {                                          " \
        "    vec4 pixel = texture2D(texture, gl_TexCoord[0].xy);" \
        "                                                       " \
        "    pixel.r = 1.0f;                                    " \
        "    pixel.g = 1.0f;                                    " \
        "    pixel.b = 1.0f;                                    " \
        "                                                       " \
        "    gl_FragColor = pixel;                              " \
        "}                                                      "



#define SHADER_GREY                                           \
        "uniform sampler2D texture;                             " \
        "                                                       " \
        "void main() {                                          " \
        "    vec4 pixel = texture2D(texture, gl_TexCoord[0].xy);" \
        "                                                       " \
        "    gl_FragColor.r = (pixel.r+pixel.g+pixel.b) / 3.0f; " \
        "    gl_FragColor.g = gl_FragColor.r;                   " \
        "    gl_FragColor.b = gl_FragColor.r;                   " \
        "    gl_FragColor.a = pixel.a;                          " \
        "}                                                      "

 

Loading code:
        shaders.white.loadFromMemory (SHADER_WHITE , sf::Shader::Fragment);
        shaders.grey.loadFromMemory  (SHADER_GREY  , sf::Shader::Fragment);
        shaders.invert.loadFromMemory(SHADER_INVERT, sf::Shader::Fragment);
 

Bonus question bonus not related to graphics, but related to Mac OS X:
After app start i got this:
"We got a keyboard without any keys (1)"

I use Mac mini with standart usb keyboard attached

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: OSX - failed to compile fragment shader
« Reply #1 on: December 29, 2020, 09:42:59 am »
Removing the 'f' should be ok. Just '1.0' for literals.
Laurent Gomila - SFML developer

achpile

  • Full Member
  • ***
  • Posts: 231
    • View Profile
    • Achpile's homepage
    • Email
Re: OSX - failed to compile fragment shader
« Reply #2 on: December 29, 2020, 09:54:03 am »
Removing the 'f' should be ok. Just '1.0' for literals.

Oh, silly me :D Thanks Laurent. Yeah, I guess i'm way too used to put 'f' and "0:1" confused me.  :D