compile shaders

This commit is contained in:
Luca Conte 2025-03-06 01:30:26 +01:00
parent 6f5873c8be
commit 5d3fb630c9
1 changed files with 38 additions and 1 deletions

View File

@ -1,8 +1,38 @@
#include <GL/glew.h> #include <GL/glew.h>
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
#include <stdio.h> #include <stdio.h>
#include <string.h>
#include "shader.h"
#include "log.h"
#include "src/shader.h"
void init(void) { void init(void) {
INFO("Compiling Shaders...\n");
// create and compile vertex shader
INFO("Compiling Vertex Shader...\n");
ShaderCompileResult vertexShader = readAndCompileShaderFromFile("src/shaders/vertex.glsl", GL_VERTEX_SHADER);
// create and compile fragment shader
ShaderCompileResult fragmentShader = readAndCompileShaderFromFile("src/shaders/fragment.glsl", GL_FRAGMENT_SHADER);
if (!vertexShader.success) {
FATAL("Failed to compile Vertex Shader\n");
exit(1);
}
if (!fragmentShader.success) {
FATAL("Failed to compile Vertex Shader\n");
exit(1);
}
// create and link shader program
// create triangle buffer
// create vertex array object
glClearColor(0.1f, 0.1f, 0.1f, 1.0f); glClearColor(0.1f, 0.1f, 0.1f, 1.0f);
} }
@ -16,6 +46,13 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) {
int main(int argc, char const *argv[]) int main(int argc, char const *argv[])
{ {
for (int i = 1; i < argc; i++) {
if (strcmp(argv[i], "-v") == 0) {
logLevel = LOG_LEVEL_DEBUG;
}
}
glfwInit(); glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);