summaryrefslogtreecommitdiff
path: root/core/src/Entrypoint/OpenGL2.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/Entrypoint/OpenGL2.cpp')
-rw-r--r--core/src/Entrypoint/OpenGL2.cpp87
1 files changed, 0 insertions, 87 deletions
diff --git a/core/src/Entrypoint/OpenGL2.cpp b/core/src/Entrypoint/OpenGL2.cpp
deleted file mode 100644
index 216399e..0000000
--- a/core/src/Entrypoint/OpenGL2.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-#include "OpenGL2.hpp"
-
-#if BUILD_CORE_WITH_OPENGL2_BACKEND
-# include <glad/glad.h>
-# include <GLFW/glfw3.h>
-# include <backend/imgui_impl_glfw.h>
-# include <backend/imgui_impl_opengl2.h>
-# include <imgui.h>
-# include <stdexcept>
-
-# define IMGUI_IMPL_OPENGL_LOADER_GLAD
-# include <backend/imgui_impl_opengl2.cpp>
-
-OpenGL2Backend::OpenGL2Backend() {
- glfwSetErrorCallback(GlfwErrorCallback);
- if (!glfwInit()) {
- throw std::runtime_error("Failed to initialize GLFW.");
- }
-
- mWindow = glfwCreateWindow(1280, 720, "Cplt", nullptr, nullptr);
- if (mWindow == nullptr) {
- throw std::runtime_error("Failed to create GLFW window.");
- }
- glfwMakeContextCurrent(mWindow);
- glfwSwapInterval(1); // Enable vsync
-
- if (gladLoadGLLoader((GLADloadproc)glfwGetProcAddress) == 0) {
- throw std::runtime_error("Failed to initialize OpenGL.");
- }
-
- IMGUI_CHECKVERSION();
- ImGui::CreateContext();
-
- ImGui_ImplGlfw_InitForOpenGL(mWindow, true);
- ImGui_ImplOpenGL2_Init();
-}
-
-OpenGL2Backend::~OpenGL2Backend() {
- ImGui_ImplOpenGL2_Shutdown();
- ImGui_ImplGlfw_Shutdown();
- ImGui::DestroyContext();
-
- glfwDestroyWindow(mWindow);
- glfwTerminate();
-}
-
-void OpenGL2Backend::BeginFrame() {
- glfwPollEvents();
-
- ImGui_ImplOpenGL2_NewFrame();
- ImGui_ImplGlfw_NewFrame();
- ImGui::NewFrame();
-}
-
-void OpenGL2Backend::EndFrame() {
- int displayWidth, displayHeight;
- glfwGetFramebufferSize(mWindow, &displayWidth, &displayHeight);
- glViewport(0, 0, displayWidth, displayHeight);
-
- const ImVec4 kClearColor = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
- glClearColor(kClearColor.x * kClearColor.w, kClearColor.y * kClearColor.w, kClearColor.z * kClearColor.w, kClearColor.w);
- glClear(GL_COLOR_BUFFER_BIT);
-
- ImGui::Render();
- ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
-
- glfwMakeContextCurrent(mWindow);
- glfwSwapBuffers(mWindow);
-}
-
-#else // ^^ BUILD_CORE_WITH_OPENGL2_BACKEND | !BUILD_CORE_WITH_OPENGL2_BACKEND vv
-# include <stdexcept>
-
-OpenGL2Backend::OpenGL2Backend() {
- throw std::runtime_error("Backend opengl2 is not available in this build.\n");
-}
-
-OpenGL2Backend::~OpenGL2Backend() {
-}
-
-void OpenGL2Backend::BeginFrame() {
-}
-
-void OpenGL2Backend::EndFrame() {
-}
-
-#endif