(see latest post)
Show differencesHistory of post edits
Posted 30 April 2013 - 02:49 PM
I forgot to include the fact that I used glUseProgram, so disableing the shader before drawing 2d by calling glUseProgram(0) fixed my problem.
One last question though, how is it that i'm able to
glDisable(GL_LIGHTING); glDisable(GL_LIGHT0); glUseProgram(shaderOne);
yet my shader still works? Is it because GL_LIGHTING only pertains to OpenGL's fixed-function lighting, and not to GLSL shaders?
Posted 30 April 2013 - 02:28 PM
I don't know how I missed this, but I am using a glsl shader and forgot to include it in my post. I use glUseProgram, but I forgot to use glDeleteProgram. But it STILL doesn't work, even with calling glDeleteProgram at the end of my 3d drawing. The updated structure is as follows:
//start 3d drawing glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glViewport(0, 0, windowWidth/1.3, windowHeight); glClearColor(0,0.5,0.5,0); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(60.0, (float)windowWidth / (float)windowHeight, 0.4, 9000.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glEnable(GL_DEPTH_TEST); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_NORMALIZE); glEnable(GL_COLOR_MATERIAL); glUseProgram(shaderOne); //draw 3d primitives + model and view transforms glDeleteProgram(shaderOne); //2D drawing glClear(GL_DEPTH_BUFFER_BIT); glViewport(windowWidth/1.3, 0, windowWidth, windowHeight); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0.0f, windowWidth, windowHeight, 0.0f, 0.0f, 1.0f); glDisable(GL_DEPTH_TEST); glDisable(GL_CULL_FACE); glDisable(GL_TEXTURE_2D); glDisable(GL_LIGHTING); //draw red triangle glPushMatrix(); glColor3f(1.0f, 0.0f, 0.0f); glBegin(GL_TRIANGLES); glVertex3f(0.0f, 0.0f, 0.0f); glVertex3f(20.0f, 20.0f, 0.0f); glVertex3f(70.0f, 20.0f, 0.0f); glEnd(); glPopMatrix(); //swap buffers glutSwapBuffers();
How is it that a glsl shader is able to keep running even when I deleted it?