### glUseProgram - Install Program Object Source: https://docs.gl/es2/glUseProgram Installs a program object as part of the current rendering state. This function takes the handle of the program object to be used. ```c void glUseProgram( GLuint program ); ``` -------------------------------- ### Install Program Object - OpenGL Source: https://docs.gl/gl4/glUseProgram Installs a program object as part of the current rendering state. This function takes a program object handle as input and makes it active for subsequent rendering calls. If the program handle is 0, the current rendering state refers to an invalid program object. ```c #include void activateProgram(GLuint program) { glUseProgram(program); } ``` -------------------------------- ### glUseProgram Source: https://docs.gl/gl3/glUseProgram Installs a program object as part of the current rendering state. ```APIDOC ## glUseProgram ### Description Installs a program object as part of current rendering state. ### Method `void glUseProgram(GLuint program)` ### Parameters #### Path Parameters - `program` (GLuint) - Specifies the handle of the program object whose executables are to be used as part of current rendering state. ``` -------------------------------- ### Get Uniform Buffer Range Start (GL_UNIFORM_BUFFER_START) Source: https://docs.gl/gl3/glGet Retrieves the start offset of the binding range for an indexed uniform buffer binding. The initial value is 0. ```c GLuint64 startOffset; glGetInteger64i_v(GL_UNIFORM_BUFFER_START, index, &startOffset); ``` -------------------------------- ### Get Transform Feedback Buffer Range Start (GL_TRANSFORM_FEEDBACK_BUFFER_START) Source: https://docs.gl/gl3/glGet Retrieves the start offset of the binding range for a transform feedback attribute stream using indexed variants. The initial value is 0. ```c GLuint64 startOffset; glGetInteger64i_v(GL_TRANSFORM_FEEDBACK_BUFFER_START, index, &startOffset); ``` -------------------------------- ### glUseProgram Source: https://docs.gl/gl4/glUseProgram Installs a program object as part of the current rendering state. ```APIDOC ## glUseProgram ### Description Installs a program object as part of the current rendering state. ### Method `void glUseProgram(GLuint program);` ### Endpoint N/A (This is a client-side OpenGL function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ``` // Not applicable for this function ``` ### Response #### Success Response (200) None (void function) #### Response Example ``` // Not applicable for this function ``` ``` -------------------------------- ### Queries Source: https://docs.gl/es2/glShaderSource Functions for performing queries in OpenGL. Includes functions for conditional rendering, starting and stopping queries, and getting query results. ```APIDOC ## Queries This section lists OpenGL functions related to queries. - glBeginConditionalRender - glBeginQuery - glBeginQueryIndexed - glCreateQueries - glDeleteQueries - glEndConditionalRender - glEndQuery - glEndQueryIndexed - glGenQueries - glGetQueryIndexed - glGetQueryObject - glGetQueryObjectuiv - glGetQueryiv - glIsQuery - glQueryCounter ``` -------------------------------- ### glUseProgram Source: https://docs.gl/gl4/glUseProgram Installs the program object specified by _`program`_ as part of current rendering state. A program object contains executables for vertex, geometry, and fragment processors. ```APIDOC ## glUseProgram ### Description Installs the program object specified by _`program`_ as part of current rendering state. One or more executables are created in a program object by successfully attaching shader objects to it with glAttachShader, successfully compiling the shader objects with glCompileShader, and successfully linking the program object with glLinkProgram. A program object will contain an executable that will run on the vertex processor if it contains one or more shader objects of type `GL_VERTEX_SHADER` that have been successfully compiled and linked. A program object will contain an executable that will run on the geometry processor if it contains one or more shader objects of type `GL_GEOMETRY_SHADER` that have been successfully compiled and linked. Similarly, a program object will contain an executable that will run on the fragment processor if it contains one or more shader objects of type `GL_FRAGMENT_SHADER` that have been successfully compiled and linked. While a program object is in use, applications are free to modify attached shader objects, compile attached shader objects, attach additional shader objects, and detach or delete shader objects. None of these operations will affect the executables that are part of the current state. However, relinking the program object that is currently in use will install the program object as part of the current rendering state if the link operation was successful (see glLinkProgram ). If the program object currently in use is relinked unsuccessfully, its link status will be set to `GL_FALSE`, but the executables and associated state will remain part of the current state until a subsequent call to `glUseProgram` removes it from use. After it is removed from use, it cannot be made part of current state until it has been successfully relinked. If _`program`_is zero, then the current rendering state refers to an _invalid_ program object and the results of shader execution are undefined. However, this is not an error. If _`program`_does not contain shader objects of type`GL_FRAGMENT_SHADER` , an executable will be installed on the vertex, and possibly geometry processors, but the results of fragment shader execution will be undefined. ### Method `GL_CURRENT_PROGRAM` ### Endpoint Not applicable (OpenGL function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **program** (GLuint) - Required - The program object to be installed or zero to disable the current program. ### Request Example ```c++ // Assuming 'myProgram' is a valid program object ID glUseProgram(myProgram); // To disable the current program glUseProgram(0); ``` ### Response #### Success Response (No explicit return value, state change) This function does not return a value. Its effect is to change the current rendering state. #### Response Example N/A ### Errors - `GL_INVALID_VALUE` is generated if _`program`_is neither 0 nor a value generated by OpenGL. - `GL_INVALID_OPERATION` is generated if _`program`_is not a program object. - `GL_INVALID_OPERATION` is generated if _`program`_could not be made part of current state. - `GL_INVALID_OPERATION` is generated if transform feedback mode is active. ### Associated Gets - `glGet` with the argument `GL_CURRENT_PROGRAM` - `glGetActiveAttrib` with a valid program object and the index of an active attribute variable - `glGetActiveUniform` with a valid program object and the index of an active uniform variable - `glGetAttachedShaders` with a valid program object - `glGetAttribLocation` with a valid program object and the name of an attribute variable - `glGetProgram` with a valid program object and the parameter to be queried - `glGetProgramInfoLog` with a valid program object - `glGetUniform` with a valid program object and the location of a uniform variable - `glGetUniformLocation` with a valid program object and the name of a uniform variable - `glIsProgram` ### Tutorials - Anton Gerdelan - Cube Maps: Sky Boxes and Environment Mapping - Anton Gerdelan - Vertex Buffer Objects - open.gl - Framebuffers - open.gl - Geometry Shaders ### Version Support | OpenGL Version | 2.0 | 2.1 | 3.0 | 3.1 | 3.2 | 3.3 | 4.0 | 4.1 | 4.2 | 4.3 | 4.4 | 4.5 | |---|---|---|---|---|---|---|---|---|---|---|---|---| | `glUseProgram` | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ### See Also `glAttachShader`, `glBindAttribLocation`, `glCompileShader`, `glCreateProgram`, `glDeleteProgram`, `glDetachShader`, `glLinkProgram`, `glUniform`, `glValidateProgram`, `glVertexAttrib` ``` -------------------------------- ### Shaders API Source: https://docs.gl/gl4/glIsProgramPipeline This section provides documentation for shader and program management, including creation, compilation, linking, and uniform handling. ```APIDOC ## Shaders API ### Description Functions for creating, compiling, linking, and managing shader programs and individual shader objects, including setting uniform variables and querying information. ### glCreateShader #### Description Creates a shader object. ### glShaderSource #### Description Sets the source code for a shader object. ### glCompileShader #### Description Compiles a shader object. ### glCreateProgram #### Description Creates an empty program object. ### glAttachShader #### Description Attaches a shader object to a program object. ### glLinkProgram #### Description Links a program object. ### glUseProgram #### Description Installs a program object as part of current rendering state. ### glGetUniformLocation #### Description Gets the location of an active uniform variable. ### glUniformMatrix4fv #### Description Specify the value of a uniform matrix. ### glGetProgramInfoLog #### Description Returns the information log for a program object. ### glGetShaderInfoLog #### Description Returns the information log for a shader object. ### glIsProgram #### Description Determines if a name corresponds to a program object. ### glIsShader #### Description Determines if a name corresponds to a shader object. ``` -------------------------------- ### Get Program Resource Location (GLSL) Source: https://docs.gl/gl4/glGetProgramResourceLocation This example demonstrates how to use glGetProgramResourceLocation to find the location of a uniform variable named 'modelViewMatrix' in a shader program. ```GLSL #version 300 es uniform mat4 modelViewMatrix; void main() { // ... shader code ... } ``` ```C #include // Assuming 'program' is a valid and linked shader program ID GLint location = glGetProgramResourceLocation(program, GL_UNIFORM, "modelViewMatrix"); if (location == -1) { // Handle error: uniform not found or not active } ``` -------------------------------- ### glMapBufferRange Usage Example (Conceptual) Source: https://docs.gl/gl3/glMapBufferRange This snippet illustrates the conceptual usage of glMapBufferRange in C/C++ to map a buffer object. It demonstrates setting up parameters like target, offset, length, and access flags, and handling the returned pointer. Note: This is a conceptual example and may require specific OpenGL context and buffer setup. ```c #include // Assume bufferID is a valid buffer object name, and context is active. GLuint bufferID = /* ... */; size_t offset = 0; size_t length = 1024; GLbitfield accessFlags = GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT; // Bind the buffer to a target glBindBuffer(GL_ARRAY_BUFFER, bufferID); // Map the buffer range void* mappedData = glMapBufferRange(GL_ARRAY_BUFFER, offset, length, accessFlags); if (mappedData) { // Data is now accessible via the mappedData pointer. // Perform read/write operations as permitted by accessFlags. // For example, to write data: // memcpy(mappedData, newData, length); // If GL_MAP_FLUSH_EXPLICIT_BIT was used, explicitly flush: // glFlushMappedBufferRange(GL_ARRAY_BUFFER, offset, length); // Unmap the buffer glUnmapBuffer(GL_ARRAY_BUFFER); } else { // Mapping failed, handle error. // Check glGetError() for specific OpenGL errors. } // Unbind the buffer (optional, depending on usage) // glBindBuffer(GL_ARRAY_BUFFER, 0); ``` -------------------------------- ### OpenGL Tutorials Source: https://docs.gl/gl4/glVertexAttribPointer A list of tutorials covering various aspects of OpenGL programming, from basic triangle rendering to advanced techniques like instancing and normal mapping. ```APIDOC ## Tutorials - **Anton Gerdelan - "Hello Triangle" - OpenGL 4 Up and Running** - **Anton Gerdelan - Cube Maps: Sky Boxes and Environment Mapping** - **Anton Gerdelan - Vertex Buffer Objects** - **Learning Modern 3D Graphics Programming - Chapter 5. Objects in Depth [Vertex Array Objects, Indexed Drawing]** - **open.gl - Geometry Shaders** - **open.gl - Textures Objects and Parameters** - **open.gl - The Graphics Pipeline** - **open.gl - Transform Feedback** - **opengl-tutorial.org - Particles / Instancing** - **opengl-tutorial.org - Tutorial 13 : Normal Mapping** - **opengl-tutorial.org - Tutorial 2 : The first triangle** - **opengl-tutorial.org - Tutorial 4 : A Colored Cube** - **opengl-tutorial.org - Tutorial 8 : Basic shading** ``` -------------------------------- ### Get Uniform Buffer Offset (OpenGL) Source: https://docs.gl/gl4/glGet Retrieves the start offset of the binding range for each indexed uniform buffer binding. Returns 0 initially for all bindings. Used with glGetInteger64i_v. ```c GLint64 offset; glGetInteger64i_v(GL_UNIFORM_BUFFER_START, index, &offset); ``` -------------------------------- ### OpenGL Tutorials Source: https://docs.gl/gl4/glBindBuffer A curated list of tutorials for learning OpenGL programming, covering foundational concepts to advanced techniques. ```APIDOC ## OpenGL Tutorials This section lists various tutorials for learning OpenGL: * **Hello Triangle** - OpenGL 4 Up and Running * **Cube Maps: Sky Boxes and Environment Mapping** * **Vertex Buffer Objects** * **Objects in Depth** (Vertex Array Objects, Indexed Drawing) * **OpenGL Pixel Buffer Object (PBO)** * **Geometry Shaders** * **The Graphics Pipeline** * **Transform Feedback** * **Particles / Instancing** * **Normal Mapping** * **Render To Texture** * **The first triangle** * **A Colored Cube** * **Basic shading** ``` -------------------------------- ### Shaders API Source: https://docs.gl/gl3/glPassThrough Functions for creating, compiling, linking, and managing shader programs. ```APIDOC ## Shaders API ### Description Functions for managing shader objects and program objects, including compilation, linking, and uniform manipulation. ### Methods GET, POST, PUT, DELETE (Conceptual for API operations) ### Endpoints N/A (These are function calls, not HTTP endpoints) ### Functions - **glAttachShader**: Attaches a shader object to a program object. - **glBindAttribLocation**: Binds a user-defined attribute variable to a generic vertex attribute index. - **glBindFragDataLocation**: Binds the user-defined varying variable to a fragment shader color number. - **glBindFragDataLocationIndexed**: Binds the user-defined varying variable to a fragment shader color number and index. - **glCompileShader**: Compiles (or re-compiles) a shader object. - **glCreateProgram**: Creates an empty program object. - **glCreateShader**: Creates an empty shader object. - **glCreateShaderProgram**: Creates a program object from a set of shaders. - **glDeleteProgram**: Deletes a program object. - **glDeleteShader**: Deletes a shader object. - **glDetachShader**: Detaches a shader object from a program object. - **glGetActiveAtomicCounterBufferiv**: Returns information about the active atomic counter buffer bindings. - **glGetActiveAttrib**: Returns information about the active attributes of a program object. - **glGetActiveSubroutineName**: Returns the name of an active subroutine. - **glGetActiveSubroutineUniform**: Returns information about an active subroutine uniform. - **glGetActiveSubroutineUniformName**: Returns the name of an active subroutine uniform. - **glGetActiveUniform**: Returns information about an active uniform variable. - **glGetActiveUniformBlock**: Returns information about an active uniform block. - **glGetActiveUniformBlockName**: Returns the name of an active uniform block. - **glGetActiveUniformBlockiv**: Returns parameters of an active uniform block. - **glGetActiveUniformName**: Returns the name of an active uniform variable. - **glGetActiveUniformsiv**: Returns information about active uniform variables. - **glGetAttachedShaders**: Returns the names of the shader objects attached to a program object. - **glGetAttribLocation**: Returns the location of an attribute variable. - **glGetFragDataIndex**: Returns the index of the fragment shader color mask. - **glGetFragDataLocation**: Returns the location of a user-defined varying variable. - **glGetProgram**: Returns parameters of a program object. - **glGetProgramBinary**: Returns the binary representation of a program object. - **glGetProgramInfoLog**: Returns the information log for a program object. - **glGetProgramResource**: Returns properties of an active resource in program object. - **glGetProgramResourceIndex**: Returns the index of an active resource in program object. - **glGetProgramResourceLocation**: Returns the location of an active resource in program object. - **glGetProgramResourceLocationIndex**: Returns the index of an active resource in program object. - **glGetProgramResourceName**: Returns the name of an active resource in program object. - **glGetProgramStage**: Returns the shader stage for a program object. - **glGetProgramiv**: Returns parameters of a program object. - **glGetShader**: Returns parameters of a shader object. - **glGetShaderInfoLog**: Returns the information log for a shader object. - **glGetShaderPrecisionFormat**: Returns the range and precision for the available range of a shader numeric format. - **glGetShaderSource**: Returns the source code of a shader object. - **glGetShaderiv**: Returns parameters of a shader object. - **glGetSubroutineIndex**: Returns the index of a subroutine. - **glGetSubroutineUniformLocation**: Returns the location of a subroutine uniform. - **glGetUniform**: Returns the value of a uniform variable. - **glGetUniformBlockIndex**: Returns the index of a uniform block. - **glGetUniformIndices**: Returns the indices of a block of uniform variables. - **glGetUniformLocation**: Returns the location of a uniform variable. - **glGetUniformSubroutine**: Returns the index of the subroutine for a given uniform subroutine variable. - **glIsProgram**: Determines if a name corresponds to a program object. - **glIsShader**: Determines if a name corresponds to a shader object. - **glLinkProgram**: Links a program object. - **glMinSampleShading**: Sets the minimum sample shading rate for multisample fragment operations. - **glProgramBinary**: Loads a program object using a binary file. - **glProgramParameter**: Sets a parameter of a program object. - **glProgramParameteri**: Sets a parameter of a program object. - **glProgramUniform**: Sets the value of a uniform variable in the active program object. - **glReleaseShaderCompiler**: Releases the compiler for all active shader objects. - **glShaderBinary**: Loads a shader object using a binary file. - **glShaderSource**: Sets the source code of a shader object. - **glShaderStorageBlockBinding**: Assigns a buffer object to a shader storage block binding point. - **glUniform**: Sets the value of a uniform variable. - **glUniformBlockBinding**: Assigns a buffer object to a uniform block binding point. - **glUniformSubroutines**: Sets the active subroutine for a set of uniform subroutine variables. - **glUseProgram**: Installs a program object as part of current rendering state. - **glUseProgramStages**: Installs a set of shader stages for the current program object. - **glValidateProgram**: Validates the current program object against the current OpenGL state. ``` -------------------------------- ### Get Vertex Binding Stride (OpenGL) Source: https://docs.gl/gl4/glGet Retrieves the byte offset between the start of each element in the bound buffer's data store for a vertex attribute. Accepted by indexed forms. Used with glGetIntegeri_v. ```c GLint stride; glGetIntegeri_v(GL_VERTEX_BINDING_STRIDE, index, &stride); ``` -------------------------------- ### Retrieve Texture Coordinate Array Pointer - OpenGL Source: https://docs.gl/gl3/glGetPointerv This example shows how to get the pointer for the texture coordinate array using `glGetPointerv`. The `GL_TEXTURE_COORD_ARRAY_POINTER` constant specifies which pointer to retrieve. This is relevant when managing texture data and its associated client-side arrays. ```c void* texCoordArrayPointer; gglGetPointerv(GL_TEXTURE_COORD_ARRAY_POINTER, &texCoordArrayPointer); // texCoordArrayPointer now points to the texture coordinate array ``` -------------------------------- ### Shaders API Source: https://docs.gl/gl3/glGetPointerv Functions for creating, compiling, linking, and managing shader programs. ```APIDOC ## Shaders API ### Description This section provides functions for shader management, including creating, attaching, compiling, linking, and validating shader programs and individual shaders. ### Functions - **glAttachShader** - **glBindAttribLocation** - **glBindFragDataLocation** - **glBindFragDataLocationIndexed** - **glCompileShader** - **glCreateProgram** - **glCreateShader** - **glCreateShaderProgram** - **glDeleteProgram** - **glDeleteShader** - **glDetachShader** - **glGetActiveAtomicCounterBufferiv** - **glGetActiveAttrib** - **glGetActiveSubroutineName** - **glGetActiveSubroutineUniform** - **glGetActiveSubroutineUniformName** - **glGetActiveUniform** - **glGetActiveUniformBlock** - **glGetActiveUniformBlockName** - **glGetActiveUniformBlockiv** - **glGetActiveUniformName** - **glGetActiveUniformsiv** - **glGetAttachedShaders** - **glGetAttribLocation** - **glGetFragDataIndex** - **glGetFragDataLocation** - **glGetProgram** - **glGetProgramBinary** - **glGetProgramInfoLog** - **glGetProgramResource** - **glGetProgramResourceIndex** - **glGetProgramResourceLocation** - **glGetProgramResourceLocationIndex** - **glGetProgramResourceName** - **glGetProgramStage** - **glGetProgramiv** - **glGetShader** - **glGetShaderInfoLog** - **glGetShaderPrecisionFormat** - **glGetShaderSource** - **glGetShaderiv** - **glGetSubroutineIndex** - **glGetSubroutineUniformLocation** - **glGetUniform** - **glGetUniformBlockIndex** - **glGetUniformIndices** - **glGetUniformLocation** - **glGetUniformSubroutine** - **glIsProgram** - **glIsShader** - **glLinkProgram** - **glMinSampleShading** - **glProgramBinary** - **glProgramParameter** - **glProgramParameteri** - **glProgramUniform** - **glReleaseShaderCompiler** - **glShaderBinary** - **glShaderSource** - **glShaderStorageBlockBinding** - **glUniform** - **glUniformBlockBinding** - **glUniformSubroutines** - **glUseProgram** - **glUseProgramStages** - **glValidateProgram** ``` -------------------------------- ### glUseProgram Source: https://docs.gl/es2/glUseProgram Installs a program object as part of the current rendering state. ```APIDOC ## glUseProgram ### Description Installs a program object as part of the current rendering state. ### Method `void glUseProgram(GLuint program)` ### Endpoint N/A (This is a function call, not an HTTP endpoint) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c // Example of how to use glUseProgram GLuint programHandle = /* get program handle */; glUseProgram(programHandle); ``` ### Response #### Success Response (Void) This function does not return a value. #### Response Example N/A ``` -------------------------------- ### glGetAttachedShaders C/C++ Example Source: https://docs.gl/es3/glGetAttachedShaders This C/C++ code snippet demonstrates how to use glGetAttachedShaders to retrieve the names of shader objects attached to a program. It first queries the number of attached shaders using glGetProgramiv and then uses glGetAttachedShaders to get the actual shader names. ```c #include #include void getShaders(GLuint program) { GLint count = 0; glGetProgramiv(program, GL_ATTACHED_SHADERS, &count); if (count > 0) { std::vector shaders(count); glGetAttachedShaders(program, count, NULL, shaders.data()); // Process the shader names (e.g., print them) for (int i = 0; i < count; ++i) { // printf("Shader: %u\n", shaders[i]); } } } ``` -------------------------------- ### OpenGL glBlendFunc Example Source: https://docs.gl/es2/glBlendFunc This C/C++ snippet demonstrates how to use the glBlendFunc function in OpenGL to enable and configure alpha blending. It sets the source blending factor to GL_SRC_ALPHA and the destination blending factor to GL_ONE_MINUS_SRC_ALPHA, a common setup for transparency. ```c #include void setupBlending() { // Enable blending glEnable(GL_BLEND); // Set the blending function for transparency // Source alpha is multiplied by the source color // Destination alpha is multiplied by the destination color glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } ``` -------------------------------- ### glDispatchCompute Source: https://docs.gl/gl4/glGenTextures Launches one or more compute work groups. ```APIDOC ## glDispatchCompute ### Description Launches one or more compute work groups. ### Method N/A (OpenGL Function) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### Shaders API Source: https://docs.gl/sl4/step API calls for creating, compiling, linking, and managing shader programs. ```APIDOC ## Shaders API This section details the OpenGL functions for managing shader programs. ### glCompileShader **Description**: Compiles a shader object. **Method**: `glCompileShader(GLuint shader)` **Endpoint**: N/A (Function call) ### glCreateProgram **Description**: Creates an empty program object. **Method**: `GLuint glCreateProgram(void)` **Endpoint**: N/A (Function call) ### glCreateShader **Description**: Creates a shader object. **Method**: `GLuint glCreateShader(GLenum type)` **Endpoint**: N/A (Function call) ### glDeleteProgram **Description**: Deletes a program object. **Method**: `glDeleteProgram(GLuint program)` **Endpoint**: N/A (Function call) ### glDeleteShader **Description**: Deletes a shader object. **Method**: `glDeleteShader(GLuint shader)` **Endpoint**: N/A (Function call) ### glGetProgramInfoLog **Description**: Returns the information log for a program object. **Method**: `glGetProgramInfoLog(GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog)` **Endpoint**: N/A (Function call) ### glGetShaderInfoLog **Description**: Returns the information log for a shader object. **Method**: `glGetShaderInfoLog(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog)` **Endpoint**: N/A (Function call) ### glGetShaderSource **Description**: Returns the source code string of a shader object. **Method**: `glGetShaderSource(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source)` **Endpoint**: N/A (Function call) ### glIsProgram **Description**: Tests whether a name corresponds to a program object. **Method**: `GLboolean glIsProgram(GLuint program)` **Endpoint**: N/A (Function call) ### glIsShader **Description**: Tests whether a name corresponds to a shader object. **Method**: `GLboolean glIsShader(GLuint shader)` **Endpoint**: N/A (Function call) ### glLinkProgram **Description**: Links a program object. **Method**: `glLinkProgram(GLuint program)` **Endpoint**: N/A (Function call) ### glShaderSource **Description**: Sets the source code string for a shader object. **Method**: `glShaderSource(GLuint shader, GLsizei count, const GLchar **string, const GLint *length)` **Endpoint**: N/A (Function call) ### glUseProgram **Description**: Installs a program object as part of current rendering state. **Method**: `glUseProgram(GLuint program)` **Endpoint**: N/A (Function call) ### glValidateProgram **Description**: Validates the current program object against the current OpenGL state. **Method**: `glValidateProgram(GLuint program)` **Endpoint**: N/A (Function call) --- ``` -------------------------------- ### Retrieve Attribute Location using glGetAttribLocation (GLSL) Source: https://docs.gl/es3/glGetAttribLocation This example demonstrates how to get the location of attribute variables like 'position', 'texcoord', 'normal', and 'color' from a shader program. The returned indices are crucial for enabling vertex attribute arrays during rendering. It also shows how to query active uniforms. ```c // The index returned from these GLint functions gets passed to glEnableVertexAttribArray during rendering. GLint position_attrib_index = glGetAttribLocation(program, "position"); // program is what is returned by glCreateProgram. GLint texcoord_attrib_index = glGetAttribLocation(program, "texcoord"); GLint normal_attrib_index = glGetAttribLocation(program, "normal"); GLint color_attrib_index = glGetAttribLocation(program, "color"); bindFragDataLocation(program, 0, "output_color"); // "output_color" is an output value in your vertex shader and an input value in your fragment shader. GLint num_uniforms; gglGetProgramiv(program, GL_ACTIVE_UNIFORMS, &num_uniforms); GLchar uniform_name[256]; GLsizei length; GLint size; GLenum type; for (int i = 0; i < num_uniforms; i++) { glGetActiveUniform(program, i, sizeof(uniform_name), &length, &size, &type, uniform_name); // ... save this uniform data so it can be used during rendering } ``` -------------------------------- ### Shaders API Source: https://docs.gl/gl3/glCreateProgram Functions for creating, compiling, linking, and managing shader programs and individual shaders. ```APIDOC ## Shaders API ### Description Functions for handling shader objects, including compilation, linking, and uniform management. ### Endpoints #### `glAttachShader` - **Description**: Attaches a shader object to a program object. - **Method**: `GLuint program, GLuint shader` #### `glBindAttribLocation` - **Description**: Binds a user-defined attribute variable to a generic vertex attribute index. - **Method**: `GLuint program, GLuint index, const GLchar *name` #### `glBindFragDataLocation` - **Description**: Binds a fragment shader varying variable to a fragment color buffer. - **Method**: `GLuint program, GLuint colorNumber, const GLchar *name` #### `glBindFragDataLocationIndexed` - **Description**: Binds a fragment shader varying variable to an indexed fragment color buffer. - **Method**: `GLuint program, GLuint colorNumber, GLuint index, const GLchar *name` #### `glCompileShader` - **Description**: Compiles a shader object. - **Method**: `GLuint shader` #### `glCreateProgram` - **Description**: Creates an empty program object. - **Method**: `void` #### `glCreateShader` - **Description**: Creates a shader object. - **Method**: `GLenum type` #### `glCreateShaderProgram` - **Description**: Creates a program object from a program whose sources are specified by shader objects. - **Method**: `GLuint vs, GLuint fs` (example for vertex and fragment shaders) #### `glDeleteProgram` - **Description**: Deletes a program object. - **Method**: `GLuint program` #### `glDeleteShader` - **Description**: Deletes a shader object. - **Method**: `GLuint shader` #### `glDetachShader` - **Description**: Detaches a shader object from a program object. - **Method**: `GLuint program, GLuint shader` #### `glGetActiveAtomicCounterBufferiv` - **Description**: Queries the properties of an active atomic counter buffer. - **Method**: `GLuint program, GLuint bufferIndex, GLenum pname, GLint *params` #### `glGetActiveAttrib` - **Description**: Returns the length and location of the active attribute variable in a program object. - **Method**: `GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name` #### `glGetActiveSubroutineName` - **Description**: Returns the name of the active subroutine. - **Method**: `GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name` #### `glGetActiveSubroutineUniform` - **Description**: Returns information about the active subroutine uniform. - **Method**: `GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values` #### `glGetActiveSubroutineUniformName` - **Description**: Returns the name of the active subroutine uniform. - **Method**: `GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name` #### `glGetActiveUniform` - **Description**: Returns the number of active uniform variables in the specified program object. - **Method**: `GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name` #### `glGetActiveUniformBlock` - **Description**: Returns the name of an active uniform block in a program. - **Method**: `GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName` #### `glGetActiveUniformBlockName` - **Description**: Returns the name of an active uniform block. - **Method**: `GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName` #### `glGetActiveUniformBlockiv` - **Description**: Returns values of parameters of an active uniform block. - **Method**: `GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params` #### `glGetActiveUniformName` - **Description**: Returns the name of an active uniform variable. - **Method**: `GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName` #### `glGetActiveUniformsiv` - **Description**: Returns values of parameters of active uniform variables. - **Method**: `GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params` #### `glGetAttachedShaders` - **Description**: Returns the names of shader objects attached to a program object. - **Method**: `GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj` #### `glGetAttribLocation` - **Description**: Returns the location of an attribute variable. - **Method**: `GLuint program, const GLchar *name` #### `glGetFragDataIndex` - **Description**: Returns the index of the fragment color output variable. - **Method**: `GLuint program, const GLchar *name` #### `glGetFragDataLocation` - **Description**: Returns the binding of fragment data color. - **Method**: `GLuint program, const GLchar *name` #### `glGetProgram` - **Description**: Returns parameters of a program object. - **Method**: `GLuint program, GLenum pname, GLint *params` #### `glGetProgramBinary` - **Description**: Returns the binary-retrievable representation of a program object. - **Method**: `GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary` #### `glGetProgramInfoLog` - **Description**: Returns the information log for a program object. - **Method**: `GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog` #### `glGetProgramResource` - **Description**: Queries properties of an active resource. - **Method**: `GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *properties, GLsizei bufSize, GLsizei *length, GLint *params` #### `glGetProgramResourceIndex` - **Description**: Returns the index of an active resource. - **Method**: `GLuint program, GLenum programInterface, const GLchar *name` #### `glGetProgramResourceLocation` - **Description**: Returns the location of an active resource. - **Method**: `GLuint program, GLenum programInterface, const GLchar *name` #### `glGetProgramResourceLocationIndex` - **Description**: Returns the index of an active resource. - **Method**: `GLuint program, GLenum programInterface, const GLchar *name` #### `glGetProgramResourceName` - **Description**: Returns the name of an active resource. - **Method**: `GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name` #### `glGetProgramStage` - **Description**: Returns the shader stage of a program object. - **Method**: `GLuint program, GLenum shadertype, GLenum pname, GLint *values` #### `glGetProgramiv` - **Description**: Returns parameters of a program object. - **Method**: `GLuint program, GLenum pname, GLint *params` #### `glGetShader` - **Description**: Returns parameters of a shader object. - **Method**: `GLuint shader, GLenum pname, GLint *params` #### `glGetShaderInfoLog` - **Description**: Returns the information log for a shader object. - **Method**: `GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog` #### `glGetShaderPrecisionFormat` - **Description**: Returns the numeric precision of available shader representations. - **Method**: `GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision` #### `glGetShaderSource` - **Description**: Returns the source code of a shader object. - **Method**: `GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source` #### `glGetShaderiv` - **Description**: Returns parameters of a shader object. - **Method**: `GLuint shader, GLenum pname, GLint *params` #### `glGetSubroutineIndex` - **Description**: Returns the index of a subroutine. - **Method**: `GLuint program, GLenum shadertype, const GLchar *name` #### `glGetSubroutineUniformLocation` - **Description**: Returns the location of a subroutine uniform. - **Method**: `GLuint program, GLenum shadertype, const GLchar *name` #### `glGetUniform` - **Description**: Returns the value of a uniform variable. - **Method**: `GLuint program, GLint location, GLfloat *params` (example for float uniforms) #### `glGetUniformBlockIndex` - **Description**: Returns the index of a uniform block. - **Method**: `GLuint program, const GLchar *uniformBlockName` #### `glGetUniformIndices` - **Description**: Returns the indices of active uniform variables. - **Method**: `GLuint program, GLsizei uniformCount, const GLchar **uniformNames, GLuint *uniformIndices` #### `glGetUniformLocation` - **Description**: Returns the location of a uniform variable. - **Method**: `GLuint program, const GLchar *name` #### `glGetUniformSubroutine` - **Description**: Returns the index of the active subroutine for a subroutine uniform variable. - **Method**: `GLuint program, GLenum shadertype, GLint location, GLuint *params` #### `glIsProgram` - **Description**: Determines if a name is a program object. - **Method**: `GLuint program` #### `glIsShader` - **Description**: Determines if a name is a shader object. - **Method**: `GLuint shader` #### `glLinkProgram` - **Description**: Links a program object. - **Method**: `GLuint ``` -------------------------------- ### Get Indexed Transform Feedback Buffer Offset/Size Info (C) Source: https://docs.gl/gl4/glGetTransformFeedback Retrieves 64-bit integer information about a specific indexed transform feedback buffer binding point, such as the start offset or size of the bound region. Requires OpenGL 4.5 or later. ```c void glGetTransformFeedbacki64_v(GLuint xfb, GLenum pname, GLuint index, GLint64 *param); // Example usage for GL_TRANSFORM_FEEDBACK_BUFFER_START at index 0: GLint64 startOffset; glGetTransformFeedbacki64_v(0, GL_TRANSFORM_FEEDBACK_BUFFER_START, 0, &startOffset); // Example usage for GL_TRANSFORM_FEEDBACK_BUFFER_SIZE at index 0: GLint64 bufferSize; glGetTransformFeedbacki64_v(0, GL_TRANSFORM_FEEDBACK_BUFFER_SIZE, 0, &bufferSize); ``` -------------------------------- ### glProgramUniform Functions - Version Support (OpenGL) Source: https://docs.gl/gl4/glProgramUniform This snippet illustrates the version support for glProgramUniform functions in OpenGL. These functions are used to set uniform variables in GLSL programs. The table shows availability starting from OpenGL version 4.0. No specific code examples are provided, but the functions are listed with their support status. ```text Function / Feature Name | 2.0 | 2.1 | 3.0 | 3.1 | 3.2 | 3.3 | 4.0 | 4.1 | 4.2 | 4.3 | 4.4 | 4.5 glProgramUniform1f | - | - | - | - | - | - | - | ✔ | ✔ | ✔ | ✔ | ✔ glProgramUniform1fv | - | - | - | - | - | - | - | ✔ | ✔ | ✔ | ✔ | ✔ glProgramUniform1i | - | - | - | - | - | - | - | ✔ | ✔ | ✔ | ✔ | ✔ glProgramUniform1iv | - | - | - | - | - | - | - | ✔ | ✔ | ✔ | ✔ | ✔ glProgramUniform1ui | - | - | - | - | - | - | - | ✔ | ✔ | ✔ | ✔ | ✔ glProgramUniform1uiv | - | - | - | - | - | - | - | ✔ | ✔ | ✔ | ✔ | ✔ glProgramUniform2f | - | - | - | - | - | - | - | ✔ | ✔ | ✔ | ✔ | ✔ glProgramUniform2fv | - | - | - | - | - | - | - | ✔ | ✔ | ✔ | ✔ | ✔ glProgramUniform2i | - | - | - | - | - | - | - | ✔ | ✔ | ✔ | ✔ | ✔ glProgramUniform2iv | - | - | - | - | - | - | - | ✔ | ✔ | ✔ | ✔ | ✔ glProgramUniform2ui | - | - | - | - | - | - | - | ✔ | ✔ | ✔ | ✔ | ✔ glProgramUniform2uiv | - | - | - | - | - | - | - | ✔ | ✔ | ✔ | ✔ | ✔ glProgramUniform3f | - | - | - | - | - | - | - | ✔ | ✔ | ✔ | ✔ | ✔ glProgramUniform3fv | - | - | - | - | - | - | - | ✔ | ✔ | ✔ | ✔ | ✔ glProgramUniform3i | - | - | - | - | - | - | - | ✔ | ✔ | ✔ | ✔ | ✔ glProgramUniform3iv | - | - | - | - | - | - | - | ✔ | ✔ | ✔ | ✔ | ✔ glProgramUniform3ui | - | - | - | - | - | - | - | ✔ | ✔ | ✔ | ✔ | ✔ glProgramUniform3uiv | - | - | - | - | - | - | - | ✔ | ✔ | ✔ | ✔ | ✔ glProgramUniform4f | - | - | - | - | - | - | - | ✔ | ✔ | ✔ | ✔ | ✔ glProgramUniform4fv | - | - | - | - | - | - | - | ✔ | ✔ | ✔ | ✔ | ✔ glProgramUniform4i | - | - | - | - | - | - | - | ✔ | ✔ | ✔ | ✔ | ✔ glProgramUniform4iv | - | - | - | - | - | - | - | ✔ | ✔ | ✔ | ✔ | ✔ glProgramUniform4ui | - | - | - | - | - | - | - | ✔ | ✔ | ✔ | ✔ | ✔ glProgramUniform4uiv | - | - | - | - | - | - | - | ✔ | ✔ | ✔ | ✔ | ✔ glProgramUniformMatrix2fv | - | - | - | - | - | - | - | ✔ | ✔ | ✔ | ✔ | ✔ glProgramUniformMatrix2x3fv | - | - | - | - | - | - | - | ✔ | ✔ | ✔ | ✔ | ✔ glProgramUniformMatrix2x4fv | - | - | - | - | - | - | - | ✔ | ✔ | ✔ | ✔ | ✔ glProgramUniformMatrix3fv | - | - | - | - | - | - | - | ✔ | ✔ | ✔ | ✔ | ✔ glProgramUniformMatrix3x2fv | - | - | - | - | - | - | - | ✔ | ✔ | ✔ | ✔ | ✔ glProgramUniformMatrix3x4fv | - | - | - | - | - | - | - | ✔ | ✔ | ✔ | ✔ | ✔ glProgramUniformMatrix4fv | - | - | - | - | - | - | - | ✔ | ✔ | ✔ | ✔ | ✔ glProgramUniformMatrix4x2fv | - | - | - | - | - | - | - | ✔ | ✔ | ✔ | ✔ | ✔ glProgramUniformMatrix4x3fv | - | - | - | - | - | - | - | ✔ | ✔ | ✔ | ✔ | ✔ ```