diff options
author | 2025-05-16 08:55:26 +0200 | |
---|---|---|
committer | 2025-05-16 08:55:26 +0200 | |
commit | aee73b628ecfe98b800ae7f653f6b19655b78b58 (patch) | |
tree | f1d6c5ec40ef3021f1a1c219274ec48dade193e0 /src/main/ui/x11/ui.c | |
parent | 795a394e17f2949de065b6a2ef276b75d5ea675c (diff) | |
download | tris-aee73b628ecfe98b800ae7f653f6b19655b78b58.tar.gz tris-aee73b628ecfe98b800ae7f653f6b19655b78b58.zip |
Add a function to ope the display
Diffstat (limited to 'src/main/ui/x11/ui.c')
-rw-r--r-- | src/main/ui/x11/ui.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/main/ui/x11/ui.c b/src/main/ui/x11/ui.c index 9018250..5199eea 100644 --- a/src/main/ui/x11/ui.c +++ b/src/main/ui/x11/ui.c @@ -22,6 +22,7 @@ #include <GL/gl.h> #include <GL/glx.h> #include <X11/Xlib.h> +#include "../../util.h" static Display *display; static Window window; @@ -29,21 +30,28 @@ static GLXContext gl_context; void cleanup(void); -void -ui_init() +static Display * +ui_open_display(void) { - display = XOpenDisplay(NULL); + Display *display = XOpenDisplay(NULL); if (!display) { - fprintf(stderr, "Error: Can't open X11 display\n"); + log_error("Can't open X11 display"); exit(1); } + return display; +} + +void +ui_init() +{ + display = ui_open_display(); + int screen = DefaultScreen(display); Window root = RootWindow(display, screen); GLint attribs[] = { GLX_RGBA, GLX_DEPTH_SIZE, 24, GLX_DOUBLEBUFFER, None }; XVisualInfo *vi = glXChooseVisual(display, screen, attribs); - if (!vi) { fprintf(stderr, "Error: No compatible Visual found\n"); exit(1); |