glGetShaderiv () function What is the use?

Part Reprinted from
https://blog.csdn.net/flycatdeng/article/details/82667207

Today, when I learn LearnOpenGL to see this function because the final image is wrong, but do not know exactly what went wrong, found glGetShaderiv () function can be used to detect whether a shader compiler success.

Name
glGetShaderiv - returns a parameter from the shader objects

C规范
void glGetShaderiv(GLuint shader,GLenum pname,GLint *params);

Parameters
shader
specified shader object to be queried directly into the need to check shaders can be.

pname
designated parameter shader object. Acceptable symbolic name is

(. 1) GL_SHADER_TYPE:
shader_type: Type shader
is used to determine and return the shader type, if the vertex shader to return GL_VERTEX_SHADER, if returned to GL_FRAGMENT_SHADER fragment shader.

(2) GL_DELETE_STATUS:
detele Status: delete state
determines whether the shader is removed, it is returned GL_TRUE, GL_FALSE, otherwise,

(3) GL_COMPILE_STATUS:
compile_status: compiled state
for detecting the compilation is successful , the success of GL_TRUE, otherwise GL_FALSE.

(. 4) GL_INFO_LOG_LENGTH:
Information log length: log is the log of the mean, the return length of the log information shader
length for return shader log information, including the terminating null character (i.e., information required to store the log character buffer the size of the area). If the log information is not shader, the value 0 is returned.

(. 5) GL_SHADER_SOURCE_LENGTH:
SHADER_SOURCE_LENGTH: Code length shader
return source shader length, there is no return 0;

params
function will return the results stored in the third parameter input, the function obtained as a result there are many, so the individual should be placed among the third parameter, it is not void glGetShaderiv GLuint.

Error
GL_INVALID_ENUM: not an acceptable value pname.

GL_INVALID_VALUE: Shader OpenGL not generated value.

: GL_INVALID_OPERATION query pname is GL_COMPILE_STATUS, GL_INFO_LOG_LENGTH or GL_SHADER_SOURCE_LENGTH without support shader compiler (GL_SHADER_TYPE, GL_DELETE_STATUS not report this error).

GL_INVALID_OPERATION: Shader no associated shader object.

Usage examples are as follows:

     GLint result = GL_FALSE;
  	 glGetShaderiv(vertexShader,GL_COMPILE_STATUS,&result);
     if (result==GL_FALSE)
	 {
		 cout << "Compilation of vertexShader Failed!" << endl;
		 glfwTerminate();
		 return -1;
	 }

Guess you like

Origin blog.csdn.net/alexhu2010q/article/details/86068878