glShaderSource - Replaces the source code in a shader object
Contents
Associated Gets
glGetShader() with arguments shader and GL_SHADER_SOURCE_LENGTHglGetShaderSource() with argument shaderglIsShader()
C Specification
voidglShaderSource(GLuintshader,GLsizeicount,constGLchar**string,constGLint*length);
Copyright
Copyright © 2003-2005 3Dlabs Inc. Ltd.
Copyright © 2010-2014 Khronos Group
[FIXME: source] 11/18/2024 GLSHADERSOURCE(3G)
Description
glShaderSource sets the source code in shader to the source code in the array of strings specified by
string. Any source code previously stored in the shader object is completely replaced. The number of
strings in the array is specified by count. If length is NULL, each string is assumed to be null
terminated. If length is a value other than NULL, it points to an array containing a string length for
each of the corresponding elements of string. Each element in the length array may contain the length of
the corresponding string (the null character is not counted as part of the string length) or a value less
than 0 to indicate that the string is null terminated. The source code strings are not scanned or parsed
at this time; they are simply copied into the specified shader object.
Errors
GL_INVALID_VALUE is generated if shader is not a value generated by OpenGL.
GL_INVALID_OPERATION is generated if shader is not a shader object.
GL_INVALID_VALUE is generated if count is less than 0.
Name
glShaderSource - Replaces the source code in a shader object
Notes
OpenGL copies the shader source code strings when glShaderSource is called, so an application may free
its copy of the source code strings immediately after the function returns.
Parameters
shader
Specifies the handle of the shader object whose source code is to be replaced.
count
Specifies the number of elements in the string and length arrays.
string
Specifies an array of pointers to strings containing the source code to be loaded into the shader.
length
Specifies an array of string lengths.
See Also
glCompileShader(), glCreateShader(), glDeleteShader()
Version Support
┌────────────────┬───────────────────────────────────────────────────────────────────────┐
│ │ OpenGLVersion │
├────────────────┼─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┤
│ Function │ 2.0 │ 2.1 │ 3.0 │ 3.1 │ 3.2 │ 3.3 │ 4.0 │ 4.1 │ 4.2 │ 4.3 │ 4.4 │ 4.5 │
│ / │ │ │ │ │ │ │ │ │ │ │ │ │
│ Feature │ │ │ │ │ │ │ │ │ │ │ │ │
│ Name │ │ │ │ │ │ │ │ │ │ │ │ │
├────────────────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│ glShaderSource │ ✔ │ ✔ │ ✔ │ ✔ │ ✔ │ ✔ │ ✔ │ ✔ │ ✔ │ ✔ │ ✔ │ ✔ │
└────────────────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘
