Compare commits
12 Commits
099c3650a7
...
master
Author | SHA1 | Date | |
---|---|---|---|
|
3320e6c1e3 | ||
|
fee884ff32 | ||
|
d8d74c9a5e | ||
dc7d4a2e93 | |||
bbb419ed42 | |||
27b4374662 | |||
884033fe5c | |||
4e4b35703f | |||
6968d4403e | |||
b6ab400943 | |||
1dc4c850f4 | |||
7122e7ff62 |
6
.github/workflows/cd.yml
vendored
6
.github/workflows/cd.yml
vendored
@@ -17,7 +17,7 @@ jobs:
|
||||
runs-on: ubuntu-20.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Configure CMake
|
||||
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
||||
@@ -58,7 +58,7 @@ jobs:
|
||||
runs-on: windows-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
# setup vs env
|
||||
- uses: ilammy/msvc-dev-cmd@v1
|
||||
@@ -111,7 +111,7 @@ jobs:
|
||||
contents: write
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Determine tag name
|
||||
id: tag
|
||||
|
6
.github/workflows/ci.yml
vendored
6
.github/workflows/ci.yml
vendored
@@ -16,7 +16,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Configure CMake
|
||||
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
||||
@@ -30,7 +30,7 @@ jobs:
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Configure CMake
|
||||
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
||||
@@ -44,7 +44,7 @@ jobs:
|
||||
runs-on: windows-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
# setup vs env
|
||||
- uses: ilammy/msvc-dev-cmd@v1
|
||||
|
45
external/CMakeLists.txt
vendored
45
external/CMakeLists.txt
vendored
@@ -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()
|
||||
|
||||
|
@@ -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
|
||||
|
@@ -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);
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
|
@@ -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();
|
||||
|
||||
|
@@ -12,7 +12,7 @@ class DoomIMGUI {
|
||||
DoomIMGUI(
|
||||
TextureUploaderI& tu
|
||||
);
|
||||
~DoomIMGUI(void);
|
||||
virtual ~DoomIMGUI(void);
|
||||
|
||||
// render imgui
|
||||
float render(float time_delta);
|
||||
|
@@ -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;
|
||||
};
|
||||
|
Reference in New Issue
Block a user