Compare commits

..

13 Commits

Author SHA1 Message Date
Green Sky
0fc34b42d4 fix cd ubuntu naming 2025-07-15 12:52:44 +02:00
Green Sky
de6826f7d3 update cd config 2025-07-15 12:44:34 +02:00
Green Sky
ed7517080b update imgui 2025-07-15 12:20:53 +02:00
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
9 changed files with 68 additions and 85 deletions

View File

@@ -7,14 +7,14 @@ on:
branches: [ master ]
env:
BUILD_TYPE: Release
BUILD_TYPE: RelWidthDebInfo
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
jobs:
linux-ubuntu:
timeout-minutes: 10
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
@@ -25,6 +25,10 @@ jobs:
- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
- name: Test
working-directory: ${{github.workspace}}/build
run: ctest -C ${{env.BUILD_TYPE}}
- name: Determine tag name
id: tag
shell: bash
@@ -32,24 +36,24 @@ jobs:
run: |
SHORT_HASH="$(git rev-parse --short=7 HEAD)"
if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
echo "name=${SHORT_HASH}" >> $GITHUB_OUTPUT
echo "name=dev-${SHORT_HASH}" >> $GITHUB_OUTPUT
else
SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
echo "name=${SAFE_NAME}-${SHORT_HASH}" >> $GITHUB_OUTPUT
echo "name=dev-${SAFE_NAME}-${SHORT_HASH}" >> $GITHUB_OUTPUT
fi
- name: Compress artifacts
shell: bash
run: |
tar -czvf ${{ github.event.repository.name }}-${{ steps.tag.outputs.name }}-${{ runner.os }}-ubuntu20.04-x86_64.tar.gz -C ${{github.workspace}}/build/bin/ .
tar -czvf ${{ github.event.repository.name }}-${{ steps.tag.outputs.name }}-${{ runner.os }}-ubuntu22.04-x86_64.tar.gz -C ${{github.workspace}}/build/bin/ .
- uses: actions/upload-artifact@v4
with:
# TODO: simpler name?
name: ${{ github.event.repository.name }}-${{ steps.tag.outputs.name }}-${{ runner.os }}-ubuntu20.04-x86_64
name: ${{ github.event.repository.name }}-${{ steps.tag.outputs.name }}-${{ runner.os }}-ubuntu22.04-x86_64
# TODO: do propper packing
path: |
${{github.workspace}}/${{ github.event.repository.name }}-${{ steps.tag.outputs.name }}-${{ runner.os }}-ubuntu20.04-x86_64.tar.gz
${{github.workspace}}/${{ github.event.repository.name }}-${{ steps.tag.outputs.name }}-${{ runner.os }}-ubuntu22.04-x86_64.tar.gz
windows:
@@ -78,10 +82,10 @@ jobs:
run: |
SHORT_HASH="$(git rev-parse --short=7 HEAD)"
if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
echo "name=${SHORT_HASH}" >> $GITHUB_OUTPUT
echo "name=dev-${SHORT_HASH}" >> $GITHUB_OUTPUT
else
SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
echo "name=${SAFE_NAME}-${SHORT_HASH}" >> $GITHUB_OUTPUT
echo "name=dev-${SAFE_NAME}-${SHORT_HASH}" >> $GITHUB_OUTPUT
fi
- name: Compress artifacts
@@ -98,8 +102,7 @@ jobs:
${{github.workspace}}/${{ github.event.repository.name }}-${{ steps.tag.outputs.name }}-${{ runner.os }}-msvc-x86_64.zip
release:
if: false
#if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) }}
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) }}
runs-on: ubuntu-latest
@@ -120,10 +123,10 @@ jobs:
run: |
SHORT_HASH="$(git rev-parse --short=7 HEAD)"
if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
echo "name=${SHORT_HASH}" >> $GITHUB_OUTPUT
echo "name=dev-${SHORT_HASH}" >> $GITHUB_OUTPUT
else
SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
echo "name=${SAFE_NAME}-${SHORT_HASH}" >> $GITHUB_OUTPUT
echo "name=dev-${SAFE_NAME}-${SHORT_HASH}" >> $GITHUB_OUTPUT
fi
- name: Download artifacts

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,14 @@ endif()
if (NOT TARGET imgui)
FetchContent_Declare(imgui
GIT_REPOSITORY https://github.com/ocornut/imgui.git
GIT_TAG d6cb3c9 # v1.90.1
GIT_TAG 5d4126876bc10396d4c6511853ff10964414c776 # v1.92.1
EXCLUDE_FROM_ALL
)
# 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 +45,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;
};