I've been noticing a small memory leak in my program and I've finally been able to track down the problem.
What i'm doing is drawing out 5 rectangles to the screen by calling this function:
bool OpenGlEntity::fillRect(SDL_Rect rect, float R, float G, float B, float A){
glPushMatrix();
glDisable(GL_TEXTURE_2D);
GLfloat vertices_position[] = {
(GLfloat)rect.x, (GLfloat)rect.y,
(GLfloat)(rect.x+rect.w), (GLfloat)rect.y,
(GLfloat)(rect.x+rect.w), (GLfloat)(rect.y+rect.h),
(GLfloat)rect.x, (GLfloat)(rect.y+rect.h),
};
glTranslatef(0, 0, 0);
//scale
glScalef(1,1,1);
//set color
glColor4f(R, G, B, A);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, vertices_position);
glLockArraysEXT(0, 4);
glDrawArrays(GL_QUADS, 0, 4);
glUnlockArraysEXT();
glDisableClientState(GL_VERTEX_ARRAY);
glEnable(GL_TEXTURE_2D);
//reset color
glColor4f(1.f, 1.f, 1.f, 1.f);
glPopMatrix();
return true;}
If i never run "glDisable(GL_TEXTURE_2D);" (or "glEnable(GL_TEXTURE_2D);") the leak doesn't occur. Why is this?
For me it doesn't many any sense, but then again i'm not that experienced in OpenGL rendering.