summaryrefslogtreecommitdiff
path: root/src/graphics.cc
blob: d9db4c81bb780a7bb84a41931434d330c2ab9672 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "graphics.h"

#include <EGL/egl.h>

#include "utils.h"
#include "wlstate.h"

enum graphics_error_e wayc_graphics_init(struct graphics_s* graphics,
                                         struct wlstate_s* state) {
  wayc_notnull(graphics);
  wayc_notnull(state);

  EGLDisplay display = eglGetDisplay(state->display);
  if (display == EGL_NO_DISPLAY) return GRAPHICS_ERROR_DISPLAY;

  graphics->display = display;
  return GRAPHICS_ERROR_NONE;
}

void wayc_graphics_deinit(struct graphics_s* graphics) {
  wayc_notnull(graphics);

  if (graphics->display == nullptr) return;

  eglMakeCurrent(graphics->display, EGL_NO_SURFACE, EGL_NO_SURFACE,
                 EGL_NO_CONTEXT);
  eglTerminate(graphics->display);
}