SFML community forums

Help => Graphics => Topic started by: poul250 on August 27, 2018, 09:42:01 pm

Title: [SOLVED] Problem with loading shader
Post by: poul250 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?
Title: Re: Problem with loading shader
Post by: NGM88 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?
Title: Re: Problem with loading shader
Post by: poul250 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.