Cleanup: move all GLX stuff into render_context_glx.

This commit is contained in:
Roz K 2022-12-24 07:03:59 +01:00
parent 65b25c8be3
commit 0c560890a4
Signed by: roz
GPG Key ID: 51FBF4E483E1C822
2 changed files with 10 additions and 7 deletions

View File

@ -17,10 +17,12 @@
#define _RK_ENGINE_RENDER_CONTEXT_H
#include "../render.hpp"
#include <GL/glx.h>
extern PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC rk_DrawElementsInstancedBaseInstance;
extern PFNGLMULTIDRAWELEMENTSINDIRECTPROC rk_MultiDrawElementsIndirect;
typedef void (*rk_DrawElementsInstancedBaseInstanceFunc)(rk_uint, rk_uint, rk_uint, const void *, rk_uint, rk_uint);
typedef void (*rk_MultiDrawElementsIndirectFunc)(rk_uint, rk_uint, const void *, rk_uint, rk_uint);
extern rk_DrawElementsInstancedBaseInstanceFunc rk_DrawElementsInstancedBaseInstance;
extern rk_MultiDrawElementsIndirectFunc rk_MultiDrawElementsIndirect;
extern rk_window_t rk_create_context(
char const * name,

View File

@ -21,6 +21,7 @@
#include <cstring>
#include <GLES3/gl32.h>
#include <X11/Xlib.h>
#include <GL/glx.h>
extern unsigned rk_events_mask;
@ -35,8 +36,8 @@ static bool rk_error_occured = false;
#define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092
typedef GLXContext (*glXCreateContextAttribsARBProc)(Display *, GLXFBConfig, GLXContext, Bool, int const *);
PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC rk_DrawElementsInstancedBaseInstance = nullptr;
PFNGLMULTIDRAWELEMENTSINDIRECTPROC rk_MultiDrawElementsIndirect = nullptr;
rk_DrawElementsInstancedBaseInstanceFunc rk_DrawElementsInstancedBaseInstance = nullptr;
rk_MultiDrawElementsIndirectFunc rk_MultiDrawElementsIndirect = nullptr;
static int const rk_visual_attribs[] = {
GLX_X_RENDERABLE, True,
@ -202,13 +203,13 @@ rk_window_t rk_create_context(
char const * const gl_exts = reinterpret_cast<char const *>(glGetString(GL_EXTENSIONS));
if (rk_extension_supported(gl_exts, "GL_EXT_base_instance")) {
rk_DrawElementsInstancedBaseInstance =
reinterpret_cast<PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC>(
reinterpret_cast<rk_DrawElementsInstancedBaseInstanceFunc>(
glXGetProcAddressARB(reinterpret_cast<GLubyte const *>("DrawElementsInstancedBaseInstance")));
if (rk_DrawElementsInstancedBaseInstance) {
rk_printf("Using extension GL_EXT_base_instance::DrawElementsInstancedBaseInstance.");
if (rk_extension_supported(gl_exts, "GL_EXT_multi_draw_indirect")) {
rk_MultiDrawElementsIndirect =
reinterpret_cast<PFNGLMULTIDRAWELEMENTSINDIRECTPROC>(
reinterpret_cast<rk_MultiDrawElementsIndirectFunc>(
glXGetProcAddressARB(reinterpret_cast<GLubyte const *>("MultiDrawElementsIndirectEXT")));
if (rk_MultiDrawElementsIndirect) {
rk_printf("Using extension GL_EXT_multi_draw_indirect::MultiDrawElementsIndirectEXT.");