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:
m-aXimilian
2025-06-13 22:23:20 +00:00
committed by GitHub
parent a175b79c96
commit a8489292b6
21 changed files with 574 additions and 169 deletions
+26 -10
View File
@@ -13,25 +13,41 @@
#endif
#include <GLFW/glfw3.h> // Will drag system OpenGL headers
#endif
#include "imaging/Image.hpp"
#include "imaging/PixelariumImage.hpp"
// clang-format on
namespace pixelarium::render
{
static void matToTexture(const cv::Mat& image, GLuint* texture);
class CvMatRender
{
public:
// we want the default constructor for the time being
// (although it does not make much sense and should
// get removed in the future)
// as the using AppGLFW constructs it empty as a member
// when coming to life.
CvMatRender() = default;
explicit CvMatRender(const std::shared_ptr<pixelarium::imaging::Image>& img);
GLuint* Render();
GLuint* Render(float factor);
GLuint* Render(size_t width, size_t height);
CvMatRender(CvMatRender&) = delete;
CvMatRender(const CvMatRender&) = delete;
CvMatRender(CvMatRender&&) = delete;
CvMatRender& operator=(CvMatRender&) = default;
CvMatRender& operator=(CvMatRender&&) = default;
~CvMatRender();
explicit CvMatRender(const std::shared_ptr<pixelarium::imaging::PixelariumImage>& img);
public:
GLuint Render();
GLuint Render(float factor);
GLuint Render(size_t width, size_t height);
void ResetRenderImage() { this->img_ = this->base_->GetImage().clone(); }
void ResetRenderImage(const std::shared_ptr<pixelarium::imaging::PixelariumImage>& img);
private:
cv::Mat _img;
std::shared_ptr<pixelarium::imaging::Image> _base;
GLuint _texture;
cv::Mat img_;
std::shared_ptr<pixelarium::imaging::PixelariumImage> base_;
GLuint texture_;
GLuint uploadTexture();
};
} // namespace pixelarium::render
} // namespace pixelarium::render