[GtkGLExt] OpenGL 2.0 extensions support



Dear all!

As you might know, GtkGlExt provides easy and convenient access
to the OpenGL extensions. The API for the extensions is in the
gdkglglext.h file. It declares a number of structures each
representing pointers to functions of a particular extension.
For example, if you want to use Vertex Buffer Objects you have to
do it in your code the following way:

GdkGL_GL_ARB_vertex_buffer_object *vbo = NULL;

vbo = gdk_gl_get_GL_ARB_vertex_buffer_object ();

if (NULL != vbo) {
   /*
    * Vertex Buffer Objects are supported
    * /
} else {
   /*
    * Vertex Buffer Objects are not supported
    * /
}

You can call extension functions afterwards:
vbo->glGenBufferARB (...);
vbo->glBindBufferARB (...);
etc.

As of GtkGlExt version 1.2.0 the extensions of OpenGL up
to the version 1.4 are supported. Unfortunately, the revisions
of OpenGL API 1.5 and 2.0 are not supported by GtkGlExt.
This means that for the moment we can't use vertex/fragment
shader objects or frame buffer objects the same convenient way
as we use, for instance, vertex buffer objects.

The attched archive contains changes I suggest to extend
gdkglglext.h with and en example of usage of the new proposed
structures. The structures are (both in the gtkglext_fbo_sl.h file):
1. GdkGL_GL_ARB_shader_objects - this one handles all the
   functions needed to create/compile/link and use GLSL
   programs (both vertex/fragment shaders).
2. GdkGL_GL_EXT_framebuffer_object - this one holds the
   functions related to Frame Buffer Objects (also often
   refered to as the "Render-to-Texture" extension).

They can be inited with the functions gdk_gl_get_GL_ARB_shader_objects ()
and GdkGL_GL_EXT_framebuffer_object () respectively.

The example of their usage is in the file fbo_sl.c. It is a modified
"Gears" demo (I believe you are all familiar with). The rendering of
the gears is redirected to a FBO (created in the function rebuild_fbo ())
and then the resulted texture is tiled in the backbuffer. Finally,
each vertex is displaced by a vertex shader program (created in the
build_GLSL_program () function, the source is in the waving_vertex_source
char array) along the Z axis. For each frame each vertex is displaced
slightly different resulting in a waving effect.

The demo is for Linux only. I tested it on RHEL4.0 with GtkGlExt 1.0.6
installed, NVIDIA 8762 propietary drivers and Geforce 5700 FX graphics
board. You can build it with the make utility and launch the executable
with this command:
./fbo_sl

The intention of this demo is to demonstrate the features of the latest
OpenGL API and to initiate a discussion here on the issue of their
support in the further versions of GtkGlExt. Of course, shaders and
FBOs are not the only extensions in the version 2.0 of OpenGl. Let's
realize which particular ones we, as users of the GtkGlExt, need and
how to provide the access to them the best way within the GtkGlExt
project.

PS. For further information on the GLSL shaders and the FBO extension you
can refer to
http://oss.sgi.com/projects/ogl-sample/registry/ARB/shader_objects.txt
http://oss.sgi.com/projects/ogl-sample/registry/ARB/vertex_shader.txt
http://oss.sgi.com/projects/ogl-sample/registry/ARB/fragment_shader.txt
http://oss.sgi.com/projects/ogl-sample/registry/EXT/framebuffer_object.txt
http://oss.sgi.com/projects/ogl-sample/registry/ARB/GLSLangSpec.Full.1.10.59.pdf

http://nehe.gamedev.net/data/articles/article.asp?article=21
http://www.lighthouse3d.com/opengl/glsl/

Best regards,

-- 
Vladimir Bashkardin
Department of Exploration Geophysics
Gubkin's Russian State University of Oil and Gas

Attachment: fbo_sl.tar.gz
Description: GNU Zip compressed data



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]