12#ifndef GAMP_GLARRAYDATAPROXY_HPP_
13#define GAMP_GLARRAYDATAPROXY_HPP_
23 using namespace gamp::render::gl;
30 template<
typename Value_type>
33 template<
typename Value_type>
41 template<
typename Value_type>
75 return std::make_shared<GLArrayDataProxy>(Private(),
102 return std::make_shared<GLArrayDataProxy>(Private(),
112 std::string_view
className() const noexcept
override {
return "GLArrayDataProxy"; }
158 return jau_format_string(
"sealed %s, elements %'d cnt, [%'zd pos .. %'zd rem .. %'zu lim .. %'zd cap]",
160 }
catch (
const std::exception &e) {
174 virtual std::string
toString(
bool withData)
const noexcept {
176 r.append(
"[").append(
m_name)
177 .append(
", location ").append(std::to_string(
m_location))
178 .append(
", isVertexAttribute ").append(std::to_string(
m_isVertexAttr))
181 .append(
", stride ").append(std::to_string(
m_strideB)).append(
"b ").append(std::to_string(
m_strideL)).append(
"c")
187 r.append(
", vboEnabled ").append(std::to_string(
m_vboEnabled))
188 .append(
", vboName ").append(std::to_string(
m_vboName))
191 .append(
", vboOffset ").append(std::to_string(
m_vboOffset))
192 .append(
", alive ").append(std::to_string(
m_alive)).append(
"]");
295 const float filled = (float)cnt_bytes / (
float)cap_bytes;
296 return jau::format_string(
"elements %'d cnt / %'zd cap, bytes %'zu cnt / %'zu cap, filled %.1f%%, left %.1f%%",
314 std::string_view
name, GLsizei componentsPerElement,
324 std::string_view
name, GLsizei componentsPerElement,
331 if( 0 == mappedElementCount ) {
Proxying a data buffer for GLArrayData usage of given template-type Value_type.
glmemsize_t elemCapacity() const noexcept
Return the element capacity.
static proxy_sref createGLSL(std::string_view name, GLsizei componentsPerElement, bool normalized, GLsizei stride, GLsizei mappedElementCount, GLuint vboName, uintptr_t vboOffset, GLenum vboUsage, GLenum vboTarget)
Create a VBO, using a custom GLSL array attribute name, proxying the mapped data characteristics.
constexpr bool usesMappedMem() const noexcept
Returns true if using mapped memory, otherwise false for client-data.
const buffer_t * buffer_ptr() const noexcept
The Buffer holding the data, nullptr if !usesClientMem()
glmemsize_t byteCount() const noexcept override
Returns the byte position (written elements) if not sealed() or the byte limit (available to read) af...
std::string_view className() const noexcept override
Returns class name of implementing class.
glmemsize_t remainingElems() const noexcept
The current number of remaining elements.
std::shared_ptr< proxy_t > proxy_sref
glmemsize_t bytePosition() const noexcept
Returns the bytes position.
virtual std::string toString(bool withData) const noexcept
buffer_t * buffer_ptr() noexcept
The Buffer holding the data, nullptr if !usesClientMem()
const GLArrayDataProxySRef< value_type > shared()
std::string fillStatsToString() const noexcept
Returns a string with detailed buffer fill stats.
std::string elemStatsToString() const noexcept override
Returns a string with detailed buffer element stats, i.e.
GLsizei elemCount() const noexcept override
Returns the element position (written elements) if not sealed() or the element limit (available to re...
GLArrayDataProxy(Private, std::string_view name, GLsizei componentsPerElement, bool normalized, GLsizei stride, GLsizei mappedElementCount, bool isVertexAttribute, GLuint vboName, uintptr_t vboOffset, GLenum vboUsage, GLenum vboTarget)
GLArrayDataProxy(Private, std::string_view name, GLsizei componentsPerElement, bool normalized, GLsizei stride, buffer_t &buffer, bool isVertexAttribute, GLuint vboName, uintptr_t vboOffset, GLenum vboUsage, GLenum vboTarget)
jau::darray< value_type, glmemsize_t > buffer_t
std::string toString() const noexcept override
GLArrayDataProxy< value_type > proxy_t
static proxy_sref createGLSL(std::string_view name, GLsizei componentsPerElement, bool normalized, GLsizei stride, buffer_t &buffer, GLuint vboName, uintptr_t vboOffset, GLenum vboUsage, GLenum vboTarget)
void destroy(GL &gl) override
glmemsize_t elemPosition() const noexcept
Returns the element position.
glmemsize_t remainingBytes() const noexcept
The current number of remaining bytes.
const void * data() const noexcept override
Returns client-data pointer at current position if usesClientMem(), otherwise nullptr.
~GLArrayDataProxy() noexcept override=default
const jau::type_info & classSignature() const noexcept override
Returns type signature of implementing class.
void glBufferData(const GL &gl) const noexcept
constexpr bool usesClientMem() const noexcept
Returns true if using client-data, otherwise false for mapped memory.
glmemsize_t byteCapacity() const noexcept override
Return the capacity in bytes.
std::unique_ptr< buffer_t > buffer_sref
constexpr bool sealed() const noexcept
Returns true if data has been sealed (flipped to read), otherwise false (writing mode).
void glBufferData(const GL &, glmemsize_t size) const noexcept
Sends (creates, updates) the data to the bound vboName buffer, see glBindBuffer().
constexpr uintptr_t vboOffset() const noexcept
The VBO buffer offset if isVBO()
constexpr GLuint vboName() const noexcept
The VBO name or 0 if not a VBO.
virtual void destroy(GL &)
constexpr bool isVertexAttribute() const noexcept
Returns true if this data set is intended for a GLSL vertex shader attribute, otherwise false,...
GLsizei m_strideB
stride in bytes; strideB >= compsPerElement * bytesPerComp
constexpr GLenum vboUsage() const noexcept
The VBO usage or 0 if not a VBO.
std::string toStringImpl() const noexcept
GLsizei stride() const noexcept
constexpr bool normalized() const noexcept
True, if GL shall normalize fixed point data while converting them into float.
GLsizei m_strideL
stride in logical components
GLArrayData(Private, std::string_view name, GLsizei componentsPerElement, GLenum componentType, jau::type_info compTypeSignature, bool normalized, GLsizei stride, GLsizei mappedElementCount, bool isVertexAttribute, GLuint vboName, uintptr_t vboOffset, GLenum vboUsage, GLenum vboTarget)
Private ctor for shared_ptr.
std::shared_ptr< ChildT > shared_from_base()
constexpr GLenum vboTarget() const noexcept
The VBO target or 0 if not a VBO.
GLsizei m_mappedElemCount
constexpr const std::string_view name() const noexcept
The name of the reflecting shader array attribute.
GLsizei m_compsPerElement
Implementation of a dynamic linear array storage, aka vector, including relative positional access.
Generic type information using either Runtime type information (RTTI) or Compile time type informatio...
#define jau_ERR_PRINT2(...)
Use for unconditional error messages, prefix '[elapsed_time] Error @ FILE:LINE FUNC: '.
const jau::type_info & static_ctti() noexcept
Returns a static global reference of make_ctti<T>(true) w/ identity instance.
GLsizeiptr glmemsize_t
Compatible with ssize_t.
std::shared_ptr< GLArrayDataProxy< Value_type > > GLArrayDataProxySRef
constexpr GLenum glType() noexcept
#define jau_format_string(fmt,...)
Macro, safely returns a (non-truncated) string according to snprintf() formatting rules using a reser...
std::string toHexString(const void *data, const nsize_t length, const lb_endian_t byteOrder=lb_endian_t::big, const LoUpCase capitalization=LoUpCase::lower, const PrefixOpt prefix=PrefixOpt::prefix) noexcept
Produce a hexadecimal string representation of the given lsb-first byte values.
__pack(...): Produces MSVC, clang and gcc compatible lead-in and -out macros.
std::string format_string(std::string_view fmt, const Args &...args) noexcept
Safely returns a (non-truncated) string according to snprintf() formatting rules using a reserved str...