openblocks/src/renderer.cpp

30 lines
607 B
C++
Raw Normal View History

2024-09-27 16:41:03 +00:00
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <GL/gl.h>
2024-09-27 17:19:35 +00:00
#include "shader.h"
2024-09-27 18:12:45 +00:00
#include "mesh.h"
2024-09-27 18:26:14 +00:00
#include "defaultmeshes.h"
2024-09-27 16:41:03 +00:00
2024-09-27 16:31:14 +00:00
#include "renderer.h"
2024-09-27 16:41:03 +00:00
2024-09-27 17:19:35 +00:00
Shader *shader = NULL;
2024-09-27 16:31:14 +00:00
void renderInit(GLFWwindow* window) {
2024-09-27 16:41:03 +00:00
glViewport(0, 0, 500, 500);
2024-09-27 18:26:14 +00:00
initMeshes();
2024-09-27 17:19:35 +00:00
// Compile shader
shader = new Shader("assets/shaders/orange.vs", "assets/shaders/orange.fs");
2024-09-27 16:31:14 +00:00
}
void render(GLFWwindow* window) {
glClearColor(0.1f, 0.1f, 0.1f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
2024-09-27 16:41:03 +00:00
2024-09-27 17:19:35 +00:00
// Use shader
shader->use();
2024-09-27 18:26:14 +00:00
CUBE_MESH->bind();
glDrawArrays(GL_TRIANGLES, 0, 36);
2024-09-27 16:31:14 +00:00
}