-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Closed
Closed
Copy link
Description
I want to create an OpenGL context with SDL_GL_FLOATBUFFERS on Windows. However, the window creation fails with the error message No matching GL pixel format available. My GPU supports the extension WGL_ARB_pixel_format_float, so it should be possible to create such a context.
I looked into the SDL code and it seems that the attributes array is not filled correctly.
Instead of
if (_this->gl_config.floatbuffers) {
*iAttr++ = WGL_TYPE_RGBA_FLOAT_ARB;
}
it should be like
if (_this->gl_config.floatbuffers) {
*iAttr++ = WGL_PIXEL_TYPE_ARB;
*iAttr++ = WGL_TYPE_RGBA_FLOAT_ARB;
}
because WGL_TYPE_RGBA_FLOAT_ARB is an value for the parameter WGL_PIXEL_TYPE_ARB (every attribute is a {type, value} pair). This also causes that the following attributes will be messed up if the user requests a float buffer.
This is my test code:
#include <SDL2/SDL.h>
#include <iostream>
int main(int argc, char *argv[])
{
SDL_Init(SDL_INIT_VIDEO);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 16);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 16);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 16);
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 16);
SDL_GL_SetAttribute(SDL_GL_FLOATBUFFERS, SDL_TRUE);
SDL_Window *window = SDL_CreateWindow("Float Framebuffer", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1024, 576, SDL_WINDOW_OPENGL);
std::cout << SDL_GetError() << '\n';
SDL_GLContext context = SDL_GL_CreateContext(window);
SDL_GL_MakeCurrent(window, context);
int r, g, b, a, fb;
SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &r);
SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &g);
SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &b);
SDL_GL_GetAttribute(SDL_GL_ALPHA_SIZE, &a);
SDL_GL_GetAttribute(SDL_GL_FLOATBUFFERS, &fb);
std::cout << "r: " << r << " g: " << g << " b: " << b << " a: " << a << " float fb: " << fb << '\n';
SDL_GL_MakeCurrent(window, nullptr);
SDL_GL_DeleteContext(context);
SDL_DestroyWindow(window);
SDL_Quit();
return 0;
}
Metadata
Metadata
Assignees
Labels
No labels