Basic Window
This commit is contained in:
parent
b045b1e2d3
commit
8d28b81b89
38
src/main.cpp
38
src/main.cpp
@ -1,6 +1,40 @@
|
|||||||
#include <glad/glad.h>
|
#include <glad/glad.h>
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
int main(void){
|
#define UNUSED(x) (void)(x)
|
||||||
|
|
||||||
|
void framebuffer_size_callback(GLFWwindow* window, int width, int height);
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
int tmp = 0;
|
||||||
|
|
||||||
|
glfwInit();
|
||||||
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||||
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
||||||
|
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||||
|
|
||||||
|
GLFWwindow *window = glfwCreateWindow(800, 600, "LearnOpenGL", NULL, NULL);
|
||||||
|
assert(window != NULL && "Window Failed");
|
||||||
|
glfwMakeContextCurrent(window);
|
||||||
|
|
||||||
|
tmp = gladLoadGLLoader((GLADloadproc)glfwGetProcAddress);
|
||||||
|
assert(tmp && "Failed to init glad");
|
||||||
|
|
||||||
|
glViewport(0, 0, 800, 600);
|
||||||
|
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
|
||||||
|
|
||||||
|
while(!glfwWindowShouldClose(window))
|
||||||
|
{
|
||||||
|
glfwSwapBuffers(window);
|
||||||
|
glfwPollEvents();
|
||||||
|
}
|
||||||
|
|
||||||
|
glfwTerminate();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void framebuffer_size_callback(GLFWwindow* window, int width, int height) {
|
||||||
|
UNUSED(window);
|
||||||
|
glViewport(0, 0, width, height);
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user