summaryrefslogtreecommitdiffhomepage
path: root/src/window.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/window.cpp')
-rw-r--r--src/window.cpp84
1 files changed, 43 insertions, 41 deletions
diff --git a/src/window.cpp b/src/window.cpp
index f1a6c46..c091b42 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -9,57 +9,59 @@
// std libs
#include <iostream>
-namespace Window {
- namespace { // private
- GLFWwindow* window;
+namespace Ogle {
+ namespace Window {
+ namespace { // private
+ GLFWwindow* window;
- void framebuffer_size_callback(GLFWwindow* window, int width, int height)
- {
- glViewport(0, 0, width, height);
+ void framebuffer_size_callback(GLFWwindow* window, int width, int height)
+ {
+ glViewport(0, 0, width, height);
+ }
}
- }
-
- GLFWwindow* get()
- {
- return window;
- }
-
- int init(
- unsigned int width,
- unsigned int height,
- const char* title
- )
- {
- glfwInit();
- glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); // 4.6 is highest, but lets use 3.3 for compatability
- glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
- glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
- glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
-
- glfwSwapInterval(1);
- window = glfwCreateWindow(width, height, title, NULL, NULL);
- if (window == NULL)
+ GLFWwindow* get()
{
- std::cout << "Failed to create GLFW window" << std::endl;
- glfwTerminate();
- return -1;
+ return window;
}
- glfwMakeContextCurrent(window);
- if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
+ int init(
+ unsigned int width,
+ unsigned int height,
+ const char* title
+ )
{
- std::cout << "Failed to init GLAD" << std::endl;
- return -1;
- }
+ glfwInit();
+ glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); // 4.6 is highest, but lets use 3.3 for compatability
+ glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
+ glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
+ glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
+
+ glfwSwapInterval(1);
+
+ window = glfwCreateWindow(width, height, title, NULL, NULL);
+ if (window == NULL)
+ {
+ std::cout << "Failed to create GLFW window" << std::endl;
+ glfwTerminate();
+ return -1;
+ }
+ glfwMakeContextCurrent(window);
- glViewport(0, 0, width, height);
+ if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
+ {
+ std::cout << "Failed to init GLAD" << std::endl;
+ return -1;
+ }
- glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
+ glViewport(0, 0, width, height);
+
+ glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- return 0;
+ return 0;
+ }
}
}