Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Application.h"
- #include <iostream>
- #include "OpenGL.h"
- #include "glfw3.h"
- #include "GameTime.h"
- #include "DebugRenderer.h"
- using namespace igad;
- Appliation::Appliation(float a_fWidth, float a_fHeight)
- {
- m_pWindow = NULL;
- m_fWidth = a_fWidth;
- m_fHeight = a_fHeight;
- }
- Appliation::~Appliation()
- {
- }
- void Appliation::Run()
- {
- if (!InitGLFW()) return;
- OnCreate();
- while (!glfwWindowShouldClose(m_pWindow))
- {
- GameTime::Tick();
- glClearColor(0.04f, 0.16f, 0.22f, 1.0f);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- glEnable(GL_CULL_FACE);
- glEnable(GL_DEPTH_TEST);
- OnUpdate(GameTime::GetDeltaTime());
- OnDraw();
- glfwSwapBuffers(m_pWindow);
- glfwPollEvents();
- }
- glfwDestroyWindow(m_pWindow);
- glfwTerminate();
- }
- void Appliation::Exit() const
- {
- glfwSetWindowShouldClose(m_pWindow, true);
- }
- bool Appliation::InitGLFW()
- {
- glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
- glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
- glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
- glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
- if (!glfwInit())
- {
- std::cout << "Failed to initialize GLFW" << std::endl;
- return false;
- }
- //Create glfw window
- m_pWindow = glfwCreateWindow(m_fWidth, m_fHeight, "Demo", NULL, NULL);
- if (m_pWindow == NULL)
- {
- std::cout << "Failed to create GLFW window" << std::endl;
- glfwTerminate();
- return false;
- }
- glfwMakeContextCurrent(m_pWindow);
- int major = glfwGetWindowAttrib(m_pWindow, GLFW_CONTEXT_VERSION_MAJOR);
- int minor = glfwGetWindowAttrib(m_pWindow, GLFW_CONTEXT_VERSION_MINOR);
- int revision = glfwGetWindowAttrib(m_pWindow, GLFW_CONTEXT_REVISION);
- std::cout << "OpenGL Version " << major << "." << minor << "." << revision << std::endl;
- //Load Glad
- if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
- {
- std::cout << "Failed to initialize GLAD" << std::endl;
- return false;
- }
- glViewport(0, 0, m_fWidth, m_fHeight);
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement