From 30c8f4ef20b687d7d1fefffa5f049d9f0c45acb2 Mon Sep 17 00:00:00 2001 From: Rakarake Date: Sun, 8 Feb 2026 15:38:36 +0100 Subject: [PATCH] done --- fragment.glsl | 7 +------ pulsating-noise.glsl | 4 ++-- renderer.c | 4 ++-- wayland.c | 22 ++++++++++++++++------ 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/fragment.glsl b/fragment.glsl index bc77986..51b16cd 100644 --- a/fragment.glsl +++ b/fragment.glsl @@ -1,9 +1,4 @@ -#version 320 es - -precision highp float; -precision highp int; -precision lowp sampler2D; -precision lowp samplerCube; +#version 330 core uniform vec2 WindowSize; uniform float time; diff --git a/pulsating-noise.glsl b/pulsating-noise.glsl index 77dfafb..42b71c3 100644 --- a/pulsating-noise.glsl +++ b/pulsating-noise.glsl @@ -1,7 +1,7 @@ #version 330 core -out vec4 FragColor; uniform vec2 WindowSize; uniform float time; +layout(location = 0) out vec4 color; float rand(vec2 co){ return fract(sin(dot(co, vec2(12.9898, 78.233))) * 43758.5453); @@ -13,5 +13,5 @@ void main() { vec2 uv = gl_FragCoord.xy / WindowSize; // grid float glob = rand(uv + time); - FragColor = vec4(glob * (sin(time)/2 + 0.5), glob, 1.0, 1.0); //vec4(gl_FragCoord.xy / WindowSize, 0.0, 1.0); + color = vec4(glob * (sin(time)/2 + 0.5), glob, 1.0, 1.0); //vec4(gl_FragCoord.xy / WindowSize, 0.0, 1.0); } diff --git a/renderer.c b/renderer.c index 9b1a4bc..c6db943 100644 --- a/renderer.c +++ b/renderer.c @@ -28,7 +28,7 @@ GLuint compile_shader(GLuint type, const char *src) { } const char *vertex_shader_src = -"#version 320 es\n" +"#version 330 core\n" "\n" "layout(location = 0) in vec2 aPos;\n" "\n" @@ -158,7 +158,7 @@ void render(Renderer *state, int w, int h, double time, char *shader_path, int r // Rendorrrr glViewport(0, 0, w, h); - glClearColor(0.3f, 0.3f, 0.3f, 1.0f); // Dark gray background + glClearColor(0.8f, 0.3f, 0.3f, 1.0f); // Dark gray background glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Shader parameters. diff --git a/wayland.c b/wayland.c index 7937b04..cf40a7c 100644 --- a/wayland.c +++ b/wayland.c @@ -365,13 +365,17 @@ static void egl_init(struct client_state *state) { EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_BLUE_SIZE, 8, - EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, + EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT | EGL_OPENGL_ES3_BIT | EGL_OPENGL_BIT, EGL_MIN_SWAP_INTERVAL, 0, // make sure that swapping buffers don't block the thread EGL_NONE }; static const EGLint context_attribs[] = { - EGL_CONTEXT_CLIENT_VERSION, 2, + //EGL_CONTEXT_CLIENT_VERSION, 2, + EGL_CONTEXT_MAJOR_VERSION, 4, + EGL_CONTEXT_MINOR_VERSION, 6, + EGL_CONTEXT_OPENGL_PROFILE_MASK, + EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT, EGL_NONE }; @@ -391,11 +395,16 @@ static void egl_init(struct client_state *state) { } printf("EGL major: %d, minor %d\n", major, minor); + // Desktop GL? + if (eglBindAPI(EGL_OPENGL_API) == EGL_FALSE) { + printf("eglBindAPI failed\n"); + exit(1); + } + EGLint count; eglGetConfigs(state->egl_display, NULL, 0, &count); printf("EGL has %d configs\n", count); - EGLConfig *configs = calloc(count, sizeof *configs); EGLint n; @@ -415,13 +424,14 @@ static void egl_init(struct client_state *state) { break; } - // Desktop GL? - eglBindAPI(EGL_OPENGL_API); - state->egl_context = eglCreateContext(state->egl_display, state->egl_config, EGL_NO_CONTEXT, context_attribs); + if (state->egl_context == EGL_NO_CONTEXT) { + printf("Failed to create EGL context\n"); + exit(1); + } // EGL window struct surface_list *next = state->surface_list;