Hi,
First of all I have to inform you that I’m a total beginner in OpenGL I don’t even know what a shader really is.
I’m currently following a tutorial and I get the following errors:
error<#202> No matching overloaded function found: texture
error<#160> Cannot convert from: “const float” to: “out highp 4-component vector of vec4”
[ATTACH=CONFIG]723[/ATTACH]
with this code :
void SceneOpenGL::principalLoop()
{
float vertices[] = { -2.0, -2.0, -2.0, -2.0, 2.0, -2.0, 2.0, 2.0, -2.0,
-2.0, -2.0, -2.0, 2.0, -2.0, -2.0, 2.0, 2.0, -2.0 };
float textureCoord[] = {0.0, 0.0, 0.0, 1.0, 1.0, 1.0,
0.0, 0.0, 1.0, 0.0, 1.0, 1.0};
unsigned int frameRate(1000 / 50);
Uint32 debutBoucle(0), finBoucle(0), tempsEcoule(0);
// Matrices
mat4 projection;
mat4 modelview;
projection = perspective(70.0, (double)m_width / m_height, 1.0, 100.0);
modelview = mat4(1.0);
// Textures
Texture texture("../../Textures/photorealistic_crate/crate21.jpg");
texture.charger();
// Shader
Shader shaderTexture("Shaders/texture.vert", "Shaders/texture.frag");
shaderTexture.charger();
// Boucle principale
while (!m_input.terminer())
{
debutBoucle = SDL_GetTicks();
// Gestion des évènements
m_input.updateEvenements();
// Nettoyage de l'écran
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
modelview = lookAt(vec3(0, 0, 2), vec3(0, 0, 0), vec3(0, 1, 0));
glUseProgram(shaderTexture.getProgramID());
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, vertices);
glEnableVertexAttribArray(0);
glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, 0, textureCoord);
glEnableVertexAttribArray(2);
glUniformMatrix4fv(glGetUniformLocation(shaderTexture.getProgramID(), "projection"), 1, GL_FALSE, value_ptr(projection));
glUniformMatrix4fv(glGetUniformLocation(shaderTexture.getProgramID(), "modelview"), 1, GL_FALSE, value_ptr(modelview));
glBindTexture(GL_TEXTURE_2D, texture.getID());
glDrawArrays(GL_TRIANGLES, 0, 6);
glBindTexture(GL_TEXTURE_2D, 0);
glDisableVertexAttribArray(2);
glDisableVertexAttribArray(0);
glUseProgram(0);
// Actualisation de la fenêtre
SDL_GL_SwapWindow(m_window);
finBoucle = SDL_GetTicks();
tempsEcoule = finBoucle - debutBoucle;
if (tempsEcoule < frameRate)
SDL_Delay(frameRate - tempsEcoule);
}
}
Doing some “cout” debugging the problem seems to come from the line “shaderTexture.charger();” so it comes from the shaders files, however, I tried this code on another computer and it worked.
What should I do?