aboutsummaryrefslogtreecommitdiff
path: root/shader.c
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2024-05-18 10:58:08 +0200
committerlonkaars <loek@pipeframe.xyz>2024-05-18 10:58:08 +0200
commit1f24a2196641f7d832300fd45c7f5e89559ecc34 (patch)
treedd9316c305118d269f9043a421bf7af9273a6723 /shader.c
parente74b821cf13869a99ac2933493207680d6666186 (diff)
more problem isolation
Diffstat (limited to 'shader.c')
-rw-r--r--shader.c52
1 files changed, 0 insertions, 52 deletions
diff --git a/shader.c b/shader.c
deleted file mode 100644
index 6831b28..0000000
--- a/shader.c
+++ /dev/null
@@ -1,52 +0,0 @@
-#include "shader.h"
-
-#include "die.h"
-
-void check_shader(GLuint shader) {
- int success;
- char debug[LOG_MAX];
- glGetShaderiv(shader, GL_COMPILE_STATUS, &success);
- if (success) return;
- glGetShaderInfoLog(shader, LOG_MAX, NULL, debug);
- die("error: shader compilation failed!\n%s", debug);
-}
-
-void check_program(GLuint program) {
- int success;
- char debug[LOG_MAX];
- glGetProgramiv(program, GL_LINK_STATUS, &success);
- if (success) return;
- glGetProgramInfoLog(program, LOG_MAX, NULL, debug);
- die("error: shader linking failed!\n%s", debug);
-}
-
-GLuint load_shader(GLenum type, const char* const src, size_t src_size) {
- GLuint shader = glCreateShader(type);
- glShaderBinary(1, &shader, GL_SHADER_BINARY_FORMAT_SPIR_V_ARB, src, src_size);
- glSpecializeShaderARB(shader, "main", 0, 0, 0);
- check_shader(shader);
- return shader;
-}
-
-GLuint frag_shader(const char* const src, size_t src_size) {
- return load_shader(GL_FRAGMENT_SHADER, src, src_size);
-}
-GLuint vert_shader(const char* const src, size_t src_size) {
- return load_shader(GL_VERTEX_SHADER, src, src_size);
-}
-
-GLuint link_shaders(GLuint vert, GLuint frag) {
- GLuint shader = glCreateProgram();
- glAttachShader(shader, vert);
- glAttachShader(shader, frag);
- glLinkProgram(shader);
-
- check_program(shader);
-
- glUseProgram(shader);
-
- glDeleteShader(vert);
- glDeleteShader(frag);
- return shader;
-}
-