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

Author Topic: [SOLVED] Problem with loading shader  (Read 1981 times)

0 Members and 1 Guest are viewing this topic.

poul250

  • Newbie
  • *
  • Posts: 2
    • View Profile
[SOLVED] Problem with loading shader
« on: August 27, 2018, 09:42:01 pm »
I tried to load the shader using the loadFromMemory function, but the console produces a strange error. Here is my code:
#include <string>
#include <SFML/Graphics.hpp>

using namespace sf;

int main()
{
    RenderWindow window(VideoMode(800, 600), "SFML", Style::Close);

    const std::string shade = "void main(){}";
    Shader shader;
    if (!shader.loadFromMemory(shade, Shader::Fragment)) {
        exit(-1);
    }

    return 0;
}
 
Here is console output:
Failed to compile fragment shader:
0(1) : error C0000: syntax error, unexpected $undefined at token "<undefined>"
 
How can I fix this?
« Last Edit: August 28, 2018, 02:20:40 pm by poul250 »

NGM88

  • Full Member
  • ***
  • Posts: 162
    • View Profile
Re: Problem with loading shader
« Reply #1 on: August 28, 2018, 12:42:00 pm »
I don't get an error compiling the same code. You're sure sfml is linked correctly?

poul250

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Problem with loading shader
« Reply #2 on: August 28, 2018, 01:40:34 pm »
Oh, thanks, I solved my problem. I'm using Visual Studio c++, and in Project Settings->Linker->Input->additional dependences in Debug configuration i've used sfml-graphics.lib instead of sfml-graphics-d.lib.