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>
74 return std::make_shared<GLArrayDataProxy>(Private(),
100 return std::make_shared<GLArrayDataProxy>(Private(),
110 std::string_view
className() const noexcept
override {
return "GLArrayDataProxy"; }
156 return jau::format_string(
"sealed %d, elements %s cnt, [%s pos .. %s rem .. %s lim .. %s cap]",
163 }
catch (
const std::exception &e) {
177 virtual std::string
toString(
bool withData)
const noexcept {
179 r.append(
"[").append(
m_name)
180 .append(
", location ").append(std::to_string(
m_location))
181 .append(
", isVertexAttribute ").append(std::to_string(
m_isVertexAttr))
184 .append(
", stride ").append(std::to_string(
m_strideB)).append(
"b ").append(std::to_string(
m_strideL)).append(
"c")
190 r.append(
", vboEnabled ").append(std::to_string(
m_vboEnabled))
191 .append(
", vboName ").append(std::to_string(
m_vboName))
194 .append(
", vboOffset ").append(std::to_string(
m_vboOffset))
195 .append(
", alive ").append(std::to_string(
m_alive)).append(
"]");
298 const float filled = (float)cnt_bytes / (
float)cap_bytes;
299 return jau::format_string(
"elements %s cnt / %s cap, bytes %s cnt / %s cap, filled %.1f%%, left %.1f%%",
304 filled * 100.0f, (1.0f - filled) * 100.0f);
321 std::string_view
name, GLsizei componentsPerElement,
331 std::string_view
name, GLsizei componentsPerElement,
338 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.
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.
glmemsize_t bytePosition() const noexcept
Returns the bytes position.
const GLArrayDataProxyRef< value_type > shared()
virtual std::string toString(bool withData) const noexcept
buffer_t * buffer_ptr() noexcept
The Buffer holding the data, nullptr if !usesClientMem()
std::string fillStatsToString() const noexcept
Returns a string with detailed buffer fill stats.
static proxy_ref createGLSL(std::string_view name, GLsizei componentsPerElement, bool normalized, GLsizei stride, buffer_t &buffer, GLuint vboName, uintptr_t vboOffset, GLenum vboUsage, GLenum vboTarget)
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
void destroy(GL &gl) override
glmemsize_t elemPosition() const noexcept
Returns the element position.
static proxy_ref 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.
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.
std::unique_ptr< buffer_t > buffer_ref
~GLArrayDataProxy() noexcept override=default
const jau::type_info & classSignature() const noexcept override
Returns type signature of implementing class.
std::shared_ptr< proxy_t > proxy_ref
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.
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 const std::string & name() const noexcept
The name of the reflecting shader array attribute.
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
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 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 > > GLArrayDataProxyRef
constexpr GLenum glType() noexcept
constexpr std::string format_string(const std::string_view format, const Args &...args)
Safely returns a (non-truncated) string according to snprintf() formatting rules using an initially s...
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.
std::string to_decstring(const value_type &v, const char separator=',', const nsize_t width=0) noexcept
Produce a decimal string representation of an integral integer value.
__pack(...): Produces MSVC, clang and gcc compatible lead-in and -out macros.