[PATCH] Another take at SDL 1.3 rendertarget bug + ARB_color_buffer_float support

Hello all!

I’ve attached a patch to SDL 1.3 CVS and I’m requesting your comments.

This patch:

(1) Takes care of robustness issue with attributes on render target
creation. Previously the parameters will be messed up if the array is
not specified in the requested order, and fails to get the remaining
attributes if SDL_GL_RED_SIZE is specified prematurely.

Jonathan Thambidurai’s patch addresses this but requires the attributes
to contain two terminating zero’s at the end of the attrib array. I
relaxed this restriction by semi-intelligently detecting whether the
zero corresponded to a SDL_GL_RED_SIZE value.

Note that for this to work, the attributes have to be specified in the
enum order (however not all attributes have to be there). As Jonathan
pointed out, the very nature of the array being passed to
SDL_GL_CreateRenderTarget is problematic (and is potentially a buffer
overflow issue as well). Maybe the attribute passing should be
redesigned before it is too late?

(2) Adds support for the GL_ARB_color_buffer_float extension, which
allows floating-point color buffers to be used. Currently this
extension only works on pbuffer render targets, and only on Windows and X11.

Jonathan’s previous patch included support for the NV_float_buffer
extension, and he recommended that it be scrapped once the ARB version
is commonplace. To avoid conflicts with code previously written to his
patch (and also to be consistent with the other enum names), I renamed

NOTE: As of this writing nVidia has not yet released official drivers
for this ARB extension. The beta drivers contain it, but only on
Windows. That means I haven’t tested if the X11 patch works properly
(but I’ve seen it to fail properly :wink: ). Also, if anyone has ATI
hardware around, please check if the patch works as is on your hardware!

I’ve also attached a very simple program to test the float buffer
functionality. This may be included in the test/ directory for future
SDL releases, if the maintainers so wish. :slight_smile:

Much thanks to Jonathan for all the help, if it isn’t obvious by now. :)–
Eric Vidal
Lecturer / Graduate Research Assistant, DISCS
Ateneo de Manila University
-------------- next part --------------
A non-text attachment was scrubbed…
Name: SDL-1.3.diff
Type: text/x-patch
Size: 12237 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20050516/34ffde90/attachment.bin
-------------- next part --------------
A non-text attachment was scrubbed…
Name: testfloatbuffer.c
Type: text/x-c
Size: 4388 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20050516/34ffde90/attachment-0001.bin