| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- #include "Application.hpp"
- Application::Application(int width, int height) : m_window_width(width), m_window_heigth(height)
- {
- }
- Application::~Application()
- {
- glfwTerminate();
- }
- void Application::init()
- {
- glfwInit();
- glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
- glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
- glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
- }
- void Application::terminate()
- {
- glfwTerminate();
- }
- bool Application::createWindow()
- {
- window = glfwCreateWindow(m_window_width, m_window_heigth, m_appName.c_str(), nullptr, nullptr);
- if(window == nullptr){
- std::cout << "glfwCreateWindow failed" << std::endl;
- terminate();
- return false;
- }
- glfwMakeContextCurrent(window);
-
- if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
- {
- std::cout << "Failed to initialize GLAD" << std::endl;
- terminate();
- return false;
- }
- glViewport(0, 0, m_window_width, m_window_heigth);
- return true;
- }
- bool Application::running()
- {
- return !glfwWindowShouldClose(window);
- }
- void Application::render()
- {
- glfwSwapBuffers(window);
- glfwPollEvents();
- }
|