diff options
| author | realtradam <[email protected]> | 2022-11-26 16:46:01 -0500 |
|---|---|---|
| committer | realtradam <[email protected]> | 2022-11-26 16:46:01 -0500 |
| commit | 368269070f851ff78a1bce35c1d993d5f02cc5f9 (patch) | |
| tree | 83292448b320f561148f16efdbb456c85ab00f87 /src/window.cpp | |
| parent | 68486053b032fd3313c887ea7d73064e59dce570 (diff) | |
| download | Ogle-368269070f851ff78a1bce35c1d993d5f02cc5f9.tar.gz Ogle-368269070f851ff78a1bce35c1d993d5f02cc5f9.zip | |
namespace it all
Diffstat (limited to 'src/window.cpp')
| -rw-r--r-- | src/window.cpp | 84 |
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; + } } } |
