fallingCand/gl_utils.h
2025-11-29 13:59:31 -08:00

28 lines
962 B
C

// gl_utils.h
#ifndef GL_UTILS_H
#define GL_UTILS_H
#include "glad/glad.h"
#define GLFW_INCLUDE_NONE
#include <GLFW/glfw3.h>
// Error callback for GLFW
void glfw_error_callback(int error, const char* description);
// Read an entire text file into a null-terminated buffer.
// Caller must free() the returned pointer.
char* load_text_file(const char* path);
// Compile a single shader from source.
GLuint compile_shader(GLenum type, const char* source, const char* debugName);
// Compile & link a vertex+fragment program from files.
GLuint create_program_from_files(const char* vsPath, const char* fsPath);
GLuint create_compute_program_from_file(const char* path);
// Minimal GLFW+GLAD init: sets error callback, (optionally) hints Wayland,
// calls glfwInit, creates window, makes context current, loads GLAD.
// Returns the created window or NULL on fatal error.
GLFWwindow* init_glfw_glad(const char* title, int width, int height);
#endif // GL_UTILS_H