aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorJack Jamison <jackqjamison@gmail.com>2025-10-11 01:45:08 -0400
committerJack Jamison <jackqjamison@gmail.com>2025-10-11 01:45:08 -0400
commitba3a68a4f73f6653b1e1b095abc08234dedc504d (patch)
treec7f12e78cd6d97c7f559811064865bc8a6eeeb9f /main.c
parentf23baade916e844b6b6c9714e6b5d81020f6ba57 (diff)
added graphics.h
Diffstat (limited to 'main.c')
-rw-r--r--main.c79
1 files changed, 4 insertions, 75 deletions
diff --git a/main.c b/main.c
index fae4ac2..9baf779 100644
--- a/main.c
+++ b/main.c
@@ -1,83 +1,14 @@
#include <EGL/egl.h>
#include <stdio.h>
-#include "./state.h"
+#include "state.h"
+#include "graphics.h"
+
#include "wlr-layer-shell-unstable-v1.h"
extern struct wl_registry_listener registry_listener;
extern struct zwlr_layer_surface_v1_listener layer_surface_listener;
-bool init_gl(client_state* state) {
- EGLint attrs[] = {
- EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
- EGL_CONFORMANT, EGL_OPENGL_BIT,
- EGL_RED_SIZE, 8,
- EGL_GREEN_SIZE, 8,
- EGL_BLUE_SIZE, 8,
- EGL_ALPHA_SIZE, 8,
- EGL_DEPTH_SIZE, 24,
- EGL_NONE
- };
-
- state->egl_window = wl_egl_window_create(state->surface, state->width, state->height);
- if (!state->egl_window) {
- fprintf(stderr, "ewindow\n");
- return false;
- }
-
-
- state->egl_display = eglGetDisplay(state->display);
- if (state->egl_display == EGL_NO_DISPLAY) {
- fprintf(stderr, "edisplay\n");
- return false;
- }
- {
- EGLint major, minor;
- if (eglInitialize(state->egl_display, &major, &minor) != EGL_TRUE) {
- fprintf(stderr, "eglinit\n");
- return false;
- }
-
- printf("EGL version %u.%u\n", major, minor);
- }
- eglBindAPI(EGL_OPENGL_API);
-
- EGLint num_configs;
- if (eglChooseConfig(state->egl_display, attrs, &state->egl_config, 1, &num_configs) != EGL_TRUE) {
- fprintf(stderr, "econfig: %d\n", eglGetError());
- return false;
- }
-
- state->egl_surface = eglCreateWindowSurface(state->egl_display, state->egl_config,
- (EGLNativeWindowType)state->egl_window, NULL);
- if (state->egl_surface == EGL_NO_SURFACE) {
- fprintf(stderr, "esurface\n");
- return false;
- }
-
- state->egl_context = eglCreateContext(state->egl_display, state->egl_config,
- EGL_NO_CONTEXT, NULL);
- if (state->egl_context == EGL_NO_CONTEXT) {
- fprintf(stderr, "econtext: %x\n", eglGetError());
- return false;
- }
-
- eglMakeCurrent(state->egl_display, state->egl_surface, state->egl_surface, state->egl_context);
-
- if (!gladLoadGL()) {
- fprintf(stderr, "gladLoadGL");
- return false;
- }
-
- {
- GLint major, minor;
- glGetIntegerv(GL_MAJOR_VERSION, &major);
- glGetIntegerv(GL_MINOR_VERSION, &minor);
- printf("GL version %u.%u\n", major, minor);
- }
- return true;
-}
-
int main() {
client_state state = {0};
@@ -116,8 +47,6 @@ int main() {
while (state.running) {
wl_display_dispatch_pending(state.display);
- glClearColor(1.0, 1.0, 1.0, 1.0);
- glClear(GL_COLOR_BUFFER_BIT);
- eglSwapBuffers(state.egl_display, state.egl_surface);
+ render_frame(&state);
}
}