SDL_video: Added SDL_GL_FLOATBUFFERS to allow Cocoa GL contexts to use EDR

This commit is contained in:
Shootfast 2022-07-06 20:12:30 +01:00 committed by Sam Lantinga
parent 0b9868b026
commit 60d1944e46
6 changed files with 38 additions and 2 deletions

View File

@ -248,7 +248,8 @@ typedef enum
SDL_GL_FRAMEBUFFER_SRGB_CAPABLE, SDL_GL_FRAMEBUFFER_SRGB_CAPABLE,
SDL_GL_CONTEXT_RELEASE_BEHAVIOR, SDL_GL_CONTEXT_RELEASE_BEHAVIOR,
SDL_GL_CONTEXT_RESET_NOTIFICATION, SDL_GL_CONTEXT_RESET_NOTIFICATION,
SDL_GL_CONTEXT_NO_ERROR SDL_GL_CONTEXT_NO_ERROR,
SDL_GL_FLOATBUFFERS
} SDL_GLattr; } SDL_GLattr;
typedef enum typedef enum

View File

@ -368,6 +368,7 @@ struct SDL_VideoDevice
int stereo; int stereo;
int multisamplebuffers; int multisamplebuffers;
int multisamplesamples; int multisamplesamples;
int floatbuffers;
int accelerated; int accelerated;
int major_version; int major_version;
int minor_version; int minor_version;

View File

@ -3519,6 +3519,7 @@ SDL_GL_ResetAttributes()
_this->gl_config.stereo = 0; _this->gl_config.stereo = 0;
_this->gl_config.multisamplebuffers = 0; _this->gl_config.multisamplebuffers = 0;
_this->gl_config.multisamplesamples = 0; _this->gl_config.multisamplesamples = 0;
_this->gl_config.floatbuffers = 0;
_this->gl_config.retained_backing = 1; _this->gl_config.retained_backing = 1;
_this->gl_config.accelerated = -1; /* accelerated or not, both are fine */ _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: case SDL_GL_MULTISAMPLESAMPLES:
_this->gl_config.multisamplesamples = value; _this->gl_config.multisamplesamples = value;
break; break;
case SDL_GL_FLOATBUFFERS:
_this->gl_config.floatbuffers = value;
break;
case SDL_GL_ACCELERATED_VISUAL: case SDL_GL_ACCELERATED_VISUAL:
_this->gl_config.accelerated = value; _this->gl_config.accelerated = value;
break; break;

View File

@ -261,6 +261,9 @@ Cocoa_GL_CreateContext(_THIS, SDL_Window * window)
attr[i++] = _this->gl_config.multisamplesamples; attr[i++] = _this->gl_config.multisamplesamples;
attr[i++] = NSOpenGLPFANoRecovery; attr[i++] = NSOpenGLPFANoRecovery;
} }
if (_this->gl_config.floatbuffers) {
attr[i++] = NSOpenGLPFAColorFloat;
}
if (_this->gl_config.accelerated >= 0) { if (_this->gl_config.accelerated >= 0) {
if (_this->gl_config.accelerated) { if (_this->gl_config.accelerated) {

View File

@ -74,6 +74,11 @@
#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9 #define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9
#endif #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 #ifndef WGL_ARB_context_flush_control
#define WGL_ARB_context_flush_control #define WGL_ARB_context_flush_control
#define WGL_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097 #define WGL_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097
@ -597,6 +602,10 @@ WIN_GL_SetupWindowInternal(_THIS, SDL_Window * window)
*iAttr++ = _this->gl_config.multisamplesamples; *iAttr++ = _this->gl_config.multisamplesamples;
} }
if (_this->gl_config.floatbuffers) {
*iAttr++ = WGL_TYPE_RGBA_FLOAT_ARB;
}
if (_this->gl_config.framebuffer_srgb_capable) { if (_this->gl_config.framebuffer_srgb_capable) {
*iAttr++ = WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB; *iAttr++ = WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB;
*iAttr++ = _this->gl_config.framebuffer_srgb_capable; *iAttr++ = _this->gl_config.framebuffer_srgb_capable;

View File

@ -118,6 +118,16 @@ typedef GLXContext(*PFNGLXCREATECONTEXTATTRIBSARBPROC) (Display * dpy,
#endif #endif
#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 #ifndef GLX_ARB_create_context_no_error
#define GLX_ARB_create_context_no_error #define GLX_ARB_create_context_no_error
#ifndef GLX_CONTEXT_OPENGL_NO_ERROR_ARB #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. */ /* Setup our GLX attributes according to the gl_config. */
if( for_FBConfig ) { if( for_FBConfig ) {
attribs[i++] = GLX_RENDER_TYPE; 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 { } else {
attribs[i++] = GLX_RGBA; 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; 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) { if (_this->gl_config.framebuffer_srgb_capable) {
attribs[i++] = GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB; attribs[i++] = GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB;
attribs[i++] = True; /* always needed, for_FBConfig or not! */ attribs[i++] = True; /* always needed, for_FBConfig or not! */