Compare commits

...

10 Commits

Author SHA1 Message Date
Green Sky
3320e6c1e3 update imgui to v1.91.7 2025-01-18 14:49:54 +01:00
Green Sky
fee884ff32 update to v3 texture uploader 2025-01-13 13:47:59 +01:00
Green Sky
d8d74c9a5e fix and update imgui 2025-01-13 13:24:43 +01:00
dc7d4a2e93 update imgui to v1.90.7
correct plugin target type
2024-05-28 17:34:56 +02:00
bbb419ed42 imgui allocators 2024-05-22 16:24:02 +02:00
27b4374662 better plugin export visibility 2024-05-19 11:33:40 +02:00
884033fe5c sync imgui, update to 1.90.6 2024-05-15 13:33:45 +02:00
4e4b35703f update imgui to be the same as latest tomato 2024-04-18 11:48:31 +02:00
6968d4403e fix missing virtual destructor 2024-04-06 11:55:42 +02:00
b6ab400943 better imgui key handling 2024-03-10 13:42:58 +01:00
8 changed files with 53 additions and 72 deletions

View File

@@ -2,33 +2,6 @@ cmake_minimum_required(VERSION 3.24 FATAL_ERROR)
include(FetchContent)
#if (NOT TARGET solanaceae_util)
#FetchContent_Declare(solanaceae_util
#GIT_REPOSITORY https://github.com/Green-Sky/solanaceae_util.git
#GIT_TAG master
#EXCLUDE_FROM_ALL
#)
#FetchContent_MakeAvailable(solanaceae_util)
#endif()
#if (NOT TARGET solanaceae_contact)
#FetchContent_Declare(solanaceae_contact
#GIT_REPOSITORY https://github.com/Green-Sky/solanaceae_contact.git
#GIT_TAG master
#EXCLUDE_FROM_ALL
#)
#FetchContent_MakeAvailable(solanaceae_contact)
#endif()
#if (NOT TARGET solanaceae_message3)
#FetchContent_Declare(solanaceae_message3
#GIT_REPOSITORY https://github.com/Green-Sky/solanaceae_message3.git
#GIT_TAG master
#EXCLUDE_FROM_ALL
#)
#FetchContent_MakeAvailable(solanaceae_message3)
#endif()
if (NOT TARGET solanaceae_plugin)
FetchContent_Declare(solanaceae_plugin
GIT_REPOSITORY https://github.com/Green-Sky/solanaceae_plugin.git
@@ -38,18 +11,6 @@ if (NOT TARGET solanaceae_plugin)
FetchContent_MakeAvailable(solanaceae_plugin)
endif()
#if (NOT TARGET oatpp)
#set(OATPP_INSTALL OFF CACHE BOOL "" FORCE)
#set(OATPP_BUILD_TESTS OFF CACHE BOOL "" FORCE)
#set(OATPP_LINK_TEST_LIBRARY OFF CACHE BOOL "" FORCE)
#FetchContent_Declare(oatpp
#GIT_REPOSITORY https://github.com/oatpp/oatpp.git
#GIT_TAG master
#EXCLUDE_FROM_ALL
#)
#FetchContent_MakeAvailable(oatpp)
#endif()
if (NOT TARGET PureDOOM)
add_subdirectory(./pure_doom)
endif()
@@ -57,14 +18,15 @@ endif()
if (NOT TARGET imgui)
FetchContent_Declare(imgui
GIT_REPOSITORY https://github.com/ocornut/imgui.git
GIT_TAG d6cb3c9 # v1.90.1
GIT_TAG 5c1d2d1e4c562a2ed3efbc64476e703a655b45fd # v1.91.7
EXCLUDE_FROM_ALL
CONFIGURE_COMMAND "" # remove?
)
# imgui does not provide a cmake
FetchContent_GetProperties(imgui)
if(NOT imgui_POPULATED)
FetchContent_Populate(imgui)
FetchContent_MakeAvailable(imgui)
add_library(imgui STATIC
${imgui_SOURCE_DIR}/imgui.h
@@ -84,6 +46,7 @@ if (NOT TARGET imgui)
)
target_include_directories(imgui PUBLIC ${imgui_SOURCE_DIR})
target_compile_features(imgui PUBLIC cxx_std_11)
target_compile_definitions(imgui PUBLIC IMGUI_USE_WCHAR32)
endif()
endif()

View File

@@ -1,9 +1,12 @@
cmake_minimum_required(VERSION 3.9...3.24 FATAL_ERROR)
add_library(plugin_doom_imgui SHARED
add_library(plugin_doom_imgui MODULE
./plugin_doom_imgui.cpp
)
target_compile_features(plugin_doom_imgui PUBLIC cxx_std_17)
set_target_properties(plugin_doom_imgui PROPERTIES
C_VISIBILITY_PRESET hidden
)
target_link_libraries(plugin_doom_imgui PUBLIC
solDOOM_imgui
solanaceae_plugin

View File

@@ -33,10 +33,16 @@ SOLANA_PLUGIN_EXPORT uint32_t solana_plugin_start(struct SolanaAPI* solana_api)
try {
//auto* cr = PLUG_RESOLVE_INSTANCE_VERSIONED(Contact3Registry, "1");
auto* imguic = PLUG_RESOLVE_INSTANCE_VERSIONED(ImGuiContext, ImGui::GetVersion());
auto* tu = PLUG_RESOLVE_INSTANCE(TextureUploaderI);
auto* imguimemaf = PLUG_RESOLVE_INSTANCE_VERSIONED(ImGuiMemAllocFunc, ImGui::GetVersion());
auto* imguimemff = PLUG_RESOLVE_INSTANCE_VERSIONED(ImGuiMemFreeFunc, ImGui::GetVersion());
// meh
auto* imguimemud = plug_resolveInstanceOptional<void*>(solana_api, "ImGuiMemUserData", ImGui::GetVersion());
ImGui::SetAllocatorFunctions(imguimemaf, imguimemff, imguimemud);
ImGui::SetCurrentContext(imguic);
auto* tu = PLUG_RESOLVE_INSTANCE(TextureUploaderI);
// static store, could be anywhere tho
// construct with fetched dependencies
g_doom_imgui = std::make_unique<DoomIMGUI>(*tu);

View File

@@ -27,12 +27,6 @@ void my_doom_gettime(int* sec, int* usec) {
}
}
//static const char* doom_argv[] {
//"self.exe",
//"-timedemo",
//"",
//};
Doom::Doom(
TextureUploaderI& tu
) : _tu(tu) {
@@ -56,8 +50,6 @@ Doom::Doom(
// does not actually work
doom_set_resolution(_width, _height);
// HATE
//doom_init(2, const_cast<char**>(doom_argv), 0);
doom_init(0, nullptr, 0);
std::vector<uint8_t> tmp_vec(4 * _width * _height, 0x00); // the api requires data for texture creation
@@ -75,9 +67,11 @@ float Doom::render(float time_delta) {
doom_update();
// TODO: use RGB instead?
const uint8_t* new_image = doom_get_framebuffer(4);
_tu.updateRGBA(_render_texture, new_image, 4 * _width * _height);
// TODO: allow more?
return 1.f/60.f;
}

View File

@@ -14,7 +14,7 @@ class Doom {
Doom(
TextureUploaderI& tu
);
~Doom(void);
virtual ~Doom(void);
float render(float time_delta);
@@ -51,12 +51,12 @@ class Doom {
//void doom_set_print(doom_print_fn print_fn);
//void doom_set_malloc(doom_malloc_fn malloc_fn, doom_free_fn free_fn);
//void doom_set_file_io(doom_open_fn open_fn,
//doom_close_fn close_fn,
//doom_read_fn read_fn,
//doom_write_fn write_fn,
//doom_seek_fn seek_fn,
//doom_tell_fn tell_fn,
//doom_eof_fn eof_fn);
//doom_close_fn close_fn,
//doom_read_fn read_fn,
//doom_write_fn write_fn,
//doom_seek_fn seek_fn,
//doom_tell_fn tell_fn,
//doom_eof_fn eof_fn);
//void doom_set_gettime(doom_gettime_fn gettime_fn);
//void doom_set_exit(doom_exit_fn exit_fn);
//void doom_set_getenv(doom_getenv_fn getenv_fn);

View File

@@ -93,20 +93,18 @@ float DoomIMGUI::render(float time_delta) {
if (ImGui::Begin("doom", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
ImGui::SliderFloat("scale", &_size_scaler, 1.f, 5.f);
if (ImGui::IsWindowFocused()) {
for (const auto& [imkey, dokey] : g_all_keys) {
// TODO: unpress all keys on focus loss
if (ImGui::IsKeyPressed(imkey, false)) {
_doom.doomKeyDown(dokey);
}
if (ImGui::IsKeyReleased(imkey)) {
_doom.doomKeyUp(dokey);
}
const bool window_focused = ImGui::IsWindowFocused();
for (const auto& [imkey, dokey] : g_all_keys) {
if (window_focused && ImGui::IsKeyPressed(imkey, false)) {
_doom.doomKeyDown(dokey);
}
if (ImGui::IsKeyReleased(imkey)) {
_doom.doomKeyUp(dokey);
}
}
doom_interval = _doom.render(time_delta);
ImGui::Image(reinterpret_cast<void*>(_doom.getTexID()), {_size_scaler * 320, _size_scaler * 200 * 1.2f});
ImGui::Image(_doom.getTexID(), {_size_scaler * 320, _size_scaler * 200 * 1.2f});
}
ImGui::End();

View File

@@ -12,7 +12,7 @@ class DoomIMGUI {
DoomIMGUI(
TextureUploaderI& tu
);
~DoomIMGUI(void);
virtual ~DoomIMGUI(void);
// render imgui
float render(float time_delta);

View File

@@ -4,7 +4,7 @@
#include <cstddef>
struct TextureUploaderI {
static constexpr const char* version {"2"};
static constexpr const char* version {"3"};
enum Filter {
NEAREST,
@@ -17,13 +17,30 @@ struct TextureUploaderI {
// target?
};
enum Format {
RGBA,
//RGB,
IYUV,
YV12,
NV12,
NV21,
MAX
};
virtual ~TextureUploaderI(void) {}
virtual uint64_t uploadRGBA(const uint8_t* data, uint32_t width, uint32_t height, Filter filter = LINEAR, Access access = STATIC) = 0;
[[deprecated]] virtual uint64_t uploadRGBA(const uint8_t* data, uint32_t width, uint32_t height, Filter filter = LINEAR, Access access = STATIC) = 0;
// keeps width height filter
// TODO: wh instead of size?
virtual bool updateRGBA(uint64_t tex_id, const uint8_t* data, size_t size) = 0;
[[deprecated]] virtual bool updateRGBA(uint64_t tex_id, const uint8_t* data, size_t size) = 0;
// use upload to create a texture, and update to update existing
virtual uint64_t upload(const uint8_t* data, uint32_t width, uint32_t height, Format format = RGBA, Filter filter = LINEAR, Access access = STATIC) = 0;
virtual bool update(uint64_t tex_id, const uint8_t* data, size_t size) = 0;
virtual void destroy(uint64_t tex_id) = 0;
};