20 constexpr static GLuint NO_BUF = 0;
24 GlBuffer(
GlBuffer && r ) : bufferID_( r.bufferID_ ), size_( r.size_ ) { r.detach_(); }
30 auto getId()
const {
return bufferID_; }
31 bool valid()
const {
return bufferID_ != NO_BUF; }
32 size_t size()
const {
return size_; }
35 MRVIEWER_API
void gen();
38 MRVIEWER_API
void del();
41 MRVIEWER_API
void bind( GLenum target );
44 MRVIEWER_API
void loadData( GLenum target,
const char * arr,
size_t arrSize );
46 void loadData( GLenum target,
const T * arr,
size_t arrSize ) {
loadData( target, (
const char *)arr,
sizeof( T ) * arrSize ); }
48 void loadData( GLenum target,
const C & cont ) {
loadData( target, cont.data(), cont.size() ); }
51 MRVIEWER_API
void loadDataOpt( GLenum target,
bool refresh,
const char * arr,
size_t arrSize );
53 void loadDataOpt( GLenum target,
bool refresh,
const T * arr,
size_t arrSize ) {
loadDataOpt( target, refresh, (
const char *)arr,
sizeof( T ) * arrSize ); }
55 void loadDataOpt( GLenum target,
bool refresh,
const C & cont ) {
loadDataOpt( target, refresh, cont.data(), cont.size() ); }
59 void detach_() { bufferID_ = NO_BUF; size_ = 0; }
62 GLuint bufferID_ = NO_BUF;
74 return Vector3i( value.x, value.y, 1 );
77 MRVIEWER_API
virtual void texImage_(
const Settings& settings,
const char* arr )
override;
86 MRVIEWER_API
virtual void texImage_(
const Settings& settings,
const char* arr )
override;
95 MRVIEWER_API
virtual void texImage_(
const Settings& settings,
const char* arr )
override;
103 const char *
arr =
nullptr;
113template<
typename T,
template<
typename,
typename...>
class C,
typename... args>
115 const GLuint program_shader,
118 const C<T, args...>& V,
119 int baseTypeElementsNumber,
121 bool forceUse =
false )
128 .arr = (
const char*)V.data(),
129 .arrSize =
sizeof(T) * V.
size(),
130 .baseTypeElementsNumber = baseTypeElementsNumber,
132 .forceUse = forceUse,
133 .isColor = std::is_same_v<Color, T>
138template <
typename T, std::
size_t N>
140 const GLuint program_shader,
143 const std::array<T, N>& V,
144 int baseTypeElementsNumber,
146 bool forceUse =
false )
153 .arr = (
const char*)V.data(),
154 .arrSize =
sizeof(T) * N,
155 .baseTypeElementsNumber = baseTypeElementsNumber,
157 .forceUse = forceUse,
158 .isColor = std::is_same_v<Color, T>
222 MRVIEWER_API
void gen(
const Vector2i& size,
bool copyDepth,
int msaaPow,
bool highPrecisionDepth =
false );
225 MRVIEWER_API
void bind(
bool clear =
true,
float clearDepth = 1.0f );
230 MRVIEWER_API
void bindTexture(
bool color =
true,
bool depth =
true );
241 const Vector2i&
getSize()
const {
return size_; }
250 bool forceSimpleDepthDraw =
false;
251 float simpleDepth = 0.5f;
256 void resize_(
const Vector2i& size,
int msaaPow );
258 bool isBound_{
false };
259 bool highPrecisionDepth_{
false };
260 unsigned mainFramebuffer_{ 0 };
261 unsigned colorRenderbuffer_{ 0 };
262 unsigned depthRenderbuffer_{ 0 };
263 unsigned copyFramebuffer_{ 0 };
264 GlTexture2 resColorTexture_;
265 GlTexture2 resDepthTexture_;
class for easier rendering in framebuffer texture
Definition MRRenderGLHelpers.h:217
represents OpenGL buffer owner, and allows uploading data in it remembering buffer size
Definition MRRenderGLHelpers.h:19
represents OpenGL array texture 2D owner, and allows uploading data in it remembering texture size
Definition MRRenderGLHelpers.h:91
represents OpenGL 2D texture owner, and allows uploading data in it remembering texture size
Definition MRRenderGLHelpers.h:68
represents OpenGL 3D texture owner, and allows uploading data in it remembering texture size
Definition MRRenderGLHelpers.h:82
represents OpenGL texture owner, and allows uploading data in it remembering texture size
Definition MRGLTexture.h:21
class for rendering simple texture
Definition MRRenderGLHelpers.h:202
MRVIEWER_API GLint bindVertexAttribArray(const BindVertexAttribArraySettings &settings)
MRVIEWER_API void gen()
generates simple quad for rendering
WrapType
Definition MREnums.h:18
MRVIEWER_API void gen(const Vector2i &size, bool copyDepth, int msaaPow, bool highPrecisionDepth=false)
const char * arr
Definition MRRenderGLHelpers.h:103
MRVIEWER_API void gen()
generates new buffer
MRVIEWER_API void loadData(GLenum target, const char *arr, size_t arrSize)
creates GL data buffer using given data and binds it
MRVIEWER_API void del()
removes this object
MRVIEWER_API void del()
deletes the buffer
void loadData(GLenum target, const T *arr, size_t arrSize)
Definition MRRenderGLHelpers.h:46
MRVIEWER_API void objectPostRenderSetup(const TransparencyMode &tMode, RenderModelPassMask desiredPass, bool deptTesting)
void loadData(GLenum target, const C &cont)
Definition MRRenderGLHelpers.h:48
MRVIEWER_API void bindDefault()
GlBuffer & buf
Definition MRRenderGLHelpers.h:102
MRVIEWER_API void draw(QuadTextureVertexObject &quadObject, const DrawParams ¶ms) const
draws this framebuffer using quadObject
unsigned getColorTexture() const
gets texture id for binding in other shaders
Definition MRRenderGLHelpers.h:238
const char * name
Definition MRRenderGLHelpers.h:101
MRVIEWER_API void copyTextureBindDef()
MRVIEWER_API void objectPreRenderSetup(const TransparencyMode &tMode, RenderModelPassMask desiredPass, bool deptTesting)
size_t arrSize
Definition MRRenderGLHelpers.h:104
MRVIEWER_API void bind()
binds simple quad vertex data
GlBuffer(GlBuffer &&r)
Definition MRRenderGLHelpers.h:24
int getDepthFunctionLEqual(DepthFunction funcType)
Definition MRRenderGLHelpers.h:193
GlTexture2()
Definition MRRenderGLHelpers.h:70
bool isBound() const
return true if texture is bound
Definition MRRenderGLHelpers.h:243
FilterType
Definition MREnums.h:12
MRVIEWER_API void bindTexture(bool color=true, bool depth=true)
marks the texture to reading
RenderModelPassMask
Various passes of the 3D rendering.
Definition MRRenderModelParameters.h:40
auto getId() const
Definition MRRenderGLHelpers.h:30
void loadDataOpt(GLenum target, bool refresh, const C &cont)
Definition MRRenderGLHelpers.h:55
GlTexture2DArray()
Definition MRRenderGLHelpers.h:93
unsigned getDepthTexture() const
Definition MRRenderGLHelpers.h:239
const Vector2i & getSize() const
Definition MRRenderGLHelpers.h:241
static Vector3i ToResolution(const Vector2i &value)
Definition MRRenderGLHelpers.h:72
int baseTypeElementsNumber
Definition MRRenderGLHelpers.h:105
GlTexture3()
Definition MRRenderGLHelpers.h:84
DepthFunction
Definition MRIRenderObject.h:21
Vector2i size
Definition MRRenderGLHelpers.h:247
GLuint program_shader
Definition MRRenderGLHelpers.h:100
GlBuffer & operator=(const GlBuffer &)=delete
int getDepthFunctionLess(DepthFunction funcType)
Definition MRRenderGLHelpers.h:165
~GlBuffer()
Definition MRRenderGLHelpers.h:25
bool refresh
Definition MRRenderGLHelpers.h:106
GlBuffer(const GlBuffer &)=delete
MRVIEWER_API void bind(bool clear=true, float clearDepth=1.0f)
void loadDataOpt(GLenum target, bool refresh, const T *arr, size_t arrSize)
Definition MRRenderGLHelpers.h:53
MRVIEWER_API void bindDepthPeelingTextures(GLuint shaderId, const TransparencyMode &tMode, GLenum startGLTextureIndex)
helper function to bind depth and color buffers to given shader program
bool isColor
Definition MRRenderGLHelpers.h:108
bool forceUse
Definition MRRenderGLHelpers.h:107
size_t size() const
Definition MRRenderGLHelpers.h:32
MRVIEWER_API void loadDataOpt(GLenum target, bool refresh, const char *arr, size_t arrSize)
binds current buffer to OpenGL context, optionally refreshing its data
MRVIEWER_API void bind(GLenum target)
binds current buffer to OpenGL context
bool valid() const
Definition MRRenderGLHelpers.h:31
MRVIEWER_API void del()
removes this framebuffer
only for bindings generation
Definition MRCameraOrientationPlugin.h:8
Definition MRRenderGLHelpers.h:99
Definition MRRenderGLHelpers.h:246
struct to determine transparent rendering mode
Definition MRRenderModelParameters.h:13