Files

53 lines
1.4 KiB
C++
Raw Permalink Normal View History

2025-03-14 19:32:40 +01:00
#pragma once
2025-05-23 15:15:01 +02:00
// windows.h must come before GL/GL.h here.
2025-03-17 10:44:56 +01:00
// clang format would change this, effectively rendering the build broken.
// clang-format off
2025-03-14 19:32:40 +01:00
#ifdef _WIN32
#include <windows.h>
#include <GL/GL.h>
#else
#define GL_SILENCE_DEPRECATION
#if defined(IMGUI_IMPL_OPENGL_ES2)
#include <GLES2/gl2.h>
#endif
#include <GLFW/glfw3.h> // Will drag system OpenGL headers
#endif
2025-09-26 21:09:51 +02:00
#include <opencv2/core/mat.hpp>
2025-03-17 10:44:56 +01:00
// clang-format on
2025-03-14 19:32:40 +01:00
2026-01-23 23:00:35 +00:00
namespace pixelarium::application
2025-03-14 19:32:40 +01:00
{
2025-09-26 21:09:51 +02:00
/// @brief Renders cv::Mat bitmaps as OpenGL textures.
2025-03-14 19:32:40 +01:00
class CvMatRender
{
public:
2025-06-13 22:23:20 +00:00
// 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.
2025-09-26 21:09:51 +02:00
// CvMatRender() = default;
2025-06-13 22:23:20 +00:00
CvMatRender(CvMatRender&) = delete;
CvMatRender(const CvMatRender&) = delete;
CvMatRender(CvMatRender&&) = delete;
2025-09-26 21:09:51 +02:00
CvMatRender& operator=(CvMatRender&) = delete;
CvMatRender& operator=(CvMatRender&& other) = delete;
2025-06-13 22:23:20 +00:00
~CvMatRender();
2025-09-26 21:09:51 +02:00
explicit CvMatRender(const cv::Mat& img);
2025-06-13 22:23:20 +00:00
public:
GLuint Render();
GLuint Render(float factor);
GLuint Render(size_t width, size_t height);
2025-09-22 23:13:28 +02:00
void ResetRenderImage();
2025-03-14 19:32:40 +01:00
private:
2025-06-13 22:23:20 +00:00
cv::Mat img_;
2025-09-26 21:09:51 +02:00
const cv::Mat& base_;
2025-06-13 22:23:20 +00:00
GLuint texture_;
GLuint uploadTexture();
2025-03-14 19:32:40 +01:00
};
2026-01-23 23:00:35 +00:00
} // namespace pixelarium::application