mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-22 02:12:45 +01:00
imgui changes
This commit is contained in:
parent
c54d9ed2e2
commit
cf38b449c5
5
external/imgui/CMakeLists.txt
vendored
5
external/imgui/CMakeLists.txt
vendored
@ -21,6 +21,11 @@ target_compile_definitions(imgui
|
||||
IMGUI_USER_CONFIG="${CMAKE_CURRENT_SOURCE_DIR}/rw_imconfig.h"
|
||||
)
|
||||
|
||||
target_link_libraries(imgui
|
||||
PUBLIC
|
||||
openrw::checks
|
||||
)
|
||||
|
||||
add_library(imgui::core ALIAS imgui)
|
||||
|
||||
openrw_target_apply_options(
|
||||
|
@ -56,8 +56,7 @@ void RWImGui::tick() {
|
||||
ImGui::SetCurrentContext(_context);
|
||||
auto& io = ImGui::GetIO();
|
||||
|
||||
SDL_Window *window;
|
||||
std::tie(window, std::ignore) = _game.getWindow().getSDLContext();
|
||||
auto [window, sdl_glcontext] = _game.getWindow().getSDLContext();
|
||||
|
||||
ImGui_ImplOpenGL3_NewFrame();
|
||||
ImGui_ImplSDL2_NewFrame(window);
|
||||
@ -79,82 +78,6 @@ void RWImGui::tick() {
|
||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||
}
|
||||
|
||||
static ImGuiIO *g_io;
|
||||
|
||||
static SDL_Window *g_sdl_window;
|
||||
static SDL_GLContext g_sdl_gl_context;
|
||||
|
||||
|
||||
void imgui_init(SDL_Window *sdl_window, SDL_GLContext sdl_gl_context) {
|
||||
IMGUI_CHECKVERSION();
|
||||
ImGui::CreateContext();
|
||||
g_io = &ImGui::GetIO();
|
||||
|
||||
g_sdl_window = sdl_window;
|
||||
g_sdl_gl_context = sdl_gl_context;
|
||||
|
||||
ImGui_ImplSDL2_InitForOpenGL(sdl_window, sdl_gl_context);
|
||||
ImGui_ImplOpenGL3_Init("#version 150");
|
||||
|
||||
// ImGui::StyleColorsDark();
|
||||
// ImGui::StyleColorsClassic();
|
||||
ImGui::StyleColorsLight();
|
||||
|
||||
|
||||
// Build atlas
|
||||
unsigned char* tex_pixels = NULL;
|
||||
int tex_w, tex_h;
|
||||
g_io->Fonts->GetTexDataAsRGBA32(&tex_pixels, &tex_w, &tex_h);
|
||||
}
|
||||
|
||||
void imgui_process_event(SDL_Event *event, bool *mouse, bool *keyboard) {
|
||||
ImGui_ImplSDL2_ProcessEvent(event);
|
||||
*mouse = g_io->WantCaptureMouse;
|
||||
*keyboard = g_io->WantCaptureKeyboard;
|
||||
}
|
||||
|
||||
static bool show_demo_window = true;
|
||||
|
||||
void imgui_tick() {
|
||||
ImGui_ImplOpenGL3_NewFrame();
|
||||
ImGui_ImplSDL2_NewFrame(g_sdl_window);
|
||||
ImGui::NewFrame();
|
||||
|
||||
// g_io->DisplaySize = ImVec2(1920, 1080);
|
||||
// g_io->DeltaTime = 1.0f / 60.0f;
|
||||
|
||||
static float f = 0.0f;
|
||||
|
||||
ImGui::Begin("Hello, world!");
|
||||
ImGui::Text("Hello, world!");
|
||||
ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
|
||||
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", static_cast<double>(1000.0f / g_io->Framerate), static_cast<double>(g_io->Framerate));
|
||||
ImGui::End();
|
||||
|
||||
if (show_demo_window) {
|
||||
ImGui::ShowDemoWindow(&show_demo_window);
|
||||
}
|
||||
|
||||
// ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
|
||||
|
||||
ImGui::Render();
|
||||
// SDL_GL_MakeCurrent(g_sdl_window, g_sdl_gl_context);
|
||||
// glViewport(0, 0, static_cast<int>(g_io->DisplaySize.x), static_cast<int>(g_io->DisplaySize.y));
|
||||
// glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
|
||||
// glClear(GL_COLOR_BUFFER_BIT);
|
||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||
// SDL_GL_SwapWindow(g_sdl_window);
|
||||
}
|
||||
|
||||
void imgui_destroy() {
|
||||
ImGui_ImplOpenGL3_Shutdown();
|
||||
ImGui_ImplSDL2_Shutdown();
|
||||
ImGui::DestroyContext();
|
||||
g_io = nullptr;
|
||||
g_sdl_gl_context = nullptr;
|
||||
g_sdl_window = nullptr;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
RWImGui::RWImGui(RWGame &game)
|
||||
|
Loading…
Reference in New Issue
Block a user