Skip to content

Commit d103e55

Browse files
bibendovskyslouken
authored andcommitted
Implement SDL_GL_GetAttribute for SDL_GL_FLOATBUFFERS
1 parent 9c54d68 commit d103e55

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed

src/video/SDL_sysvideo.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,7 @@ struct SDL_VideoDevice
455455
int retained_backing;
456456
int egl_platform;
457457
int driver_loaded;
458+
int HAS_GL_ARB_color_buffer_float;
458459
char driver_path[256];
459460
SDL_SharedObject *dll_handle;
460461
} gl_config;

src/video/SDL_video.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@
7575
#include <unistd.h>
7676
#endif
7777

78+
#ifndef GL_RGBA_FLOAT_MODE_ARB
79+
#define GL_RGBA_FLOAT_MODE_ARB 0x8820
80+
#endif /* GL_RGBA_FLOAT_MODE_ARB */
81+
7882
// Available video drivers
7983
static VideoBootStrap *bootstrap[] = {
8084
#ifdef SDL_VIDEO_DRIVER_PRIVATE
@@ -5124,6 +5128,15 @@ bool SDL_GL_GetAttribute(SDL_GLAttr attr, int *value)
51245128
*value = _this->gl_config.egl_platform;
51255129
return true;
51265130
}
5131+
case SDL_GL_FLOATBUFFERS:
5132+
{
5133+
if (_this->gl_config.HAS_GL_ARB_color_buffer_float) {
5134+
attrib = GL_RGBA_FLOAT_MODE_ARB;
5135+
break;
5136+
} else {
5137+
return 0;
5138+
}
5139+
}
51275140
default:
51285141
return SDL_SetError("Unknown OpenGL attribute");
51295142
}

src/video/windows/SDL_windowsopengl.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,10 @@ void WIN_GL_InitExtensions(SDL_VideoDevice *_this)
510510
_this->gl_data->HAS_WGL_ARB_create_context_no_error = true;
511511
}
512512

513+
/* Check for WGL_ARB_pixel_format_float */
514+
_this->gl_data->HAS_WGL_ARB_pixel_format_float =
515+
HasExtension("WGL_ARB_pixel_format_float", extensions);
516+
513517
_this->gl_data->wglMakeCurrent(hdc, NULL);
514518
_this->gl_data->wglDeleteContext(hglrc);
515519
ReleaseDC(hwnd, hdc);
@@ -640,7 +644,7 @@ static bool WIN_GL_SetupWindowInternal(SDL_VideoDevice *_this, SDL_Window *windo
640644
*iAttr++ = _this->gl_config.multisamplesamples;
641645
}
642646

643-
if (_this->gl_config.floatbuffers) {
647+
if (_this->gl_data->HAS_WGL_ARB_pixel_format_float && _this->gl_config.floatbuffers) {
644648
*iAttr++ = WGL_PIXEL_TYPE_ARB;
645649
*iAttr++ = WGL_TYPE_RGBA_FLOAT_ARB;
646650
}
@@ -825,6 +829,9 @@ SDL_GLContext WIN_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window *window)
825829
return NULL;
826830
}
827831

832+
_this->gl_config.HAS_GL_ARB_color_buffer_float =
833+
SDL_GL_ExtensionSupported("GL_ARB_color_buffer_float");
834+
828835
return (SDL_GLContext)context;
829836
}
830837

src/video/windows/SDL_windowsopengl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ struct SDL_GLDriverData
6464
bool HAS_WGL_ARB_context_flush_control;
6565
bool HAS_WGL_ARB_create_context_robustness;
6666
bool HAS_WGL_ARB_create_context_no_error;
67+
bool HAS_WGL_ARB_pixel_format_float;
6768

6869
/* Max version of OpenGL ES context that can be created if the
6970
implementation supports WGL_EXT_create_context_es2_profile.

0 commit comments

Comments
 (0)