-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathIMGUI.cpp
More file actions
37 lines (30 loc) · 1.06 KB
/
IMGUI.cpp
File metadata and controls
37 lines (30 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "IMGUI.hpp"
#include "helpers/imgui/imgui_impl_sdl.h"
#include "helpers/imgui/imgui_impl_opengl3.h"
#include <SDL2/SDL.h>
struct jzj::IMGUIcontext::implementation {
jzj::GLContextDisplay *display;
};
jzj::IMGUIcontext::IMGUIcontext(jzj::GLContextDisplay *display, void (*styleFunction)(ImGuiStyle* style)) : impl(new implementation){
this->impl->display = display;
IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGuiIO &io = ImGui::GetIO(); (void)io;
styleFunction(&ImGui::GetStyle());
ImGui_ImplSDL2_InitForOpenGL((SDL_Window *)display->getWindow(), display->getContext());
ImGui_ImplOpenGL3_Init(NULL);
}
jzj::IMGUIcontext::~IMGUIcontext() {
ImGui_ImplOpenGL3_Shutdown();
ImGui_ImplSDL2_Shutdown();
ImGui::DestroyContext();
}
void jzj::IMGUIcontext::update() {
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplSDL2_NewFrame((SDL_Window *)this->impl->display->getWindow());
ImGui::NewFrame();
}
void jzj::IMGUIcontext::render() {
ImGui::Render();
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
}