SDL_video: Added SDL_GL_FLOATBUFFERS to allow Cocoa GL contexts to use EDR
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
diff --git a/include/SDL_video.h b/include/SDL_video.h
index 48d00cf..8e6d317 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 fdaf1ad..6bfb60e 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 2ce99c9..9868543 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 5a57612..5b41b18 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 549b01b..1f81917 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 3e17e97..60b2203 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! */