Implement SDL_GL_GetAttribute for SDL_GL_FLOATBUFFERS

This commit is contained in:
Boris I. Bendovsky
2025-07-27 21:55:59 +03:00
committed by Sam Lantinga
parent 9c54d686aa
commit d103e5531f
4 changed files with 23 additions and 1 deletions

View File

@@ -455,6 +455,7 @@ struct SDL_VideoDevice
int retained_backing;
int egl_platform;
int driver_loaded;
int HAS_GL_ARB_color_buffer_float;
char driver_path[256];
SDL_SharedObject *dll_handle;
} gl_config;

View File

@@ -75,6 +75,10 @@
#include <unistd.h>
#endif
#ifndef GL_RGBA_FLOAT_MODE_ARB
#define GL_RGBA_FLOAT_MODE_ARB 0x8820
#endif /* GL_RGBA_FLOAT_MODE_ARB */
// Available video drivers
static VideoBootStrap *bootstrap[] = {
#ifdef SDL_VIDEO_DRIVER_PRIVATE
@@ -5124,6 +5128,15 @@ bool SDL_GL_GetAttribute(SDL_GLAttr attr, int *value)
*value = _this->gl_config.egl_platform;
return true;
}
case SDL_GL_FLOATBUFFERS:
{
if (_this->gl_config.HAS_GL_ARB_color_buffer_float) {
attrib = GL_RGBA_FLOAT_MODE_ARB;
break;
} else {
return 0;
}
}
default:
return SDL_SetError("Unknown OpenGL attribute");
}

View File

@@ -510,6 +510,10 @@ void WIN_GL_InitExtensions(SDL_VideoDevice *_this)
_this->gl_data->HAS_WGL_ARB_create_context_no_error = true;
}
/* Check for WGL_ARB_pixel_format_float */
_this->gl_data->HAS_WGL_ARB_pixel_format_float =
HasExtension("WGL_ARB_pixel_format_float", extensions);
_this->gl_data->wglMakeCurrent(hdc, NULL);
_this->gl_data->wglDeleteContext(hglrc);
ReleaseDC(hwnd, hdc);
@@ -640,7 +644,7 @@ static bool WIN_GL_SetupWindowInternal(SDL_VideoDevice *_this, SDL_Window *windo
*iAttr++ = _this->gl_config.multisamplesamples;
}
if (_this->gl_config.floatbuffers) {
if (_this->gl_data->HAS_WGL_ARB_pixel_format_float && _this->gl_config.floatbuffers) {
*iAttr++ = WGL_PIXEL_TYPE_ARB;
*iAttr++ = WGL_TYPE_RGBA_FLOAT_ARB;
}
@@ -825,6 +829,9 @@ SDL_GLContext WIN_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window *window)
return NULL;
}
_this->gl_config.HAS_GL_ARB_color_buffer_float =
SDL_GL_ExtensionSupported("GL_ARB_color_buffer_float");
return (SDL_GLContext)context;
}

View File

@@ -64,6 +64,7 @@ struct SDL_GLDriverData
bool HAS_WGL_ARB_context_flush_control;
bool HAS_WGL_ARB_create_context_robustness;
bool HAS_WGL_ARB_create_context_no_error;
bool HAS_WGL_ARB_pixel_format_float;
/* Max version of OpenGL ES context that can be created if the
implementation supports WGL_EXT_create_context_es2_profile.