4# pragma warning(push, 1)
5# pragma warning(disable : 4127)
6# pragma warning(disable : 4005)
9#include <QSurfaceFormat>
10#include <QOffscreenSurface>
14#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
15# include <QOpenGLExtraFunctions>
22#include "../../global.hpp"
26#include "decl_opengl_image_renderer.hpp"
45 class OpenGLImageRendererFactory final
80 static bool TryVersion(
int version, QSurfaceFormat &format)
noexcept;
100#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
104 GL3ImageRenderer()
noexcept;
108 void *BeginBufferAccess(
int &linePad)
noexcept override
115 return pixelBuffer_.Map();
118 void EndBufferAccess()
noexcept override
121 pixelBuffer_.Unmap();
123 Image2DTexture(
nullptr,
true);
124 pixelBuffer_.Release();
128 bool MonoUploadSupported()
const noexcept override
134 class GLPixelBuffer :
public QOpenGLExtraFunctions
137 GLPixelBuffer()
noexcept;
138 GLPixelBuffer(
const GLPixelBuffer &other) =
delete;
139 GLPixelBuffer &operator=(
const GLPixelBuffer &other) =
delete;
140 GLPixelBuffer(GLPixelBuffer &&other) =
delete;
141 GLPixelBuffer &operator=(GLPixelBuffer &&other) =
delete;
144 void Bind()
noexcept;
145 void Release()
noexcept;
147 void Data()
noexcept;
148 void Data(
int size)
noexcept;
150 void *Map()
noexcept;
151 void Unmap()
noexcept;
158 GLPixelBuffer pixelBuffer_;
165 GL2ImageRenderer() noexcept
172 void *BeginBufferAccess(
int & )
noexcept override
174 return &pixelBuffer_[0];
177 void EndBufferAccess()
noexcept override
180 Image2DTexture(
BufferFormat(), &pixelBuffer_[0],
false);
184 bool MonoUploadSupported()
const noexcept override
193 OpenGLImageRendererFactory()
noexcept =
delete;
195 static bool TryFormat(
const QSurfaceFormat &format,
int minVersion)
noexcept
197 QOpenGLContext context;
198 context.setFormat(format);
199 if (!context.create())
202 auto effectiveFormat = context.format();
203 if (effectiveFormat.majorVersion() < minVersion
205 || (effectiveFormat.majorVersion() == 3 && effectiveFormat.renderableType() == QSurfaceFormat::OpenGLES
206 && !(QSysInfo::currentCpuArchitecture().startsWith(
"arm")))
208 || (effectiveFormat.majorVersion() == 2 && effectiveFormat.renderableType() != QSurfaceFormat::OpenGLES))
210 if (effectiveFormat.profile() == QSurfaceFormat::CoreProfile)
216 static String ReadString(
int version,
int value)
220 QOpenGLContext context;
221 context.setFormat(format);
222 if (!context.create())
223 throw std::runtime_error(
"failed to create context for already verified OpenGL version.");
225 QOffscreenSurface surface;
226 context.makeCurrent(&surface);
227 QOpenGLFunctions fnc;
228 fnc.initializeOpenGLFunctions();
230 QString vendor(
reinterpret_cast<const char *
>(fnc.glGetString(
static_cast<GLenum
>(value))));
45 class OpenGLImageRendererFactory final {
…};
static QSurfaceFormat CreateFormat(int version)
Create a OpenGL format for the given version.
Definition detail_opengl_image_renderer_factory.hpp:35
static String VendorName(int version)
Get the name of the OpenGL vendor.
Definition detail_opengl_image_renderer_factory.hpp:82
static bool TryVersion(int version) noexcept
Test if a OpenGL version is implemented on your system.
Definition detail_opengl_image_renderer_factory.hpp:47
static String RendererName(int version)
Gets the name of the OpenGL renderer.
Definition detail_opengl_image_renderer_factory.hpp:87
static std::unique_ptr< OpenGLImageRenderer > CreateRenderer(int version)
Create a renderer.
Definition detail_opengl_image_renderer_factory.hpp:18
Base class for OpenGL image renderer.
Definition decl_opengl_image_renderer.hpp:43
OpenGLBufferFormat BufferFormat() const noexcept
Returns the current buffer format.
Definition decl_opengl_image_renderer.hpp:75
Namespace for user interface components.
Definition decl_image_scene.hpp:39
Cvb::String QtToCvb(const QString text) noexcept
Convenience converter for strings.
Definition ui.hpp:219
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17
std::string String
String for wide characters or unicode characters.
Definition string.hpp:49