Resources (#1)
* start some resource fiddling * start some resource fiddling * initiate a real resource manager * fix color flicker in rendering * delete unintended constructors and add a convenience function to reset the render-image (from the original image, aka. clone again) * [OpenGL deprecation warning] The compiler said that these functions are "deprecated". They seem to be useless anyway... * various improvements * add resource enumerator and documentation * fix constness stuff * use existing iterator for insertion * init unit tests * rm bogus file --------- Co-authored-by: m-aXimilian <keuffnermax@gmail.com>
This commit is contained in:
+30
-10
@@ -3,18 +3,20 @@
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#include <cstdio>
|
||||
#include <format>
|
||||
#include <memory>
|
||||
|
||||
#include "Image.hpp"
|
||||
#include "PixelariumImage.hpp"
|
||||
#include "imgui.h"
|
||||
#include "rendering/CvMatRender.hpp"
|
||||
#include "resources/resource.hpp"
|
||||
#include "utilities/ILog.hpp"
|
||||
|
||||
namespace pixelarium::ui
|
||||
{
|
||||
static bool dim_changed_p(const ImVec2& ref_rect, const ImVec2& new_rect);
|
||||
|
||||
static ImVec2 ascpet_const_dimensions(const pixelarium::imaging::Image& img, const ImVec2& curr_dim);
|
||||
static ImVec2 aspect_const_dimensions(const pixelarium::imaging::PixelariumImage& img, const ImVec2& curr_dim);
|
||||
|
||||
enum LogLevelSelection
|
||||
{
|
||||
@@ -28,7 +30,24 @@ class AppGLFW
|
||||
{
|
||||
public:
|
||||
AppGLFW() { this->InitMainWindow(); }
|
||||
AppGLFW(std::unique_ptr<utils::log::ILog>& log) : _logger(log.get()) { this->InitMainWindow(); }
|
||||
AppGLFW(std::unique_ptr<utils::log::ILog>& log) : AppGLFW()
|
||||
{
|
||||
logger_ = log.get();
|
||||
if (logger_)
|
||||
{
|
||||
logger_->Debug(std::format("{}: Initiating a new window", __FUNCTION__).c_str());
|
||||
|
||||
if (pool_)
|
||||
{
|
||||
logger_->Debug(std::format("{}: We have an image resource pool!", __FUNCTION__).c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
AppGLFW(std::unique_ptr<utils::log::ILog>& log, std::unique_ptr<pixelarium::resources::ImageResourcePool>& pool)
|
||||
: AppGLFW(log)
|
||||
{
|
||||
pool_ = pool.get();
|
||||
};
|
||||
int Run();
|
||||
|
||||
private:
|
||||
@@ -38,17 +57,18 @@ class AppGLFW
|
||||
|
||||
private:
|
||||
// LogLevelSelection log_level_ = static_cast<LogLevelSelection>(0);
|
||||
utils::log::ILog* _logger;
|
||||
utils::log::ILog* logger_;
|
||||
resources::ImageResourcePool* pool_;
|
||||
GLFWwindow* window = nullptr;
|
||||
ImGuiWindowFlags window_flags = 0;
|
||||
std::shared_ptr<pixelarium::imaging::Image> _img;
|
||||
pixelarium::render::CvMatRender _render;
|
||||
bool _imagep{false};
|
||||
ImVec2 _curr_dim;
|
||||
ImGuiWindowFlags window_flags_ = 0;
|
||||
std::shared_ptr<pixelarium::imaging::PixelariumImage> img_;
|
||||
pixelarium::render::CvMatRender render_;
|
||||
bool imagep_{false};
|
||||
ImVec2 curr_dim_;
|
||||
};
|
||||
|
||||
static void glfw_error_callback(int error, const char* description)
|
||||
{
|
||||
fprintf(stderr, "GLFW Error %d: %s\n", error, description);
|
||||
}
|
||||
} // namespace pixelarium::ui
|
||||
} // namespace pixelarium::ui
|
||||
|
||||
Reference in New Issue
Block a user