works, no input yet, but renders and loads wad
This commit is contained in:
@ -15,8 +15,7 @@ add_library(solDOOM
|
||||
)
|
||||
|
||||
target_include_directories(solDOOM PUBLIC .)
|
||||
#target_compile_features(solanaceae_llama-cpp-web PRIVATE cxx_std_20)
|
||||
#target_compile_features(solanaceae_llama-cpp-web INTERFACE cxx_std_17)
|
||||
target_compile_features(solDOOM PUBLIC cxx_std_17)
|
||||
target_link_libraries(solDOOM PUBLIC
|
||||
PureDOOM
|
||||
#httplib::httplib
|
||||
@ -27,35 +26,14 @@ target_link_libraries(solDOOM PUBLIC
|
||||
|
||||
#########################################
|
||||
|
||||
#add_executable(test1
|
||||
#test1.cpp
|
||||
#)
|
||||
add_library(solDOOM_imgui
|
||||
./solanaceae/doom_imgui.hpp
|
||||
./solanaceae/doom_imgui.cpp
|
||||
)
|
||||
|
||||
#target_link_libraries(test1 PUBLIC
|
||||
#solanaceae_llama-cpp-web
|
||||
#)
|
||||
|
||||
#########################################
|
||||
|
||||
#add_library(solanaceae_rpbot
|
||||
#./solanaceae/rpbot/message_prompt_builder.hpp
|
||||
#./solanaceae/rpbot/message_prompt_builder.cpp
|
||||
|
||||
#./solanaceae/rpbot/rpbot.hpp
|
||||
#./solanaceae/rpbot/rpbot_states.hpp
|
||||
#./solanaceae/rpbot/rpbot.cpp
|
||||
#./solanaceae/rpbot/rpbot_commands.cpp
|
||||
#)
|
||||
|
||||
#target_include_directories(solanaceae_rpbot PUBLIC .)
|
||||
#target_compile_features(solanaceae_rpbot PRIVATE cxx_std_20)
|
||||
#target_compile_features(solanaceae_rpbot INTERFACE cxx_std_17)
|
||||
#target_link_libraries(solanaceae_rpbot PUBLIC
|
||||
#solanaceae_util
|
||||
#solanaceae_message3
|
||||
|
||||
#solanaceae_llama-cpp-web
|
||||
|
||||
#fmt::fmt # TODO: switch to header only?
|
||||
#)
|
||||
target_include_directories(solDOOM_imgui PUBLIC .)
|
||||
target_link_libraries(solDOOM_imgui PUBLIC
|
||||
solDOOM
|
||||
imgui
|
||||
)
|
||||
|
||||
|
@ -4,9 +4,46 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
void my_doom_print(const char* str) {
|
||||
std::printf("%s", str);
|
||||
}
|
||||
|
||||
// evil global
|
||||
static volatile double g_time {0};
|
||||
|
||||
void my_doom_gettime(int* sec, int* usec) {
|
||||
const int tmp_sec = g_time; // cast to full sec
|
||||
if (sec != nullptr) {
|
||||
*sec = tmp_sec;
|
||||
}
|
||||
if (usec != nullptr) {
|
||||
const float rest_time = g_time - tmp_sec;
|
||||
*usec = rest_time * 1'000 * 1'000;
|
||||
}
|
||||
}
|
||||
|
||||
//static const char* doom_argv[] {
|
||||
//"self.exe",
|
||||
//"-timedemo",
|
||||
//"",
|
||||
//};
|
||||
|
||||
Doom::Doom(
|
||||
TextureUploaderI& tu
|
||||
) : _tu(tu) {
|
||||
doom_set_getenv(&std::getenv);
|
||||
|
||||
doom_set_print(&my_doom_print);
|
||||
|
||||
// TODO: replace this with exception?
|
||||
doom_set_exit(&std::exit);
|
||||
|
||||
doom_set_gettime(&my_doom_gettime);
|
||||
|
||||
// Change default bindings to modern
|
||||
doom_set_default_int("key_up", DOOM_KEY_W);
|
||||
@ -16,8 +53,11 @@ Doom::Doom(
|
||||
doom_set_default_int("key_use", DOOM_KEY_E);
|
||||
doom_set_default_int("mouse_move", 0); // Mouse will not move forward
|
||||
|
||||
// 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
|
||||
@ -31,6 +71,8 @@ Doom::~Doom(void) {
|
||||
}
|
||||
|
||||
float Doom::render(float time_delta) {
|
||||
g_time += time_delta;
|
||||
|
||||
doom_update();
|
||||
|
||||
const uint8_t* new_image = doom_get_framebuffer(4);
|
||||
|
25
src/solanaceae/doom_imgui.cpp
Normal file
25
src/solanaceae/doom_imgui.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
#include "./doom_imgui.hpp"
|
||||
|
||||
#include <imgui.h>
|
||||
|
||||
DoomIMGUI::DoomIMGUI(
|
||||
TextureUploaderI& tu
|
||||
) : _doom(tu) {
|
||||
}
|
||||
|
||||
DoomIMGUI::~DoomIMGUI(void) {
|
||||
}
|
||||
|
||||
float DoomIMGUI::render(float time_delta) {
|
||||
// tick doom either way
|
||||
// while this is computing, and as such could be run in tick(), its still rendering
|
||||
const float doom_interval = _doom.render(time_delta);
|
||||
|
||||
if (ImGui::Begin("doom")) {
|
||||
ImGui::Image(reinterpret_cast<void*>(_doom.getTexID()), {320, 200});
|
||||
}
|
||||
ImGui::End();
|
||||
|
||||
return doom_interval;
|
||||
}
|
||||
|
21
src/solanaceae/doom_imgui.hpp
Normal file
21
src/solanaceae/doom_imgui.hpp
Normal file
@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include "./doom.hpp"
|
||||
|
||||
class DoomIMGUI {
|
||||
// inherit instead?
|
||||
Doom _doom;
|
||||
|
||||
public:
|
||||
DoomIMGUI(
|
||||
TextureUploaderI& tu
|
||||
);
|
||||
~DoomIMGUI(void);
|
||||
|
||||
// render imgui
|
||||
float render(float time_delta);
|
||||
|
||||
public: // custom doom api
|
||||
uint64_t getTexID(void);
|
||||
};
|
||||
|
Reference in New Issue
Block a user