Skip to content

Commit

Permalink
Merge pull request #1011 from absolutelynothelix/decouple-glx-and-egl…
Browse files Browse the repository at this point in the history
…-backends
  • Loading branch information
yshui committed Jun 19, 2023
2 parents dd85c3e + 15667d6 commit b852723
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
12 changes: 6 additions & 6 deletions src/backend/gl/egl.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const char *eglGetErrorString(EGLint error) {
}

/**
* Free a glx_texture_t.
* Free a gl_texture_t.
*/
static void egl_release_image(backend_t *base, struct gl_texture *tex) {
struct egl_data *gd = (void *)base;
Expand All @@ -88,14 +88,14 @@ static void egl_release_image(backend_t *base, struct gl_texture *tex) {
}

/**
* Destroy GLX related resources.
* Destroy EGL related resources.
*/
void egl_deinit(backend_t *base) {
struct egl_data *gd = (void *)base;

gl_deinit(&gd->gl);

// Destroy GLX context
// Destroy EGL context
if (gd->ctx != EGL_NO_CONTEXT) {
eglMakeCurrent(gd->display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
eglDestroyContext(gd->display, gd->ctx);
Expand Down Expand Up @@ -225,12 +225,12 @@ static backend_t *egl_init(session_t *ps) {

gd->ctx = eglCreateContext(gd->display, config, NULL, NULL);
if (gd->ctx == EGL_NO_CONTEXT) {
log_error("Failed to get GLX context.");
log_error("Failed to get EGL context.");
goto end;
}

if (!eglMakeCurrent(gd->display, gd->target_win, gd->target_win, gd->ctx)) {
log_error("Failed to attach GLX context.");
log_error("Failed to attach EGL context.");
goto end;
}

Expand Down Expand Up @@ -423,7 +423,7 @@ struct backend_operations egl_ops = {

PFNEGLGETDISPLAYDRIVERNAMEPROC eglGetDisplayDriverName;
/**
* Check if a GLX extension exists.
* Check if a EGL extension exists.
*/
static inline bool egl_has_extension(EGLDisplay dpy, const char *ext) {
const char *egl_exts = eglQueryString(dpy, EGL_EXTENSIONS);
Expand Down
4 changes: 1 addition & 3 deletions src/backend/gl/egl.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) Yuxuan Shui <yshuiv7@gmail.com>
#pragma once
#include <stdbool.h>
// Older version of glx.h defines function prototypes for these extensions...
// Rename them to avoid conflicts
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <GL/gl.h>
#include <GL/glext.h>
#include <stdbool.h>
#include <xcb/render.h>
#include <xcb/xcb.h>

Expand Down
2 changes: 1 addition & 1 deletion src/backend/gl/gl_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ bool gl_init(struct gl_data *gd, session_t *ps) {
glGenQueries(2, gd->frame_timing);
gd->current_frame_timing = 0;

// Initialize GLX data structure
// Initialize GL data structure
glDisable(GL_DEPTH_TEST);
glDepthMask(GL_FALSE);

Expand Down
10 changes: 5 additions & 5 deletions src/backend/gl/gl_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ typedef struct {
GLint color_loc;
} gl_fill_shader_t;

/// @brief Wrapper of a binded GLX texture.
/// @brief Wrapper of a binded GL texture.
struct gl_texture {
int refcount;
bool has_alpha;
Expand Down Expand Up @@ -214,7 +214,7 @@ static inline const char *gl_get_err_str(GLenum err) {
}

/**
* Check for GLX error.
* Check for GL error.
*
* http://blog.nobel-joergensen.com/2013/01/29/debugging-opengl-using-glgeterror/
*/
Expand All @@ -225,10 +225,10 @@ static inline void gl_check_err_(const char *func, int line) {
const char *errtext = gl_get_err_str(err);
if (errtext) {
log_printf(tls_logger, LOG_LEVEL_ERROR, func,
"GLX error at line %d: %s", line, errtext);
"GL error at line %d: %s", line, errtext);
} else {
log_printf(tls_logger, LOG_LEVEL_ERROR, func,
"GLX error at line %d: %d", line, err);
"GL error at line %d: %d", line, err);
}
}
}
Expand Down Expand Up @@ -265,7 +265,7 @@ static inline bool gl_check_fb_complete_(const char *func, int line, GLenum fb)
#define gl_check_fb_complete(fb) gl_check_fb_complete_(__func__, __LINE__, (fb))

/**
* Check if a GLX extension exists.
* Check if a GL extension exists.
*/
static inline bool gl_has_extension(const char *ext) {
int nexts = 0;
Expand Down

0 comments on commit b852723

Please sign in to comment.