This commit is contained in:
Rakarake 2026-02-08 15:38:36 +01:00
parent 7c306a2d1e
commit 30c8f4ef20
4 changed files with 21 additions and 16 deletions

View file

@ -1,9 +1,4 @@
#version 320 es #version 330 core
precision highp float;
precision highp int;
precision lowp sampler2D;
precision lowp samplerCube;
uniform vec2 WindowSize; uniform vec2 WindowSize;
uniform float time; uniform float time;

View file

@ -1,7 +1,7 @@
#version 330 core #version 330 core
out vec4 FragColor;
uniform vec2 WindowSize; uniform vec2 WindowSize;
uniform float time; uniform float time;
layout(location = 0) out vec4 color;
float rand(vec2 co){ float rand(vec2 co){
return fract(sin(dot(co, vec2(12.9898, 78.233))) * 43758.5453); return fract(sin(dot(co, vec2(12.9898, 78.233))) * 43758.5453);
@ -13,5 +13,5 @@ void main() {
vec2 uv = gl_FragCoord.xy / WindowSize; vec2 uv = gl_FragCoord.xy / WindowSize;
// grid // grid
float glob = rand(uv + time); 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);
} }

View file

@ -28,7 +28,7 @@ GLuint compile_shader(GLuint type, const char *src) {
} }
const char *vertex_shader_src = const char *vertex_shader_src =
"#version 320 es\n" "#version 330 core\n"
"\n" "\n"
"layout(location = 0) in vec2 aPos;\n" "layout(location = 0) in vec2 aPos;\n"
"\n" "\n"
@ -158,7 +158,7 @@ void render(Renderer *state, int w, int h, double time, char *shader_path, int r
// Rendorrrr // Rendorrrr
glViewport(0, 0, w, h); 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); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Shader parameters. // Shader parameters.

View file

@ -365,13 +365,17 @@ static void egl_init(struct client_state *state) {
EGL_RED_SIZE, 8, EGL_RED_SIZE, 8,
EGL_GREEN_SIZE, 8, EGL_GREEN_SIZE, 8,
EGL_BLUE_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_MIN_SWAP_INTERVAL, 0, // make sure that swapping buffers don't block the thread
EGL_NONE EGL_NONE
}; };
static const EGLint context_attribs[] = { 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 EGL_NONE
}; };
@ -391,11 +395,16 @@ static void egl_init(struct client_state *state) {
} }
printf("EGL major: %d, minor %d\n", major, minor); 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; EGLint count;
eglGetConfigs(state->egl_display, NULL, 0, &count); eglGetConfigs(state->egl_display, NULL, 0, &count);
printf("EGL has %d configs\n", count); printf("EGL has %d configs\n", count);
EGLConfig *configs = calloc(count, sizeof *configs); EGLConfig *configs = calloc(count, sizeof *configs);
EGLint n; EGLint n;
@ -415,13 +424,14 @@ static void egl_init(struct client_state *state) {
break; break;
} }
// Desktop GL?
eglBindAPI(EGL_OPENGL_API);
state->egl_context = state->egl_context =
eglCreateContext(state->egl_display, eglCreateContext(state->egl_display,
state->egl_config, state->egl_config,
EGL_NO_CONTEXT, context_attribs); EGL_NO_CONTEXT, context_attribs);
if (state->egl_context == EGL_NO_CONTEXT) {
printf("Failed to create EGL context\n");
exit(1);
}
// EGL window // EGL window
struct surface_list *next = state->surface_list; struct surface_list *next = state->surface_list;