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 16:41:03 +00:00
|
|
|
|
2024-09-27 16:31:14 +00:00
|
|
|
#include "renderer.h"
|
2024-09-27 16:41:03 +00:00
|
|
|
|
|
|
|
float verts[] {
|
2024-09-27 18:12:45 +00:00
|
|
|
// position // normals // tex coords
|
|
|
|
0.5f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
|
|
|
|
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
|
|
|
|
1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
|
2024-09-27 16:41:03 +00:00
|
|
|
};
|
|
|
|
|
2024-09-27 17:19:35 +00:00
|
|
|
Shader *shader = NULL;
|
2024-09-27 18:12:45 +00:00
|
|
|
Mesh *triangleMesh = 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 17:19:35 +00:00
|
|
|
// Compile shader
|
|
|
|
shader = new Shader("assets/shaders/orange.vs", "assets/shaders/orange.fs");
|
2024-09-27 18:12:45 +00:00
|
|
|
|
|
|
|
triangleMesh = new Mesh(3, verts);
|
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:12:45 +00:00
|
|
|
triangleMesh->bind();
|
2024-09-27 16:41:03 +00:00
|
|
|
glDrawArrays(GL_TRIANGLES, 0, 3);
|
2024-09-27 16:31:14 +00:00
|
|
|
}
|