90 lines
1.6 KiB
C++
90 lines
1.6 KiB
C++
#define CIMGUI_DEFINE_ENUMS_AND_STRUCTS
|
|
|
|
#include <GL/gl.h>
|
|
#include <GLFW/glfw3.h>
|
|
#include <imgui/cimgui.h>
|
|
#include <imgui/imgui_impl_opengl3.h>
|
|
#include <imgui/imgui_impl_glfw.h>
|
|
|
|
extern "C" {
|
|
#include "ui.h"
|
|
}
|
|
|
|
#define WIDTH 400
|
|
#define HEIGHT 200
|
|
|
|
void glfw_logger(int error, const char *desc)
|
|
{
|
|
fprintf(stderr, "Erreur %d GLFW: %s\n", error, desc);
|
|
}
|
|
|
|
int main(void)
|
|
{
|
|
GLFWwindow* window;
|
|
|
|
ImGuiContext *ctx;
|
|
ImGuiIO *io;
|
|
|
|
const char *glsl_version;
|
|
|
|
if (!glfwInit())
|
|
{
|
|
fprintf(stderr, "Erreur à l'initialisation de GLFW.\n");
|
|
return -1;
|
|
}
|
|
|
|
glfwSetErrorCallback(glfw_logger);
|
|
|
|
glfwWindowHint(GLFW_RESIZABLE, 0);
|
|
window = glfwCreateWindow(WIDTH, HEIGHT, "Macros", NULL, NULL);
|
|
if (!window)
|
|
{
|
|
fprintf(stderr, "Erreur lors de la création de la fenêtre GLFW.\n");
|
|
glfwTerminate();
|
|
return -1;
|
|
}
|
|
|
|
glfwMakeContextCurrent(window);
|
|
|
|
ctx = igCreateContext(NULL);
|
|
io = igGetIO();
|
|
|
|
glsl_version = "#version 330 core";
|
|
ImGui_ImplGlfw_InitForOpenGL(window, true);
|
|
ImGui_ImplOpenGL3_Init(glsl_version);
|
|
|
|
igStyleColorsDark(NULL);
|
|
|
|
char is_recording = 0;
|
|
char *name = "fichier.macros";
|
|
|
|
ui_infos *ui = init_ui(name);
|
|
|
|
while (!glfwWindowShouldClose(window))
|
|
{
|
|
glfwPollEvents();
|
|
|
|
ImGui_ImplOpenGL3_NewFrame();
|
|
ImGui_ImplGlfw_NewFrame();
|
|
igNewFrame();
|
|
|
|
if (draw_ui(ui)) break;
|
|
|
|
igRender();
|
|
glClear(GL_COLOR_BUFFER_BIT);
|
|
ImGui_ImplOpenGL3_RenderDrawData(igGetDrawData());
|
|
glfwSwapBuffers(window);
|
|
}
|
|
|
|
free_ui(ui);
|
|
|
|
ImGui_ImplOpenGL3_Shutdown();
|
|
ImGui_ImplGlfw_Shutdown();
|
|
igDestroyContext(ctx);
|
|
|
|
glfwDestroyWindow(window);
|
|
glfwTerminate();
|
|
|
|
return 0;
|
|
}
|