Reference to the activated program in OpenGL?

Viewed 855

I am working with OpenGL and for some classes I wrote I would have to pass a shader, although the class is only used, when a shader is already active. Is there a way to get the currently active program from OpenGL, so a function like glGetActiveProgram()?

1 Answers

glGetIntegerv() with GL_CURRENT_PROGRAM:

GLint prog = 0;
glGetIntegerv(GL_CURRENT_PROGRAM, &prog);

Standard "querying OpenGL state isn't guaranteed to be performant" disclaimer applies.

Related