The Dot Docs

DotShaders

DotShaders.pas contains various utility functions for working with shaders, based on either ARB_vertex_program / ARB_fragment_program or the OpenGL Shading Language (GLSL).

ARB_vp / ARB_fp

  function dotLoadASMShader(target: GLenum; filename: String): GLuint;

This function loads an assembly shader from the specified file and generates a program object for it. The target parameter should be either GL_VERTEX_PROGRAM_ARB or GL_FRAGMENT_PROGRAM_ARB. An exception will be raised if the file can't be loaded or the shader fails to compile.

GLSL

  function dotGLSLGetInfoLog(s: GLhandleARB): String;

This function returns the info log associated with the given program object as a Delphi string.

  function dotGLSLLoadShader(const src: String; const stype: GLenum): GLhandleARB;
function dotGLSLLoadShaderFromFile(const filename: String; const stype: GLenum): GLhandleARB; function dotGLSLLoadProgram(const sources: array of const): GLhandleARB; function dotGLSLLoadProgramFromFiles(const filenames: array of const): GLhandleARB;

These functions are all used to load shader source and compile it. The first two load a single shader from memory (by passing the source code directly to the function) and from disk, respectively. The latter two load multiple shaders and link them into a single program object, ready to be used. Again, this pair of functions can either take shader source directly or load it from disk for you. The argument to the dotGLSLLoadProgram*() functions is an array of consts that should consist of pairs (i.e. the number of elements must be even). The first item in each pair should be a shader compilation target, i.e. either GL_VERTEX_SHADER_ARB or GL_FRAGMENT_SHADER_ARB. The second item in each pair should be either the shader source or the filename from which to load the source.

The dotGLSLLoadProgram*() functions compile and link the shaders, so there is no need to link them yourself.

  function dotGLSLLinkPrograms(const programs: array of GLhandleARB): GLhandleARB;

If you decide not to use the dotGLSLLoadProgram*() functions, you will have to link shaders manually, which you can do using dotGLSLLinkPrograms(). This function takes an array of shader handles and returns a program object ready to be used.

  function dotGLSLUniformLocation(const shader: GLhandleARB; const name: String): Integer;

The last of the GLSL utility functions, dotGLSLUniformLocation() returns the location of the given uniform value. The function takes a plain Delphi string as an argument and returns the location immediately, which is more convenient than calling glGetUniformLocationARB() directly.

The Delphi OpenGL Toolkit was written by Tom Nuydens.
See main page for disclaimer. For updates, visit Delphi3D.