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