Add files via upload

This commit is contained in:
MihailRis
2021-04-25 16:08:48 +03:00
committed by GitHub
commit e1cdcf01e9
49 changed files with 2866 additions and 0 deletions
+56
View File
@@ -0,0 +1,56 @@
#include <iostream>
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include "Window.h"
GLFWwindow* Window::window;
int Window::width = 0;
int Window::height = 0;
int Window::initialize(int width, int height, const char* title){
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_RESIZABLE, GL_TRUE);
//glfwWindowHint(GLFW_SAMPLES, 2);
window = glfwCreateWindow(width, height, title, nullptr, nullptr);
if (window == nullptr){
std::cerr << "Failed to create GLFW Window" << std::endl;
glfwTerminate();
return -1;
}
glfwMakeContextCurrent(window);
glewExperimental = GL_TRUE;
if (glewInit() != GLEW_OK){
std::cerr << "Failed to initialize GLEW" << std::endl;
return -1;
}
glViewport(0,0, width, height);
Window::width = width;
Window::height = height;
return 0;
}
void Window::setCursorMode(int mode){
glfwSetInputMode(window, GLFW_CURSOR, mode);
}
void Window::terminate(){
glfwTerminate();
}
bool Window::isShouldClose(){
return glfwWindowShouldClose(window);
}
void Window::setShouldClose(bool flag){
glfwSetWindowShouldClose(window, flag);
}
void Window::swapBuffers(){
glfwSwapBuffers(window);
}