diff --git a/include/SDL_video.h b/include/SDL_video.h index 48d00cf40..8e6d317a6 100644 --- a/include/SDL_video.h +++ b/include/SDL_video.h @@ -248,7 +248,8 @@ typedef enum SDL_GL_FRAMEBUFFER_SRGB_CAPABLE, SDL_GL_CONTEXT_RELEASE_BEHAVIOR, SDL_GL_CONTEXT_RESET_NOTIFICATION, - SDL_GL_CONTEXT_NO_ERROR + SDL_GL_CONTEXT_NO_ERROR, + SDL_GL_FLOATBUFFERS } SDL_GLattr; typedef enum diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h index fdaf1adf1..6bfb60e92 100644 --- a/src/video/SDL_sysvideo.h +++ b/src/video/SDL_sysvideo.h @@ -368,6 +368,7 @@ struct SDL_VideoDevice int stereo; int multisamplebuffers; int multisamplesamples; + int floatbuffers; int accelerated; int major_version; int minor_version; diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 2ce99c921..986854345 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -3519,6 +3519,7 @@ SDL_GL_ResetAttributes() _this->gl_config.stereo = 0; _this->gl_config.multisamplebuffers = 0; _this->gl_config.multisamplesamples = 0; + _this->gl_config.floatbuffers = 0; _this->gl_config.retained_backing = 1; _this->gl_config.accelerated = -1; /* accelerated or not, both are fine */ @@ -3607,6 +3608,9 @@ SDL_GL_SetAttribute(SDL_GLattr attr, int value) case SDL_GL_MULTISAMPLESAMPLES: _this->gl_config.multisamplesamples = value; break; + case SDL_GL_FLOATBUFFERS: + _this->gl_config.floatbuffers = value; + break; case SDL_GL_ACCELERATED_VISUAL: _this->gl_config.accelerated = value; break; diff --git a/src/video/cocoa/SDL_cocoaopengl.m b/src/video/cocoa/SDL_cocoaopengl.m index 5a57612b2..5b41b1822 100644 --- a/src/video/cocoa/SDL_cocoaopengl.m +++ b/src/video/cocoa/SDL_cocoaopengl.m @@ -261,6 +261,9 @@ Cocoa_GL_CreateContext(_THIS, SDL_Window * window) attr[i++] = _this->gl_config.multisamplesamples; attr[i++] = NSOpenGLPFANoRecovery; } + if (_this->gl_config.floatbuffers) { + attr[i++] = NSOpenGLPFAColorFloat; + } if (_this->gl_config.accelerated >= 0) { if (_this->gl_config.accelerated) { diff --git a/src/video/windows/SDL_windowsopengl.c b/src/video/windows/SDL_windowsopengl.c index 549b01bb1..1f81917f3 100644 --- a/src/video/windows/SDL_windowsopengl.c +++ b/src/video/windows/SDL_windowsopengl.c @@ -74,6 +74,11 @@ #define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9 #endif +#ifndef WGL_ARB_pixel_format_float +#define WGL_ARB_pixel_format_float +#define WGL_TYPE_RGBA_FLOAT_ARB 0x21A0 +#endif + #ifndef WGL_ARB_context_flush_control #define WGL_ARB_context_flush_control #define WGL_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097 @@ -597,6 +602,10 @@ WIN_GL_SetupWindowInternal(_THIS, SDL_Window * window) *iAttr++ = _this->gl_config.multisamplesamples; } + if (_this->gl_config.floatbuffers) { + *iAttr++ = WGL_TYPE_RGBA_FLOAT_ARB; + } + if (_this->gl_config.framebuffer_srgb_capable) { *iAttr++ = WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB; *iAttr++ = _this->gl_config.framebuffer_srgb_capable; diff --git a/src/video/x11/SDL_x11opengl.c b/src/video/x11/SDL_x11opengl.c index 3e17e97ff..60b2203cd 100644 --- a/src/video/x11/SDL_x11opengl.c +++ b/src/video/x11/SDL_x11opengl.c @@ -118,6 +118,16 @@ typedef GLXContext(*PFNGLXCREATECONTEXTATTRIBSARBPROC) (Display * dpy, #endif #endif +#ifndef GLX_ARB_fbconfig_float +#define GLX_ARB_fbconfig_float +#ifndef GLX_RGBA_FLOAT_TYPE_ARB +#define GLX_RGBA_FLOAT_TYPE_ARB 0x20B9 +#endif +#ifndef GLX_RGBA_FLOAT_BIT_ARB +#define GLX_RGBA_FLOAT_BIT_ARB 0x00000004 +#endif +#endif + #ifndef GLX_ARB_create_context_no_error #define GLX_ARB_create_context_no_error #ifndef GLX_CONTEXT_OPENGL_NO_ERROR_ARB @@ -492,7 +502,11 @@ X11_GL_GetAttributes(_THIS, Display * display, int screen, int * attribs, int si /* Setup our GLX attributes according to the gl_config. */ if( for_FBConfig ) { attribs[i++] = GLX_RENDER_TYPE; - attribs[i++] = GLX_RGBA_BIT; + if (_this->gl_config.floatbuffers) { + attribs[i++] = GLX_RGBA_FLOAT_BIT_ARB; + } else { + attribs[i++] = GLX_RGBA_BIT; + } } else { attribs[i++] = GLX_RGBA; } @@ -560,6 +574,10 @@ X11_GL_GetAttributes(_THIS, Display * display, int screen, int * attribs, int si attribs[i++] = _this->gl_config.multisamplesamples; } + if (_this->gl_config.floatbuffers) { + attribs[i++] = GLX_RGBA_FLOAT_TYPE_ARB; + } + if (_this->gl_config.framebuffer_srgb_capable) { attribs[i++] = GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB; attribs[i++] = True; /* always needed, for_FBConfig or not! */