I have noticed a memory leak in my program, and seems like if i comment out the commented lines in the following code, the leak goes away.
The code goes like this:
groundShader->Use();
int vertexLoc = glGetAttribLocation(groundShader->Program, "InVertex");
int texCoord0Loc = glGetAttribLocation(groundShader->Program, "InTexCoord0");
glActiveTexture(GL_TEXTURE0 + 0);
glBindTexture(GL_TEXTURE_2D, c->AlphaMap->ID);
// glUniform1i(glGetUniformLocation(groundShader->Program, "AlphaMap"), 0);
/*glActiveTexture(GL_TEXTURE0 + 1);
glBindTexture(GL_TEXTURE_2D, GroundTextures[c->groundTexIDs[0]]);
glUniform1i(glGetUniformLocation(groundShader->Program, "groundRedTex"), 1);
glActiveTexture(GL_TEXTURE0 + 2);
glBindTexture(GL_TEXTURE_2D, GroundTextures[c->groundTexIDs[1]]);
glUniform1i(glGetUniformLocation(groundShader->Program, "groundGreenTex"), 2);
glActiveTexture(GL_TEXTURE0 + 3);
glBindTexture(GL_TEXTURE_2D, GroundTextures[c->groundTexIDs[2]]);
glUniform1i(glGetUniformLocation(groundShader->Program, "groundBlueTex"), 3);
glActiveTexture(GL_TEXTURE0 + 4);
glBindTexture(GL_TEXTURE_2D, GroundTextures[c->groundTexIDs[3]]);
glUniform1i(glGetUniformLocation(groundShader->Program, "groundAlphaTex"), 4);
glEnableVertexAttribArray(vertexLoc);
glEnableVertexAttribArray(texCoord0Loc);
glBindBuffer(GL_ARRAY_BUFFER, c->GroundMesh->VBO);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, c->GroundMesh->IBO);
glVertexAttribPointer(vertexLoc, 3, GL_FLOAT, GL_FALSE, sizeof(VertexCompound), 0);
glVertexAttribPointer(texCoord0Loc, 2, GL_FLOAT, GL_FALSE, sizeof(VertexCompound), (const void*)(sizeof(float) * 3));
glEnableClientState(GL_VERTEX_ARRAY);
glDrawElements(GL_TRIANGLES, c->GroundMesh->IBOSize, GL_UNSIGNED_INT, 0);
glDisableClientState(GL_VERTEX_ARRAY);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glDisableVertexAttribArray(vertexLoc);
glDisableVertexAttribArray(texCoord0Loc);*/
glUseProgram(0);
However as soon as i uncomment the line “glUniform1i(glGetUniformLocation(groundShader->Program, “AlphaMap”), 0);”, my program’s memory usage slowly creeps up. Am i doing something wrong?
(The code is for a shader that uses alpha-mapping to mix 4 different textures onto a mesh.)