Skip to content

Commit

Permalink
backend/glx: refactor glXChooseFBConfig's attrib_list
Browse files Browse the repository at this point in the history
first, let's get rid of invalid attributes:
* the EXT_framebuffer_sRGB extension specification doesn't say that the
GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT token is accepted by the <attribList>
parameter of glXChooseFBConfig.

second, let's get rid of ignored attributes:
* GLX_BUFFER_SIZE is ignored if GLX_COLOR_INDEX_BIT is not set in
GLX_RENDER_TYPE and the default value of GLX_RENDER_TYPE is
GLX_RGBA_BIT;
* GLX_X_VISUAL_TYPE is ignored if GLX_DRAWABLE_TYPE is specified in
attrib_list and the mask that follows does not have GLX_WINDOW_BIT set.

third, let's get rid of attributes that are set to default values:
* the default value of GLX_RENDER_TYPE is GLX_RGBA_BIT;
* the default value of GLX_STENCIL_SIZE is 0;
* the default value of GLX_DEPTH_SIZE is 0.

fourth, let's set the GLX_CONFIG_CAVEAT attribute to GLX_NONE to match
the eglChooseConfig's attrib_list and avoid getting slow or non
conformant frame buffer configurations.

fifth, let's use fancy constants Xlib gives us: True instead of true and
None instead of 0. we're working closely with Xlib here after all.

sixth, let's sort the attrib_list to match the order attributes are
described in the glXChooseFBConfig function specification for easier
lookup.

references:
https://registry.khronos.org/OpenGL-Refpages/gl2.1/xhtml/glXChooseFBConfig.xml
https://registry.khronos.org/OpenGL/extensions/EXT/EXT_framebuffer_sRGB.txt
  • Loading branch information
absolutelynothelix committed Jul 29, 2024
1 parent c7fc878 commit 72dc6b4
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/backend/gl/glx.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,14 @@ bool glx_find_fbconfig(struct x_connection *c, struct xvisual_info m,
// clang-format off
GLXFBConfig *cfg =
glXChooseFBConfig(c->dpy, c->screen, (int[]){
GLX_RENDER_TYPE, GLX_RGBA_BIT,
GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT,
GLX_X_VISUAL_TYPE, GLX_TRUE_COLOR,
GLX_X_RENDERABLE, true,
GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT, (GLint)GLX_DONT_CARE,
GLX_BUFFER_SIZE, m.red_size + m.green_size +
m.blue_size + m.alpha_size,
GLX_RED_SIZE, m.red_size,
GLX_BLUE_SIZE, m.blue_size,
GLX_GREEN_SIZE, m.green_size,
GLX_BLUE_SIZE, m.blue_size,
GLX_ALPHA_SIZE, m.alpha_size,
GLX_STENCIL_SIZE, 0,
GLX_DEPTH_SIZE, 0,
0
GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT,
GLX_X_RENDERABLE, True,
GLX_CONFIG_CAVEAT, GLX_NONE,
None,
}, &ncfg);
// clang-format on

Expand Down

0 comments on commit 72dc6b4

Please sign in to comment.