restructuring

This commit is contained in:
2020-06-22 14:51:43 +02:00
parent 5365d44f9c
commit 6a1bbc27f4
8 changed files with 106 additions and 4 deletions

View File

@ -31,6 +31,15 @@ int main() {
glViewport(0, 0, 1920, 1080);
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
glfwSetInputMode(window, GLFW_STICKY_KEYS, GL_TRUE);
float vertices[] = {
-0.5f, -0.5f, 0.0f,
0.5f, -0.5f, 0.0f,
0.0f, 0.5f, 0.0f
};
unsigned int VBO;
glGenBuffers(1, &VBO);
glBindBuffer(GL_ARRAY_BUFFER, VBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
while(!glfwWindowShouldClose(window)) {
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
@ -47,3 +56,28 @@ void glfwError(int id, const char* description) {
void framebuffer_size_callback(GLFWwindow* window, int width, int height) {
glViewport(0, 0, width, height);
}
unsigned int parseShader(const char *filePath) {
FILE *fp = fopen(filePath, "rb");
size_t lSize;
char *buffer;
if(!fp) {
perror(filePath);
}
fseek(fp, 0L, SEEK_END);
lSize = ftell(fp);
rewind(fp);
buffer = malloc(lSize + 1);
if(!buffer) {
fclose(fp);
printf("out of memory");
exit(1);
}
size_t readReturn = fread(buffer, lSize, 1, fp);
fclose(fp);
if(readReturn != 1) {
printf("Can't read Shader");
exit(1);
}
printf("%s", buffer);
return 0;
}