Off-screen fixes for ATI on OSX   Leave a comment

A few days ago some people noted that the off-screen mode of the GLGraphics object would not work on ATI cards (see the thread in the Processing forum). A new release of the GLGraphics library (0.8.1) that fixes this issue is available for download here.

First of all, it seems to be a problem related to the opengl drivers on OSX, since I tested the off-screen rendering on a ATI 1550 on Windows XP (using catalyst drivers 6.7), and worked ok.

The first implementation of the off-screen mode used a 32 bits texture to hold a packed depth+stencil buffer. Something like this:

gl.glGenTextures(1, depthStencilTex, 0);
gl.glBindTexture(GL.GL_TEXTURE_2D, depthStencilTex[0]);
gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR);
gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR);
gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_REPEAT);
gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_REPEAT);
gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8, width, height, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, null);
gl.glBindTexture(GL.GL_TEXTURE_2D, 0);

and then attaching the texture to the FBO with:

gl.glFramebufferTexture2DEXT(GL.GL_FRAMEBUFFER_EXT, GL.GL_DEPTH_ATTACHMENT_EXT, GL.GL_TEXTURE_2D, depthStencilTex[0], 0);

By replacing the texture by a renderbuffer:

gl.glGenRenderbuffersEXT(1, depthStencilBuffer, 0);
gl.glBindRenderbufferEXT(GL.GL_RENDERBUFFER_EXT, depthStencilBuffer[0]);
gl.glRenderbufferStorageEXT(GL.GL_RENDERBUFFER_EXT, GL_DEPTH24_STENCIL8, width, height);

with the corresponding attachments:

gl.glFramebufferRenderbufferEXT(GL.GL_FRAMEBUFFER_EXT, GL.GL_DEPTH_ATTACHMENT_EXT, GL.GL_RENDERBUFFER_EXT, depthStencilBuffer[0]);
gl.glFramebufferRenderbufferEXT(GL.GL_FRAMEBUFFER_EXT, GL.GL_STENCIL_ATTACHMENT_EXT, GL.GL_RENDERBUFFER_EXT, depthStencilBuffer[0]);

the off-screen mode of GLGraphics now works fine on ATI+OSX.

Advertisements

Posted August 2, 2008 by ac in Programming

Tagged with , , , , , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: