OpenGL 1.X functions and gl3.h

How-to bind OpenGL 1.0 and 1.1 functions in the new OpenGL 3.2 context (core profile) on Windows when using the gl3.h header

For OpenGL 3 and above it is a good practice to use the new gl3.h header which does not include any deprecated functions from older OpenGL versions.

If you replace your gl.h (and maybe also the glext.h) header with the new gl3.h file the first thing you may notice is that the fundamental functions like glGetError() are not ready to use.

You could define GL3_PROTOTYPES but maybe that is not what you want to do because Windows’s opengl32.dll does not provide the necessary implementations for all the functions defined in gl3.h’s #ifdef GL3_PROTOTYPES […] #endif blocks. In fact Windows’s native OpenGL implementation only contains implementations for OpenGL 1.0 and 1.1 since Microsoft left the Khronos Group.

So instead of defining GL3_PROTOTYPES one has to use the function pointers provided below each #ifdef GL3_PROTOTYPES […] #endif block.

But the 1.0 and 1.1 functions declared in gl3.h cannot be bound via wglGetProcAddress()! Instead one has to load the opengl32.dll and then bind the functions via GetProcAddress():

HMODULE handle = NULL;

PROC getGlAddr(string procedure)
    PROC address= wglGetProcAddress(procedure.c_str());

    if (!address)
        address= GetProcAddress(handle, procedure.c_str());

    return address;

handle= LoadLibraryA("opengl32.dll");

glGetError= (PFNGLGETERRORPROC) getGlAddr("glGetError");


Die besten Horrorfilme

Auf der Suche nach guten Horrorfilmen stolpert man im Netz über Foren und Blogs, in denen oft kitschige Filme (z.B. Scream) oder Zombistreifen genannt werden. Noch ermüdender, die dort genannten Filme gehören oft einem ganz anderen Genre an (z.B. Thriller oder Splatter/Gorefilme wie Hostel und Saw).

Darum sollen an dieser Stelle mal die besten „echten“ Horrorfilme genannt werden:

  1. Der Exorzist – Director’s Cut (Teil 1!)
  2. Der Babadook
  3. Paranormal Activity 1 und 2
  4. The Grudge 1
  5. The Ring 1 und 2
  6. The Descent 1
  7. It Follows
  8. The Visit
  9. Drag Me To Hell
  10. The Shining
  11. The Conjuring
  12. Insidious 1 und 2
  13. The Pact
  14. Mama 2013

Der beste Horrorfilm ist also IMHO Der Exorzist – Director’s Cut. Er kommt wie eine Dokumentation rüber, in der die Grenzen der Medizin deutlich gemacht werden. Darüber hinaus wird der Teufel in Person, wie in keinem anderen Film, vor allem durch vulgäre Sprache inszeniert.

ATI multisample glBlitFramebuffer driver bug

Nasty ATI OpenGL driver bug when using a multisample framebuffer (FBO) with a GL_DEPTH24_STENCIL8_EXT renderbuffer attached

During the last few days I was wondering why the lens flare in one of my OpenGL games was broken on the ATI Radeon HD 5850 with latest drivers. On my NVidia 8800 GTS and ATI Mobility Radeon HD 3400 everything was working fine.

But on the 5850 both of the following glReadPixels calls always returned zero (0.0f) for Zf or Zi when a framebuffer object was bound which was downsampled from a multisampled framebuffer with a GL_DEPTH24_STENCIL8_EXT renderbuffer attached.

GLfloat Zf;
glReadPixels(x, y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &Zf);

unsigned int Zi;
glReadPixels(x, y, 1, 1, GL_DEPTH_STENCIL_EXT, GL_UNSIGNED_INT_24_8_EXT, &Zi);

The downsampling was done using glBlitFramebufferEXT like this:

glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, Handle_MS);
glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT,  Handle);

glBlitFramebufferEXT(0, 0, Width, Height, 0,  0, Width, Height, GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT,  GL_NEAREST);

A workaround is to call glBlitFramebufferEXT without the GL_STENCIL_BUFFER_BIT flag although we are working on a packed depth stencil buffer.

glBlitFramebufferEXT(0, 0, Width, Height, 0,  0, Width, Height, GL_DEPTH_BUFFER_BIT,  GL_NEAREST);

Otherwise the depth values will not be copied from the multisampled renderbuffer to the singlesampled one or at least not on the ATI Radeon HD 5850 with the following driver version:

Driver Packaging Version    8.732-100504a-099996C-ATI
Catalyst™ Version    10.5
Provider    ATI Technologies Inc.
2D Driver Version
2D Driver File Path    /REGISTRY/MACHINE/SYSTEM/ControlSet001/Control/CLASS/{4D36E968-E325-11CE-BFC1-08002BE10318}/0001
Direct3D Version
OpenGL Version
Catalyst™ Control Center Version    2010.0504.2152.37420