2024-09-27 16:41:03 +00:00
|
|
|
#include <GL/glew.h>
|
|
|
|
#include <GLFW/glfw3.h>
|
|
|
|
#include <GL/gl.h>
|
|
|
|
|
2024-09-27 16:31:14 +00:00
|
|
|
#include "renderer.h"
|
2024-09-27 16:41:03 +00:00
|
|
|
|
|
|
|
float verts[] {
|
|
|
|
0.5f, 1.0f, 0.0f,
|
|
|
|
0.0f, 0.0f, 0.0f,
|
|
|
|
1.0f, 0.0f, 0.0f,
|
|
|
|
};
|
|
|
|
|
|
|
|
unsigned int VAO, VBO;
|
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);
|
|
|
|
|
|
|
|
glGenBuffers(1, &VBO);
|
|
|
|
glGenVertexArrays(1, &VAO);
|
|
|
|
|
|
|
|
// Bind vertex data to VBO
|
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, VBO);
|
|
|
|
glBufferData(GL_ARRAY_BUFFER, sizeof(verts), verts, GL_STATIC_DRAW);
|
|
|
|
|
|
|
|
// Bind vertex attributes to VAO
|
|
|
|
glBindVertexArray(VAO);
|
|
|
|
|
|
|
|
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), (void*)0);
|
|
|
|
glEnableVertexAttribArray(0);
|
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
|
|
|
|
|
|
|
glBindVertexArray(VAO);
|
|
|
|
glDrawArrays(GL_TRIANGLES, 0, 3);
|
2024-09-27 16:31:14 +00:00
|
|
|
}
|