From 07b820f4575d2108b5675106d3ea16e83c168c22 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Thu, 16 May 2024 19:13:05 +0200 Subject: clean up garbage code i wrote 5 minutes ago --- blob | 4 ++-- config.h | 8 ++++++++ hello.frag | 3 +-- main.c | 3 ++- 4 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 config.h diff --git a/blob b/blob index 6baae9c..e0f4b4c 100755 --- a/blob +++ b/blob @@ -18,8 +18,8 @@ cat << EOF > "$base.h" #include extern const char ${symbol_base}_head; -const char* ${symbol_base} = &${symbol_base}_head; -const size_t ${symbol_base}_size = $(wc -c < "$input"); +static const char* ${symbol_base} = &${symbol_base}_head; +static const size_t ${symbol_base}_size = $(wc -c < "$input"); EOF diff --git a/config.h b/config.h new file mode 100644 index 0000000..5f0a76a --- /dev/null +++ b/config.h @@ -0,0 +1,8 @@ +// glsl doesn't support #pragma once +#ifndef _CONFIG_H +#define _CONFIG_H + +#define WIDTH 800 +#define HEIGHT 600 + +#endif diff --git a/hello.frag b/hello.frag index 291c0f1..3539bdc 100644 --- a/hello.frag +++ b/hello.frag @@ -1,7 +1,6 @@ #version 330 core -#define WIDTH 800 -#define HEIGHT 600 +#include "config.h" void main() { gl_FragColor = vec4(gl_FragCoord.x / WIDTH, gl_FragCoord.y / HEIGHT, 0, 1); diff --git a/main.c b/main.c index c7a156b..0ff0706 100644 --- a/main.c +++ b/main.c @@ -4,6 +4,7 @@ #include "shader.h" #include "die.h" +#include "config.h" #include "hello_vert.h" #include "hello_frag.h" @@ -45,7 +46,7 @@ int main(int argc, char** argv) { glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE); // initialize window - GLFWwindow* window = glfwCreateWindow(800, 600, "vis", NULL, NULL); + GLFWwindow* window = glfwCreateWindow(WIDTH, HEIGHT, "vis", NULL, NULL); if (window == NULL) die("error: could not create window\n"); glfwMakeContextCurrent(window); -- cgit v1.2.3