Hello Andrey,
I tested with the if/else for the moment but nothing is displaying.
Here is my new printTexture method. (I tried with the two vertices : mine and yours to see if something is changing).
void Cluster::printTexture(GLuint idTexture, GLfloat x, GLfloat y) {
glActiveTexture(GL_TEXTURE0);
glBindVertexArray(this->VAO[0]); //VAO[0] or VAO[1] depending on wich Vertices I'm using.
glUniform1i(this->mTagShaderHandle, 0); // this will set the variable on the shader to 0.
/*GLfloat vertices[6][4] = {
{ x, y + 32, 0.0, 0.0 },
{ x, y, 0.0, 1.0 },
{ x + 32, y, 1.0, 1.0 },
{ x, y + 32, 0.0, 0.0 },
{ x + 32, y, 1.0, 1.0 },
{ x + 32, y + 32, 1.0, 0.0 }
};*/
GLfloat vertices[6][2] = {
{ x, y + 32 },
{ x, y },
{ x + 32, y },
{ x, y + 32 },
{ x + 32, y },
{ x + 32, y + 32 }
};
glBindTexture(GL_TEXTURE_2D, idTexture);
glBindBuffer(GL_ARRAY_BUFFER, this->VBO[0]);
glBufferSubData(GL_ARRAY_BUFFER, GL_ZERO, sizeof(vertices), vertices);
glDrawArrays(GL_TRIANGLE_STRIP, GL_ZERO, 6);
glBindVertexArray(GL_ZERO);
glBindTexture(GL_TEXTURE_2D, GL_ZERO);
}
Here is how I init my vertices :
//init VAO[0] VBO[0]
glBindVertexArray(this->VAO[0]);
glBindBuffer(GL_ARRAY_BUFFER, this->VBO[0]);
glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * 6 * 4, GL_ZERO, GL_DYNAMIC_DRAW);
glEnableVertexAttribArray(GL_ZERO);
glVertexAttribPointer(GL_ZERO, 4, GL_FLOAT, GL_FALSE, 4 * sizeof(GLfloat), GL_ZERO);
glBindVertexArray(GL_ZERO);
//init VAO[1] VBO[1]
glBindVertexArray(this->VAO[1]);
glBindBuffer(GL_ARRAY_BUFFER, this->VBO[1]);
glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * 6 * 2, GL_ZERO, GL_STATIC_DRAW);
glEnableVertexAttribArray(GL_ZERO);
glVertexAttribPointer(GL_ZERO, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(GLfloat), GL_ZERO);
glBindVertexArray(GL_ZERO);
And the shader here :
const char gVertexShader[] =
"#version 320 es\n"
"layout (location = 0) in vec4 vertex;\n"
"out vec2 TexCoords;\n"
"uniform mat4 projection;\n"
"uniform int tag;"
"void main() {\n"
" gl_Position = projection * vec4(vertex.xy, 0.0, 1.0);\n"
" if (tag > 0) {\n"
" TexCoords = vertex.zw;\n"
" } else {\n"
" TexCoords = vertex.xy;\n"
" }\n"
"}\n";
On my main I'm just trying to print a texture for the moment but nothing appears...
I don't know if it could be the glActivityTexture or the Slot ID of where the texture is bound...
Do you have an idea ? Thank you for your effort.