engineer-thesis-WUT/Engine/engine/match.cpp

59 lines
1.7 KiB
C++
Raw Normal View History

2022-08-28 19:20:00 +02:00
#include <glad/glad.h>
2022-08-27 21:43:58 +02:00
#include <GLFW/glfw3.h>
2022-08-28 19:20:00 +02:00
#include <iostream>
2022-08-27 21:43:58 +02:00
2022-08-28 19:20:00 +02:00
void e() { std::cout << "breakpoint" << std::endl; };
void instantiateGLFWWindow()
{
glfwInit(); // we initialize glfw
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
// we configure glfw ,
// first argument is what option we want to configure, // the second sets the value of the option
// see: https://www.glfw.org/docs/latest/window.html#window_hints
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
// We tell glfw we want to use smaller subset of OGL features without backwards-compatible one
//glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
// We would use this one if we worked on macOs
}
int createWindowObject()
{
GLFWwindow* window = glfwCreateWindow(800, 600, "LearnOpenGL", NULL, NULL);
// we provide width and height of window
// then name of the window
// we ignore last 2 parameters
// function returns GLFW window object that we will use for other glfw operations
if (window == NULL)
2022-08-27 21:43:58 +02:00
{
2022-08-28 19:20:00 +02:00
std::cout << "Failed to create GLFW window" << std::endl;
2022-08-27 21:43:58 +02:00
glfwTerminate();
return -1;
}
2022-08-28 19:20:00 +02:00
// context of our window becomes the main context of current thread
2022-08-27 21:43:58 +02:00
glfwMakeContextCurrent(window);
2022-08-28 19:20:00 +02:00
return 0;
}
2022-08-27 21:43:58 +02:00
2022-08-28 19:20:00 +02:00
int initializeGLAD()
{
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
2022-08-27 21:43:58 +02:00
{
2022-08-28 19:20:00 +02:00
std::cout << "Failed to initialize GLAD" << std::endl;
return -1;
}
return 0;
}
2022-08-27 21:43:58 +02:00
2022-08-28 19:20:00 +02:00
int main()
{
if(initializeGLAD() == -1) return -1;
instantiateGLFWWindow();
if(createWindowObject() == -1) return -1;
e();
2022-08-27 21:43:58 +02:00
return 0;
2022-08-28 19:20:00 +02:00
2022-08-25 17:17:53 +02:00
}