The open source OpenXR runtime

aux/ogl: Add GLX API wrapper

Add a wrapper for the GLX API around the GLAD header.

Co-authored-by: Christoph Haag <christoph.haag@collabora.com>

authored by

James Hogan
Christoph Haag
and committed by
Christoph Haag
7440e14f 3dfcc485

+53
+3
src/xrt/auxiliary/CMakeLists.txt
··· 21 21 ogl/ogl_helpers.h 22 22 ) 23 23 target_link_libraries(aux_ogl PUBLIC aux-includes xrt-external-glad) 24 + if(XRT_HAVE_OPENGL_GLX AND XRT_HAVE_XLIB) 25 + target_sources(aux_ogl PRIVATE ogl/glx_api.c ogl/glx_api.h) 26 + endif() 24 27 if(XRT_HAVE_EGL) 25 28 target_sources(aux_ogl PRIVATE ogl/egl_api.c ogl/egl_api.h) 26 29 endif()
+7
src/xrt/auxiliary/meson.build
··· 119 119 'ogl/ogl_helpers.h', 120 120 ] 121 121 122 + if build_opengl and build_xlib 123 + ogl_files += [ 124 + 'ogl/glx_api.h', 125 + 'ogl/glx_api.c', 126 + ] 127 + endif 128 + 122 129 if build_opengles or build_egl 123 130 ogl_files += [ 124 131 'ogl/egl_api.h',
+11
src/xrt/auxiliary/ogl/glx_api.c
··· 1 + // Copyright 2022, James Hogan <james@albanarts.com> 2 + // SPDX-License-Identifier: BSL-1.0 3 + /*! 4 + * @file 5 + * @brief GLX API wrapper. 6 + * @author James Hogan <james@albanarts.com> 7 + * @ingroup aux_ogl 8 + */ 9 + 10 + #define GLAD_GLX_NO_X11 11 + #include "../../external/glad/src/glx.c"
+32
src/xrt/auxiliary/ogl/glx_api.h
··· 1 + // Copyright 2022, James Hogan <james@albanarts.com> 2 + // SPDX-License-Identifier: BSL-1.0 3 + /*! 4 + * @file 5 + * @brief GLX API wrapper header. 6 + * @author James Hogan <james@albanarts.com> 7 + * @ingroup aux_ogl 8 + */ 9 + 10 + #pragma once 11 + 12 + #include "xrt/xrt_gfx_xlib.h" 13 + 14 + // We don't #include "glad/glx.h" here in order not to conflict with our typedefs in xrt_gfx_xlib.h. 15 + 16 + Display * 17 + glXGetCurrentDisplay(void); 18 + GLXContext 19 + glXGetCurrentContext(void); 20 + GLXDrawable 21 + glXGetCurrentDrawable(void); 22 + GLXDrawable 23 + glXGetCurrentReadDrawable(void); 24 + bool 25 + glXMakeContextCurrent(Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx); 26 + bool 27 + glXMakeCurrent(Display *dpy, GLXDrawable drawable, GLXContext ctx); 28 + 29 + typedef void (*GLADapiproc)(void); 30 + typedef GLADapiproc (*GLADloadfunc)(const char *name); 31 + int 32 + gladLoadGLX(Display *display, int screen, GLADloadfunc load);