[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.18 Programmable shaders

Shader objects

Function: gl-create-shader-object-arb type

[GL_ARB_shader_objects] Creates a new shader object and returns its handle. Type can be either GL_VERTEX_SHADER_ARB or GL_FRAGMENT_SHADER_ARB.

Function: gl-shader-source-arb shader strings

[GL_ARB_shader_objects] Sets the source code of the shader, whose handle is shader. You can give the source code as a list of strings to strings. All strings are concatenated internally in the OpenGL driver.

Function: gl-compile-shader-arb shader

[GL_ARB_shader_objects] Compile the source code attached to the shader, whose handle is shader. You can query the result of the compilation by passing GL_OBJECT_COMPILE_STATUS_ARB to gl-get-object-parameter-arb; it returns #t if the compilation succeeded, or #f if failed. The information about the compilation can be obtained by gl-get-info-log-arb.

Function: gl-create-program-object-arb

[GL_ARB_shader_objects] Creates a new program object and returns its handle.

Function: gl-attach-object-arb program shader

[GL_ARB_shader_objects] Attach a shader whose handle is shader to the program whose handle is program.

Function: gl-detach-object-arb program shader

[GL_ARB_shader_objects] Detach a shader from a program.

Function: gl-link-program-arb program

[GL_ARB_shader_objects] Link the program object. The result of linking can be queried by passing GL_OBJECT_LINK_STATUS_ARB to gl-get-object-parameter-arb.

Function: gl-use-program-object-arb program

[GL_ARB_shader_objects] Installs the program to the current rendering state.

Function: gl-delete-object-arb handle

[GL_ARB_shader_objects] Deletes either a shader object or a program object specified by handle.

Function: gl-get-object-parameter-arb object pname

[GL_ARB_shader_objects] Queries the value of pname of the shader or the program specified by object. The following values are accepted as pname: GL_OBJECT_TYPE_ARB, GL_OBJECT_SUBTYPE_ARB, GL_OBJECT_DELETE_STATUS_ARB, GL_OBJECT_COMPILE_STATUS_ARB, GL_OBJECT_LINK_STATUS_ARB, GL_OBJECT_VALIDATE_STATUS_ARB, GL_OBJECT_INFO_LOG_LENGTH_ARB, GL_OBJECT_ATTACHED_OBJECTS_ARB, GL_OBJECT_ACTIVE_ATTRIBUTES_ARB, GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB, GL_OBJECT_ACTIVE_UNIFORMS_ARB, GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB, and GL_OBJECT_SHADER_SOURCE_LENGTH_ARB. The procedure returns an integer value.

Function: gl-get-shader-source-arb shader

[GL_ARB_shader_objects] Returns the shader source code of a shader object shader in a string.

Function: gl-get-info-log-arb handle

[GL_ARB_shader_objects] Returns the information log of an object pointed by handle.

Function: gl-get-handle-arb pname

[GL_ARB_shader_objects] Returns the handle to an object that is used in the current state. The only argument accepted currently as pname is GL_PROGRAM_OBJECT_ARB, which returns the handle to the current program object.

Function: gl-get-attached-objects-arb program

[GL_ARB_shader_objects] Rethrns a vector of GL object handles that are attached to the program.

Function: gl-validate-program-arb program

[GL_ARB_shader_objects] Checks whether the program can execute in the current GL state. The result is stored in program's log.

Specifying vertex attributes

Function: gl-vertex-attrib-arb index values
Function: gl-vertex-attrib-arb index v0 &rest v1 v2 v3

[GL_ARB_vertex_program] Sets the generic vertex attribute specified by index. In the first form, you can pass f32, f64, or s16vector of size 1 to 4, or u8, s8, u16, s32, or u32vector of size 4. In the second form, you can pass 1 to 4 real numbers (they are interpreted as C doubles and glVertexAttrib4dARB is called).

Function: gl-vertex-attrib-4n-arb index values
Function: gl-vertex-attrib-4n-arb index v0 v1 v2 v3

[GL_ARB_vertex_program] These variations can be used to pass normalized values. The first form accepts s8, u8, s16, u16, s32, u32, f32 and f64vector of size 4. The second value takes four integers, whose lower 8bits are taken as unsigned byte and passed to glVertexAttrib4NubARB.

Function: gl-vertex-attrib-pointer-arb index size vec &optional normalized stride offset

[GL_ARB_vertex_program] This is the generic version of vertex arrays. Index names the attribute, size specifies the number of components (1, 2, 3 or 4), and vec is a uniform vector that contains the array of values.

The optional boolean normalized argument tells whether the passed integer values should be mapped to normalized range (#t or taken as are #f, default). The optional stride argument specifies the gap between each set of values within vec. The optional offset argument tells GL to take values beginning from the offset-th element of vec.

Function: gl-enable-vertex-attrib-array-arb index
Function: gl-disable-vertex-attrib-array-arb index

[GL_ARB_vertex_program] Enable or disable a vertex attribute array specified by index.

Function: gl-bind-attrib-location-arb program index name

[GL_ARB_vertex_shader] Associates a user-defined attribute variable in the program object program with an index-th generic vertex attribute. Name is a string of the name of user-defined attribute as appears in the shader program.

Function: gl-get-attrib-location-arb program name

[GL_ARB_vertex_shader] Returns an integer index of the user-defined attribute name in the program. Must be called after program is linked.

Function: gl-get-active-attrib-arb program index

[GL_ARB_vertex_shader] Obtains information about the index-th user-defined attribute in the program. Must be called after program is linked.

It returns three values: the size of the attribute (1, 2, 3 or 4), the type of the attribute (an integer that matches one of the following constants: GL_FLOAT, GL_FLOAT_VEC2_ARB, GL_FLOAT_VEC3_ARB, GL_FLOAT_VEC4_ARB, GL_FLOAT_MAT2_ARB, GL_FLOAT_MAT3_ARB, or GL_FLOAT_MAT4_ARB.), and the name of the attribute.

Specifying uniform variables

Function: gl-get-uniform-location-arb program name

[GL_ARB_shader_objects] Returns an integer location of the uniform variable name of the program program.

Function: gl-uniform1-arb location vec
Function: gl-uniform1-arb location v0
Function: gl-uniform2-arb location vec
Function: gl-uniform2-arb location v0 v1
Function: gl-uniform3-arb location vec
Function: gl-uniform3-arb location v0 v1 v2
Function: gl-uniform4-arb location vec
Function: gl-uniform4-arb location v0 v1 v1 v3

[GL_ARB_shader_objects] Sets a value of the uniform variable specified by location. gl-uniform1-arb sets a single component value (e.g. float) gl-uniform2-arb sets a double component value (e.g. vec2) etc.

The first form of each function takes either an s32vector or f32vector. It can have a size multiple of the number of components to set an array uniform variable (e.g. you can pass an f32vector of size 8 to fill vec2[2]).

The second form just sets the component(s) of a single uniform variable. The arguments v0 to v3 must be real numbers, and coerced to C float (i.e. glUniform*fARB is used).

Function: gl-uniform-matrix2-arb location transpose v
Function: gl-uniform-matrix3-arb location transpose v
Function: gl-uniform-matrix4-arb location transpose v

[GL_ARB_shader_objects] Sets a matrix uniform variable (or an array of matrix uniform variables) specified by location. A boolean flag transpose specifies whether the matrix should be transposed. The v argument must be a f32vector of size multiple of 4, 9, or 16, respectively.

Function: gl-get-active-uniform-arb program index

[GL_ARB_shader_objects] Returns informaton about the index-th uniform variable of program.

Returns three values. The first one is the size, either 1, 2, 3 or 4. The second value is the type, which is an integer that matches one of the following constants: GL_FLOAT, GL_FLOAT_VEC(1|2|3|4)_ARB, GL_INT, GL_INT_VEC(1|2|3|4)_ARB, GL_BOOL, GL_BOOL_VEC(1|2|3|4)_ARB, GL_FLOAT_MAT(2|3|4)_ARB. And the third value is the name of the uniform variable.

Vertex and fragment programs

These APIs are for low-level vertex/fragment pipeline programming.

Function: gl-gen-programs-arb n

[GL_ARB_vertex_program] Generates N names (integers) for the new programs and returns them in an s32vector.

Function: gl-delete-programs-arb programs

[GL_ARB_vertex_program] Deletes programs whose names are specified by an s32vector programs.

Function: gl-is-program-arb prog-id

[GL_ARB_vertex_program] Returns #t if an integer prog-id refers to a valid program.

Function: gl-bind-program-arb target prog-id

[GL_ARB_vertex_program] Binds a program specified by prog-id to a target, which is either GL_VERTEX_PROGRAM_ARB or GL_FRAGMENT_PROGRAM_ARB.

Function: gl-program-string-arb target format text

[GL_ARB_vertex_program] Sets the source code of the program currently bound to the target (GL_VERTEX_PROGRAM_ARB or GL_FRAGMENT_PROGRAM_ARB).

Format must be GL_PROGRAM_FORMAT_ASCII_ARB. Text is a string for the program source.

Function: gl-program-env-parameter-arb target param-id args
Function: gl-program-env-parameter-arb target param-id arg0 arg1 arg2 arg3
Function: gl-program-local-parameter-arb target param-id args
Function: gl-program-local-parameter-arb target param-id arg0 arg1 arg2 arg3

[GL_ARB_vertex_program] Sets the value of the environment and local parameter specified by param-id of the program currently bount to the target. In the first form of each, args must be either f32 or f64vector of size 4 or <vector4f> object.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]

This document was generated by Shiro Kawai on June, 7 2008 using texi2html 1.78.