GLAD liberay
This commit is contained in:
22
src/main.c
22
src/main.c
@ -1,7 +1,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <GL/glew.h>
|
||||
#include <glad/glad.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
#include "main.h"
|
||||
|
||||
@ -24,8 +24,26 @@ int main() {
|
||||
return -1;
|
||||
}
|
||||
glfwMakeContextCurrent(window);
|
||||
glewExperimental = true;
|
||||
if(!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) {
|
||||
printf("Failed to initialize GLAD\n");
|
||||
return -1;
|
||||
}
|
||||
glViewport(0, 0, 1920, 1080);
|
||||
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
|
||||
glfwSetInputMode(window, GLFW_STICKY_KEYS, GL_TRUE);
|
||||
while(!glfwWindowShouldClose(window)) {
|
||||
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
glfwSwapBuffers(window);
|
||||
glfwPollEvents();
|
||||
}
|
||||
glfwTerminate();
|
||||
return 0;
|
||||
}
|
||||
void glfwError(int id, const char* description) {
|
||||
printf("Glfw Error: %s\n", description);
|
||||
}
|
||||
|
||||
void framebuffer_size_callback(GLFWwindow* window, int width, int height) {
|
||||
glViewport(0, 0, width, height);
|
||||
}
|
||||
|
||||
@ -1,4 +1,7 @@
|
||||
#ifndef main_h
|
||||
#define main_h
|
||||
#include <glad/glad.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
void glfwError(int id, const char* description);
|
||||
void framebuffer_size_callback(GLFWwindow* window, int width, int height);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user