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

Author Topic: Weird errors with sf::Shader  (Read 2491 times)

0 Members and 1 Guest are viewing this topic.

mman2112

  • Newbie
  • *
  • Posts: 2
    • View Profile
Weird errors with sf::Shader
« on: May 16, 2015, 06:26:06 pm »
I've decided to try out sf::shader, however when I make even the simplest of shader programs I get errors I can't make sense of. I'm not new to GLSL, I've used it in unity.

My code is the example code from the "getting started with 2d drawing" tutorial with little modification.
the code I've added (besides initializing a simple sf:RectangleShape) is the following:

Code: [Select]
const std::string fragmentShader = "void main(){}";
shader.loadFromMemory(fragmentShader, sf::Shader::Fragment);

The expected result is a fragment shader that does nothing (I had more, but tried eliminating lines to find the root issue)

I get an unexpected error message upon running the program,
Code: [Select]
Failed to complile fragment shader:
Fragment shader failed to compile with the following errors:
ERROR: 0:1 error(#132) Syntax error: "<" parse error
ERROR: error(#273) 1 compilation errors. No code  generated

Note that there is no '<' in the code, also sometimes when I run the program it has a similar error but with a '!' indicated as the syntax error.

Also, (I don't know if this could be related) when I tried loading a shader from a file it filled the console with junk text before crashing)

the full code is the attachment.
I'm using VS2013

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Weird errors with sf::Shader
« Reply #1 on: May 16, 2015, 06:43:09 pm »
I tested your posted code and it compiles fine. Here's a screenshot of your exact code in action:


I used VS2013 with SFML 2.2 (release version).

Which version of SFML are you using? Did you build it yourself?
Is it an older version? Problem could be fixed.
Is it a newer version? Problem could have arisen since 2.2.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: Weird errors with sf::Shader
« Reply #2 on: May 16, 2015, 08:42:19 pm »
Visual Studio has a special "debugging version" of std::string that contains extra information which it uses in debug builds. You are probably mixing a debug application and release library or vice versa. Make sure the configurations match up and your application will pass the string verbatim to SFML.
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

mman2112

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Weird errors with sf::Shader
« Reply #3 on: May 18, 2015, 10:54:31 pm »
Visual Studio has a special "debugging version" of std::string that contains extra information which it uses in debug builds. You are probably mixing a debug application and release library or vice versa. Make sure the configurations match up and your application will pass the string verbatim to SFML.

Thanks so much, this did the trick.

 

anything