1
Graphics / Re: How to use sf::Shader with multiple textures as a raw shader for OpenGL?
« on: April 03, 2019, 05:28:17 pm »
Thank you for your advice. I found my mistake.
I called sf::Shader::bind(&shader) before shader.setUniform("diffuse", texdif).
I changed code to:
I called sf::Shader::bind(&shader) before shader.setUniform("diffuse", texdif).
I changed code to:
sf::Texture texdif= model->diffusemapT;
sf::Texture texnormal = model->normalmapT;
glEnable(GL_TEXTURE_2D);
sf::Shader shader;
if (!shader.loadFromFile("Vertex_shader.glsl", "Fragment_shader.glsl")) return 0;
shader.setUniform("diffuse", texdif);
shader.setUniform("tangentnm", texnormal);
sf::Shader::bind(&shader);
But it is strange that I can call other "setUniform" rows after sf::Shader::bind, and it works. For example:sf::Texture texnormal = model->normalmapT;
glEnable(GL_TEXTURE_2D);
sf::Shader shader;
if (!shader.loadFromFile("Vertex_shader.glsl", "Fragment_shader.glsl")) return 0;
shader.setUniform("diffuse", texdif);
shader.setUniform("tangentnm", texnormal);
sf::Shader::bind(&shader);
sf::Glsl::Mat4 M1(tmp);
shader.setUniform("M", M1);
And vertex shader uses:shader.setUniform("M", M1);
uniform mat4 M;