You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.1 KiB
52 lines
1.1 KiB
#include "GLFW/glfw3.h" |
|
#include "glad/glad.h" |
|
#include "ruc/meta/assert.h" |
|
|
|
#include "inferno/core.h" |
|
#include "inferno/io/log.h" |
|
#include "inferno/render/context.h" |
|
#include "inferno/window.h" |
|
|
|
namespace Inferno { |
|
|
|
Context::Context(GLFWwindow* window) |
|
: m_window(window) |
|
{ |
|
VERIFY(window, "Context window is nullptr!"); |
|
} |
|
|
|
void Context::initialize() |
|
{ |
|
Context::setCurrent(); |
|
|
|
// Initialize glad |
|
int glad = gladLoadGLLoader((GLADloadproc)glfwGetProcAddress); |
|
VERIFY(glad, "Failed to initialize glad!"); |
|
|
|
// Log OpenGL properties |
|
comment() << "OpenGL Info:"; |
|
comment() << " Vendor: " << glGetString(GL_VENDOR); |
|
comment() << " Renderer: " << glGetString(GL_RENDERER); |
|
comment() << " Version: " << glGetString(GL_VERSION); |
|
|
|
// Check OpenGL version |
|
VERIFY(GLVersion.major > 4 || (GLVersion.major == 4 && GLVersion.minor >= 5), |
|
"Inferno requires at least OpenGL version 4.5!"); |
|
} |
|
|
|
void Context::destroy() |
|
{ |
|
} |
|
|
|
void Context::render() |
|
{ |
|
glfwSwapBuffers(m_window); |
|
} |
|
|
|
void Context::setCurrent() |
|
{ |
|
// Set current OpenGL context to this window |
|
glfwMakeContextCurrent(m_window); |
|
} |
|
|
|
} // namespace Inferno
|
|
|