Create OpenGL context

This commit is contained in:
Derek Christ
2020-08-31 00:56:04 +02:00
parent cab3b9272d
commit 22eca24033
13 changed files with 261 additions and 11 deletions

35
Window.cpp Normal file
View File

@@ -0,0 +1,35 @@
#include <iostream>
#include <glad/glad.h>
#include "Window.h"
Window::Window() {
width = 800; height = 600;
window = glfwCreateWindow(width, height, "Fall-Fever", NULL, NULL);
if(!window) {
std::cout << "Failed to create window" << std::endl;
}
// Create OpenGL context
glfwMakeContextCurrent(window);
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) {
std::cout << "Failed to initialize GLAD" << std::endl;
exit(-1);
}
glViewport(0, 0, width, height);
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
}
Window::~Window() {
glfwDestroyWindow(window);
}
void Window::framebuffer_size_callback(GLFWwindow* window, int width, int height) {
(void)window;
glViewport(0, 0, width, height);
}