The problem is happening because of the way you call these two OpenGL functions.
glBegin(GL_QUADS);
... etc ...
glEnd();
After call glBegin()
you can only use the following OpenGL functions, until you call glEnd()
glVertex()
glColor()
glSecondaryColor()
glIndex()
glNormal()
glFogCoord()
glTexCoord()
glMultiTexCoord()
glVertexAttrib()
glEvalCoord()
glEvalPoint()
glArrayElement()
glMaterial()
glEdgeFlag()
It's also acceptable to use.
glCallList()
glCallLists()
So as we can see in your code you call glEnable()
, glDisable()
, glBlendFunc()
, glAlphaFunc()
and bind the texture, etc. all these things you need to do them before you call glBegin()
Extra
Also you're using deprecated OpenGL functions in case you don't know. You should learn about and use VBOs and VAOs and also learn to use the modern functions and ways of doing things in OpenGL.