Help end child hunger

VSGLInfoLib – Very Simple OpenGL Information Lib


OpenGL has a rich set of functions to query its state. It is possible to get information on just about anything, from which shaders are attached to a program, to the values of uniforms, or the properties of the textures currently bound.

However, it is also true, that to get some of this information a lot of code is required. When debugging, we end up writing code to access this and that information over and over again.

This lib attempts to provide that information with a minimal effort to the developer. All the above questions are answered, plus a few more.

Information is provided for the following objects:

  • Buffers
  • Textures
  • Programs and Shaders
  • Uniforms
  • Vertex Array Objects

In Action

VSGLInfoLib provides a set of functions to display information that can be useful for debugging purposes. Each function is usually composed of a sequence of OpenGL state queries for some object in particular, or for types of objects.

Since there is no need for instances, all methods are static. Some methods return values, but most of them just send a human-readable string to a stream. To specify the output the stream the following function is provided

static void setOutputStream(std::ostream *outStream)

Passing NULL as an argument will set the stream to cout, which is also the default setting.


std::ostream *f;
f = new std::ofstream("info.txt");



One piece of information we always like to have is the OpenGL and GLSL versions we are working with. The following function provides this and some more information. An example of the output provided is:

General Information
Vendor: ATI Technologies Inc.
Renderer: AMD Radeon HD 6900M Series
Version: 4.1.11251 Core Profile Forward-Compatible/Debug Context
GLSL: 4.10
Num. Extensions: 201


Another useful piece of info is extension availability. To check if an extension is supported the following function can be used:

static bool isExtensionSupported(std::string extName)


The library provides detailed information about OpenGL objects. For instance, we can get information on a given program as follows:


Or, if using VSShaderLib:

VSShaderLib shader;
// init program and shaders


An example of the output provided is as follows:

Program Information for name 1
    Shaders {
    Program Separable: 0
    Program Binary Retrievable Hint: 0
    Link Status: 1
    Validate_Status: 1
    Delete_Status: 0
    Active_Attributes: 3
    Active_Uniforms: 9
    Active_Uniform_Blocks: 2
    Transform Feedback Buffer Mode: GL_INTERLEAVED_ATTRIBS

The numbers reported for the shaders are the names of each shader object.

For the same program we can query its uniforms and attributes with

static void getUniformsInfo(unsigned int program)
static void getAttributesInfo(unsigned int program)

Assuming the following uniforms in the shaders

// in the vertex shader
layout (std140) uniform Matrices {

	mat4 projModelViewMatrix;
	mat3 normalMatrix;

// in the fragment shader
layout (std140) uniform Material {
	vec4 diffuse;
	vec4 ambient;
	vec4 specular;
	vec4 emissive;
	float shininess;
	int texCount;

uniform	sampler2D texUnit;

An example of output for uniform information is as follows:

Uniforms Info for program: 1
    location: 8
    size: 4
  Size 72
  Block binding point: 1
  Buffer bound to binding point: 1 {
            offset: 16
            size: 16
            offset: 0
            size: 16
            offset: 48
            size: 16
            offset: 64
            size: 4
            offset: 32
            size: 16
            offset: 68
            size: 4
  Size 112
  Block binding point: 2
  Buffer bound to binding point: 2 {
            offset: 64
            size: 48
            mat stride: 16
            offset: 0
            size: 64
            mat stride: 16

It is also possible to query uniform values, both for uniforms in the default block, as well as for uniforms in named blocks:

static void getUniformInfo(unsigned int program, 
				std::string uniName)	
static void getUniformInBlockInfo(unsigned int program,																									
				std::string blockName,												
				std::string uniName)

For instance we can query the uniform “diffuse”, inside block “Material”, as follows:


Below is an example of the information we may obtain:

Block binding point: 1
Buffer bound to binding point: 1
Index of Uniform: 1
0.600000 0.600000 0.600000 0.000000

To see the full set of functions in the library check the Header section.


Version 0.1.0

  • Initial Release


To download go to VSL Downloads page.

  One Response to “VSGLInfoLib – Very Simple OpenGL Information Lib”

  1. diky je to ok

 Leave a Reply




You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>