mirror of https://github.com/inolen/redream.git
add ENABLE_IMGUI
This commit is contained in:
parent
bb67d95860
commit
b8da4eada6
|
@ -24,7 +24,6 @@ endif()
|
|||
option(BUILD_LIBRETRO "Build libretro core" OFF)
|
||||
option(BUILD_TOOLS "Build tools" OFF)
|
||||
option(BUILD_TESTS "Build tests" OFF)
|
||||
option(ENABLE_MICROPROFILE "Enable MicroProfile" ON)
|
||||
|
||||
if(WIN32 OR MINGW)
|
||||
set(PLATFORM_WINDOWS TRUE)
|
||||
|
@ -98,6 +97,18 @@ list(APPEND REDREAM_INCLUDES deps/glew-1.13.0/include)
|
|||
list(APPEND REDREAM_LIBS glew_s)
|
||||
list(APPEND REDREAM_DEFS GLEW_STATIC)
|
||||
|
||||
# inih
|
||||
add_library(inih STATIC deps/inih/ini.c)
|
||||
list(APPEND REDREAM_INCLUDES deps/inih)
|
||||
list(APPEND REDREAM_LIBS inih)
|
||||
|
||||
# xbyak
|
||||
list(APPEND REDREAM_INCLUDES deps/xbyak-4.901)
|
||||
|
||||
#--------------------------------------------------
|
||||
# optional libs
|
||||
#--------------------------------------------------
|
||||
|
||||
# imgui
|
||||
add_library(imgui STATIC
|
||||
deps/cimgui/imgui/imgui.cpp
|
||||
|
@ -108,22 +119,10 @@ add_library(imgui STATIC
|
|||
deps/cimgui/cimgui/fontAtlas.cpp
|
||||
deps/cimgui/cimgui/listClipper.cpp)
|
||||
list(APPEND REDREAM_INCLUDES deps/cimgui)
|
||||
list(APPEND REDREAM_LIBS imgui)
|
||||
|
||||
# inih
|
||||
add_library(inih STATIC deps/inih/ini.c)
|
||||
list(APPEND REDREAM_INCLUDES deps/inih)
|
||||
list(APPEND REDREAM_LIBS inih)
|
||||
list(APPEND IMGUI_LIBS imgui)
|
||||
|
||||
# microprofile
|
||||
list(APPEND MICROPROFILE_INCLUDES deps/microprofile)
|
||||
|
||||
# xbyak
|
||||
list(APPEND REDREAM_INCLUDES deps/xbyak-4.901)
|
||||
|
||||
#--------------------------------------------------
|
||||
# optional libs
|
||||
#--------------------------------------------------
|
||||
list(APPEND REDREAM_INCLUDES deps/microprofile)
|
||||
|
||||
# sdl2
|
||||
if(NOT BUILD_LIBRETRO)
|
||||
|
@ -142,7 +141,7 @@ if(APPLE)
|
|||
set(SDL_FRAMEWORK_CARBON 1)
|
||||
endif()
|
||||
add_subdirectory(deps/sdl2-2.0.5 EXCLUDE_FROM_ALL)
|
||||
list(APPEND SDL_INCLUDE_DIRS deps/sdl2-2.0.5/include)
|
||||
list(APPEND REDREAM_INCLUDES deps/sdl2-2.0.5/include)
|
||||
if(MINGW)
|
||||
list(APPEND SDL_LIBS mingw32)
|
||||
endif()
|
||||
|
@ -341,15 +340,18 @@ set(REDREAM_SDL_SOURCES
|
|||
source_group_by_dir(REDREAM_SDL_SOURCES)
|
||||
|
||||
add_executable(redream ${REDREAM_SDL_SOURCES})
|
||||
target_include_directories(redream SYSTEM PUBLIC ${REDREAM_INCLUDES} ${MICROPROFILE_INCLUDE_DIRS} ${SDL_INCLUDE_DIRS})
|
||||
target_include_directories(redream SYSTEM PUBLIC ${REDREAM_INCLUDES})
|
||||
target_include_directories(redream PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
||||
target_link_libraries(redream ${REDREAM_LIBS} ${SDL_LIBS})
|
||||
target_compile_definitions(redream PRIVATE ${REDREAM_DEFS})
|
||||
target_compile_options(redream PRIVATE ${REDREAM_FLAGS})
|
||||
|
||||
if(ENABLE_MICROPROFILE)
|
||||
target_compile_definitions(redream PRIVATE ENABLE_MICROPROFILE=1)
|
||||
endif()
|
||||
# enable imgui
|
||||
target_link_libraries(redream ${IMGUI_LIBS})
|
||||
target_compile_definitions(redream PRIVATE ENABLE_IMGUI=1)
|
||||
|
||||
# enable microprofile
|
||||
target_compile_definitions(redream PRIVATE ENABLE_MICROPROFILE=1)
|
||||
|
||||
#--------------------------------------------------
|
||||
# recc
|
||||
|
|
|
@ -453,6 +453,7 @@ static void emu_paint(struct emu *emu) {
|
|||
r_end_ui_surfaces(emu->r);
|
||||
}
|
||||
|
||||
#if ENABLE_IMGUI
|
||||
if (emu->debug_menu) {
|
||||
if (igBeginMainMenuBar()) {
|
||||
if (igBeginMenu("DEBUG", 1)) {
|
||||
|
@ -503,6 +504,7 @@ static void emu_paint(struct emu *emu) {
|
|||
igEndMainMenuBar();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
imgui_render(emu->imgui);
|
||||
mp_render(emu->mp);
|
||||
|
|
|
@ -835,6 +835,7 @@ void aica_set_clock(struct aica *aica, uint32_t time) {
|
|||
aica->rtc = time;
|
||||
}
|
||||
|
||||
#if ENABLE_IMGUI
|
||||
void aica_debug_menu(struct aica *aica) {
|
||||
if (igBeginMainMenuBar()) {
|
||||
if (igBeginMenu("AICA", 1)) {
|
||||
|
@ -851,6 +852,7 @@ void aica_debug_menu(struct aica *aica) {
|
|||
igEndMainMenuBar();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void aica_destroy(struct aica *aica) {
|
||||
/* shutdown rtc */
|
||||
|
|
|
@ -329,6 +329,7 @@ static int bios_boot(struct bios *bios) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
#if ENABLE_IMGUI
|
||||
void bios_debug_menu(struct bios *bios) {
|
||||
int changed = 0;
|
||||
|
||||
|
@ -382,6 +383,7 @@ void bios_debug_menu(struct bios *bios) {
|
|||
LOG_WARNING("bios settings changed, restart for changes to take effect");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
int bios_invalid_instr(struct bios *bios) {
|
||||
struct dreamcast *dc = bios->dc;
|
||||
|
|
|
@ -325,6 +325,7 @@ void holly_raise_interrupt(struct holly *hl, holly_interrupt_t intr) {
|
|||
}
|
||||
}
|
||||
|
||||
#if ENABLE_IMGUI
|
||||
void holly_debug_menu(struct holly *hl) {
|
||||
if (igBeginMainMenuBar()) {
|
||||
if (igBeginMenu("HOLLY", 1)) {
|
||||
|
@ -350,6 +351,7 @@ void holly_debug_menu(struct holly *hl) {
|
|||
igEndMainMenuBar();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void holly_destroy(struct holly *hl) {
|
||||
dc_destroy_device((struct device *)hl);
|
||||
|
|
|
@ -209,6 +209,7 @@ void sh4_reset(struct sh4 *sh4, uint32_t pc) {
|
|||
sh4->execute_if->running = 1;
|
||||
}
|
||||
|
||||
#if ENABLE_IMGUI
|
||||
void sh4_debug_menu(struct sh4 *sh4) {
|
||||
struct jit *jit = sh4->jit;
|
||||
|
||||
|
@ -235,6 +236,7 @@ void sh4_debug_menu(struct sh4 *sh4) {
|
|||
igEndMainMenuBar();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void sh4_destroy(struct sh4 *sh4) {
|
||||
jit_destroy(sh4->jit);
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
#if ENABLE_IMGUI
|
||||
#include <imgui/imgui.h>
|
||||
#endif
|
||||
|
||||
extern "C" {
|
||||
#include "core/assert.h"
|
||||
|
@ -14,6 +16,7 @@ struct imgui {
|
|||
};
|
||||
|
||||
extern "C" void imgui_render(struct imgui *imgui) {
|
||||
#if ENABLE_IMGUI
|
||||
ImGuiIO &io = ImGui::GetIO();
|
||||
|
||||
/* update draw batches. note, this doesn't _actually_ render anything because
|
||||
|
@ -61,9 +64,11 @@ extern "C" void imgui_render(struct imgui *imgui) {
|
|||
|
||||
r_end_ui_surfaces(imgui->r);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
extern "C" void imgui_update_input(struct imgui *imgui) {
|
||||
#if ENABLE_IMGUI
|
||||
ImGuiIO &io = ImGui::GetIO();
|
||||
|
||||
int width = r_viewport_width(imgui->r);
|
||||
|
@ -75,10 +80,12 @@ extern "C" void imgui_update_input(struct imgui *imgui) {
|
|||
|
||||
/* reset mouse scroll state */
|
||||
io.MouseWheel = 0.0;
|
||||
#endif
|
||||
}
|
||||
|
||||
extern "C" void imgui_keydown(struct imgui *imgui, enum keycode code,
|
||||
int16_t value) {
|
||||
#if ENABLE_IMGUI
|
||||
ImGuiIO &io = ImGui::GetIO();
|
||||
|
||||
if (code == K_MWHEELUP) {
|
||||
|
@ -91,7 +98,6 @@ extern "C" void imgui_keydown(struct imgui *imgui, enum keycode code,
|
|||
io.MouseDown[1] = value > 0;
|
||||
} else if (code == K_MOUSE3) {
|
||||
io.MouseDown[2] = value > 0;
|
||||
;
|
||||
} else if (code == K_LALT || code == K_RALT) {
|
||||
imgui->alt[code == K_LALT ? 0 : 1] = !!value;
|
||||
io.KeyAlt = imgui->alt[0] || imgui->alt[1];
|
||||
|
@ -104,21 +110,27 @@ extern "C" void imgui_keydown(struct imgui *imgui, enum keycode code,
|
|||
} else {
|
||||
io.KeysDown[code] = value > 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
extern "C" void imgui_mousemove(struct imgui *imgui, int x, int y) {
|
||||
#if ENABLE_IMGUI
|
||||
ImGuiIO &io = ImGui::GetIO();
|
||||
|
||||
io.MousePos = ImVec2((float)x, (float)y);
|
||||
#endif
|
||||
}
|
||||
|
||||
extern "C" void imgui_destroy(struct imgui *imgui) {
|
||||
#if ENABLE_IMGUI
|
||||
ImGui::Shutdown();
|
||||
|
||||
free(imgui);
|
||||
#endif
|
||||
}
|
||||
|
||||
extern "C" struct imgui *imgui_create(struct render_backend *r) {
|
||||
#if ENABLE_IMGUI
|
||||
struct imgui *imgui =
|
||||
reinterpret_cast<struct imgui *>(calloc(1, sizeof(struct imgui)));
|
||||
|
||||
|
@ -168,4 +180,7 @@ extern "C" struct imgui *imgui_create(struct render_backend *r) {
|
|||
io.Fonts->TexID = reinterpret_cast<void *>(static_cast<intptr_t>(handle));
|
||||
|
||||
return imgui;
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
#ifndef IMGUI_H
|
||||
#define IMGUI_H
|
||||
|
||||
#include "host/keycode.h"
|
||||
|
||||
#if ENABLE_IMGUI
|
||||
#define CIMGUI_DEFINE_ENUMS_AND_STRUCTS
|
||||
#include <cimgui/cimgui.h>
|
||||
#include "host/keycode.h"
|
||||
#endif
|
||||
|
||||
struct imgui;
|
||||
struct render_backend;
|
||||
|
|
|
@ -275,16 +275,16 @@ void mp_keydown(struct microprofile *mp, enum keycode key, int16_t value) {
|
|||
void mp_destroy(struct microprofile *mp) {
|
||||
#if ENABLE_MICROPROFILE
|
||||
r_destroy_texture(mp->r, mp->font_texture);
|
||||
#endif
|
||||
|
||||
free(mp);
|
||||
#endif
|
||||
}
|
||||
|
||||
struct microprofile *mp_create(struct render_backend *r) {
|
||||
#if ENABLE_MICROPROFILE
|
||||
struct microprofile *mp = reinterpret_cast<struct microprofile *>(
|
||||
calloc(1, sizeof(struct microprofile)));
|
||||
|
||||
#if ENABLE_MICROPROFILE
|
||||
mp->r = r;
|
||||
|
||||
/* register and enable cpu and gpu groups by default */
|
||||
|
@ -305,9 +305,11 @@ struct microprofile *mp_create(struct render_backend *r) {
|
|||
r_create_texture(mp->r, PXL_RGBA, FILTER_NEAREST, WRAP_CLAMP_TO_EDGE,
|
||||
WRAP_CLAMP_TO_EDGE, 0, FONT_WIDTH, FONT_HEIGHT,
|
||||
reinterpret_cast<const uint8_t *>(s_font_data));
|
||||
#endif
|
||||
|
||||
return mp;
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* microprofile expects the following three functions to be defined, they're
|
||||
|
|
Loading…
Reference in New Issue