kge/kge.cc

53 lines
1.1 KiB
C++

//
// Created by kyle on 2023-10-04.
//
#include <iostream>
#include "Platform.h"
#include "GUI.h"
static void
glfw_error_callback(int error, const char *description)
{
cerr << "GLFW error " << error << ": " << description << std::endl;
}
int
main(int argc, const char *argv[])
{
const char *glsl_version = "#version 130";
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
// Setup window
glfwSetErrorCallback(glfw_error_callback);
if (!glfwInit()) {
return 1;
}
if (window == NULL)
return 1;
glfwMakeContextCurrent(window);
glfwSwapInterval(1); // Enable vsync
bool err = glewInit() != GLEW_OK;
if (err)
{
std::cerr << "Failed to initialize OpenGL loader!" << std::endl;
return 1;
}
int screen_width, screen_height;
glfwGetFramebufferSize(window, &screen_width, &screen_height);
glViewport(0, 0, screen_width, screen_height);
IMGUI_CHECKVERSION();
ImGui::CreateContext(NULL);
ImGuiIO &io = ImGui::GetIO();
ImGui_ImplGlfw_InitForOpenGL(window, true);
ImGui_ImplOpenGL3_Init(glsl_version);
return 0;
}