From 83d5ba42f8a98fc0df177efef4333f74a0481f61 Mon Sep 17 00:00:00 2001 From: pants Date: Mon, 21 Sep 2026 14:18:06 -0700 Subject: init --- include/util/egl.hpp | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 include/util/egl.hpp (limited to 'include/util/egl.hpp') diff --git a/include/util/egl.hpp b/include/util/egl.hpp new file mode 100644 index 0000000..05a1373 --- /dev/null +++ b/include/util/egl.hpp @@ -0,0 +1,54 @@ +// Display images inside a terminal +// Copyright (C) 2023 JustKidding +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +#ifndef UTIL_EGL_H +#define UTIL_EGL_H + +#include "image.hpp" + +#include +#include + +#include + +#include +#define GL_GLEXT_PROTOTYPES +#include + +template +class EGLUtil +{ + public: + EGLUtil(EGLenum platform, T *native_display, const EGLAttrib *attrib = nullptr); + ~EGLUtil(); + + void get_texture_from_image(const Image &image, GLuint texture) const; + void run_contained(EGLSurface surface, EGLContext context, const std::function &func) const; + void make_current(EGLSurface surface, EGLContext context) const; + void restore() const; + [[nodiscard]] auto create_surface(V *native_window) const -> EGLSurface; + [[nodiscard]] auto create_context(EGLSurface surface) const -> EGLContext; + + EGLDisplay display; + + private: + EGLConfig config; + std::shared_ptr logger; + + [[nodiscard]] auto error_to_string() const -> std::string; +}; + +#endif -- cgit v1.2.3