Gamp v0.0.7-54-gccdc599
Gamp: Graphics, Audio, Multimedia and Processing
Loading...
Searching...
No Matches
GLArrayDataClient.hpp
Go to the documentation of this file.
1/*
2 * Author: Sven Gothel <sgothel@jausoft.com>
3 * Copyright Gothel Software e.K.
4 *
5 * SPDX-License-Identifier: MIT
6 *
7 * This Source Code Form is subject to the terms of the MIT License
8 * If a copy of the MIT was not distributed with this file,
9 * you can obtain one at https://opensource.org/license/mit/.
10 */
11
12#ifndef GAMP_GLARRAYDATACLIENT_HPP_
13#define GAMP_GLARRAYDATACLIENT_HPP_
14
15#include <cmath>
16#include <memory>
17
18#include <jau/basic_types.hpp>
19#include <jau/float_types.hpp>
20#include <jau/int_types.hpp>
21#include <jau/type_info.hpp>
22
27
28namespace gamp::render::gl::data {
29 using namespace gamp::render::gl;
30
31 /** \addtogroup Gamp_GLData
32 *
33 * @{
34 */
35
36 template<typename Value_type>
38
39 template<typename Value_type>
40 using GLArrayDataClientRef = std::shared_ptr<GLArrayDataClient<Value_type>>;
41
44
45 /**
46 * Client data buffer for non VBO GLArrayData usage of given template-type Value_type.
47 *
48 * The GL data type is determined via template type glType<Value_type>().
49 */
50 template<typename Value_type>
51 class GLArrayDataClient : public GLArrayDataProxy<Value_type> {
52 public:
55 using typename proxy_t::buffer_t;
56 using typename proxy_t::buffer_ref;
57
59 typedef std::shared_ptr<client_t> client_ref;
60
61 /** Default growth factor using the golden ratio 1.618 */
62 inline static constexpr float DEFAULT_GROWTH_FACTOR = std::numbers::phi_v<float>;
63
64 /**
65 * Create a client side buffer object, using a custom GLSL array attribute name
66 * and starting with a new created Buffer object with initialElementCount size
67 *
68 * The GL data type is determined via template type glType<Value_type>().
69 * @param name The custom name for the GL attribute.
70 * @param compsPerElement The array component number
71 * @param normalized Whether the data shall be normalized
72 * @param initialElementCount
73 */
74 static client_ref createGLSL(std::string_view name, GLsizei compsPerElement,
75 bool normalized, size_t initialElementCount)
76 {
77 client_ref r = std::make_shared<GLArrayDataClient>(Private(),
78 name, compsPerElement,
79 normalized, /*stride=*/0, initialElementCount, DEFAULT_GROWTH_FACTOR,
80 /*isVertexAttribute=*/true, std::move(std::make_unique<impl::GLSLArrayHandler<value_type>>()),
81 /*vboName=*/0, /*vboOffset=*/0, /*vboUsage=*/0, /*vboTarget=*/0);
82 r->m_glArrayHandler->set(r);
83 return r;
84 }
85
86 /**
87 * Create a client side buffer object, using a custom GLSL array attribute name
88 * and starting with a given Buffer object incl it's stride.
89 *
90 * The GL data type is determined via template type glType<Value_type>().
91 * @param name The custom name for the GL attribute.
92 * @param compsPerElement The array component number
93 * @param normalized Whether the data shall be normalized
94 * @param stride
95 * @param buffer the user define data, taking ownership
96 */
97 static client_ref createGLSL(std::string_view name, GLsizei compsPerElement,
98 bool normalized, GLsizei stride, buffer_t&& buffer)
99 {
100 client_ref r = std::make_shared<GLArrayDataClient>(Private(),
101 name, compsPerElement,
102 normalized, stride, std::move(buffer), DEFAULT_GROWTH_FACTOR, 0 /* mappedElementCount */,
103 /*isVertexAttribute=*/true, std::move(std::make_unique<impl::GLSLArrayHandler<value_type>>()),
104 /*vboName=*/0, /*vboOffset=*/0, /*vboUsage=*/0, /*vboTarget=*/0);
105 r->m_glArrayHandler->set(r);
106 return r;
107 }
108
109 std::string_view className() const noexcept override { return "GLArrayDataClient"; }
110
111 const jau::type_info& classSignature() const noexcept override {
113 }
114
116
117 void associate(ShaderState& st, bool enable) override {
118 if( enable ) {
119 m_shaderState = &st;
120 } else {
121 m_shaderState = nullptr;
122 }
123 }
124
125 //
126 // Data read access
127 //
128
129 constexpr bool enabled() const noexcept { return m_bufferEnabled; }
130
131 /** Is the buffer written to the VBO ? */
132 constexpr bool isVBOWritten() const noexcept { return m_bufferWritten; }
133
134 //
135 // Data and GL state modification ..
136 //
137
138 /** Marks the buffer written to the VBO */
139 void setVBOWritten(bool written) noexcept {
140 m_bufferWritten = (0 == GLArrayData::m_mappedElemCount) ? written : true;
141 }
142
143 void destroy(GL& gl) override {
144 clear(gl);
146 }
147
148 /**
149 * Clears this buffer and resets states accordingly.
150 * <p>
151 * Implementation calls {@link #seal(GL&, bool) seal(gl, false)} and {@link #clear()},
152 * i.e. turns-off the GL& buffer and then clearing it.
153 * </p>
154 * <p>
155 * The position is set to zero and the limit is set to the capacity.
156 * </p>
157 * <p>
158 * Invoke this method before using a sequence of get or put operations to fill this buffer.
159 * </p>
160 * <p>
161 * This method does not actually erase the data in the buffer and will most often be used when erasing the underlying memory is suitable.
162 * </p>
163 * @see #seal(GL&, bool)
164 * @see #clear()
165 */
166 void clear(GL& gl) {
167 seal(gl, false);
168 clear();
169 }
170
171 /**
172 * Convenience method calling {@link #seal(bool)} and {@link #enableBuffer(GL&, bool)}.
173 *
174 * @see #seal(bool)
175 * @see #enableBuffer(GL&, bool)
176 */
177 void seal(GL& gl, bool seal_) {
178 seal(seal_);
179 enableBuffer(gl, seal_);
180 }
181
182 /**
183 * Enables the buffer if <code>enable</code> is <code>true</code>,
184 * and transfers the data if required.
185 *
186 * In case {@link #isVBO() VBO is used}, it is bound accordingly for the data transfer and association,
187 * i.e. it issued {@link #bindBuffer(GL&, bool)}.
188 * The VBO buffer is unbound when the method returns.
189 *
190 * Disables the buffer if <code>enable</code> is <code>false</code>.
191 *
192 * The action will only be executed,
193 * if the internal enable state differs,
194 * or 'setEnableAlways' was called with 'true'.
195 *
196 * It is up to the user to enable/disable the array properly,
197 * ie in case of multiple data sets for the same vertex attribute (VA).
198 * Meaning in such case usage of one set while expecting another one
199 * to be used for the same VA implies decorating each usage with enable/disable.
200 *
201 * @see #setEnableAlways(bool)
202 */
203 void enableBuffer(GL& gl, bool enable) {
204 if( m_enableBufferAlways || m_bufferEnabled != enable ) {
205 if( enable ) {
206 checkSeal(true);
207 // init/generate VBO name if not done yet
208 init_vbo(gl);
209 }
210 m_glArrayHandler->enableState(gl, enable, m_shaderState);
211 m_bufferEnabled = enable;
212 }
213 }
214
215 /**
216 * if <code>bind</code> is true and the data uses {@link #isVBO() VBO},
217 * the latter will be bound and data written to the GPU if required.
218 * <p>
219 * If <code>bind</code> is false and the data uses {@link #isVBO() VBO},
220 * the latter will be unbound.
221 * </p>
222 * <p>
223 * This method is exposed to allow data VBO arrays, i.e. {@link GL&#GL&_ELEMENT_ARRAY_BUFFER},
224 * to be bounded and written while keeping the VBO bound. The latter is in contrast to {@link #enableBuffer(GL&, bool)},
225 * which leaves the VBO unbound, since it's not required for vertex attributes or pointers.
226 * </p>
227 *
228 * @param gl current GL& object
229 * @param bind true if VBO shall be bound and data written,
230 * otherwise clear VBO binding.
231 * @return true if data uses VBO and action was performed, otherwise false
232 */
233 bool bindBuffer(GL& gl, bool bind) {
234 if( bind ) {
235 checkSeal(true);
236 // init/generate VBO name if not done yet
237 init_vbo(gl);
238 }
239 return m_glArrayHandler->bindBuffer(gl, bind);
240 }
241
242 /**
243 * Affects the behavior of 'enableBuffer'.
244 *
245 * The default is 'false'
246 *
247 * This is useful when you mix up
248 * GLArrayData usage with conventional GL array calls
249 * or in case of a buggy GL& VBO implementation.
250 *
251 * @see #enableBuffer(GL&, bool)
252 */
253 void setEnableAlways(bool always) { m_enableBufferAlways = always; }
254
255 //
256 // Data modification ..
257 //
258
259 /**
260 * Clears this buffer and resets states accordingly.
261 * <p>
262 * The position is set to zero and the limit is set to the capacity.
263 * </p>
264 * <p>
265 * Invoke this method before using a sequence of get or put operations to fill this buffer.
266 * </p>
267 * <p>
268 * This method does not actually erase the data in the buffer and will most often be used when erasing the underlying memory is suitable.
269 * </p>
270 * @see #clear(GL&)
271 */
272 void clear() {
273 m_buffer.clear();
274 proxy_t::m_sealed = false;
275 m_bufferEnabled = false;
276 m_bufferWritten = proxy_t::usesClientMem() ? false : true;
277 }
278
279 /**
280 * <p>If <i>seal</i> is true, it
281 * disables write operations to the buffer.
282 * Calls flip, ie limit:=position and position:=0.</p>
283 *
284 * <p>If <i>seal</i> is false, it
285 * enable write operations continuing
286 * at the buffer position, where you left off at seal(true),
287 * ie position:=limit and limit:=capacity.</p>
288 *
289 * @see #seal(bool)
290 * @see #sealed()
291 */
292 void seal(bool seal) {
293 if( proxy_t::sealed() == seal ) return;
295 m_bufferWritten = proxy_t::usesClientMem() ? false : true;
296 if( seal ) {
297 m_buffer.flip();
298 } else {
299 m_buffer.setPosition(m_buffer.limit());
300 m_buffer.setLimit(m_buffer.size());
301 }
302 }
303
304 /**
305 * Rewinds this buffer.
306 *
307 * The position is set to zero and the limit is set to the capacity.
308 *
309 * Invoke this method before a sequence of put or get operations.
310 */
311 void rewind() {
312 m_buffer.rewind();
313 }
314
315 public:
316 template<typename T, std::enable_if_t<std::is_integral_v<T> || std::is_floating_point_v<T>, bool> = true>
318 if( sizeof(Value_type) > sizeof(T) ) {
319 throw jau::IllegalArgumentError("Buffer `"+toString()+"` incompatible with type `"+jau::static_ctti<T>().name()+"`", E_FILE_LINE);
320 }
321 return static_cast<T>( m_buffer.get() );
322 }
323
324 template<typename... Targs,
325 std::enable_if_t< jau::is_all_same_v<Targs...> &&
326 sizeof(value_type) >= sizeof(jau::first_type<Targs...>) &&
327 ( std::is_integral_v<jau::first_type<Targs...>> ||
328 std::is_floating_point_v<jau::first_type<Targs...>> ), bool> = true>
329 constexpr_cxx20 client_t& putN(const Targs&...args) {
330 if( !proxy_t::sealed() ) {
331 growIfNeeded(sizeof...(args));
332 m_buffer.putN(jau::Bool::False, args...);
333 }
334 return *this;
335 }
336
337 constexpr_cxx20 client_t& put(std::initializer_list<value_type> initlist) {
338 if( !proxy_t::sealed() ) {
339 growIfNeeded(initlist.size());
340 m_buffer.put(initlist, jau::Bool::False);
341 }
342 return *this;
343 }
344
346 if( !proxy_t::sealed() ) {
347 growIfNeeded(1);
348 m_buffer.put(v);
349 }
350 return *this;
351 }
352 constexpr_cxx20 client_t& puti32(const int32_t v) {
353 return put(static_cast<value_type>(v));
354 }
355 constexpr_cxx20 client_t& putu32(const uint32_t v) {
356 return put(static_cast<value_type>(v));
357 }
358 constexpr_cxx20 client_t& putf(const float v) {
359 return put(static_cast<value_type>(v));
360 }
361 constexpr_cxx20 client_t& put2f(const float x, const float y) {
362 return putN(x, y);
363 }
364 constexpr_cxx20 client_t& put3f(const float x, const float y, const float z) {
365 return putN(x, y, z);
366 }
367 constexpr_cxx20 client_t& put4f(const float x, const float y, const float z, const float w) {
368 return putN(x, y, z, w);
369 }
371 return putN(v.x, v.y);
372 }
374 return putN(v.x, v.y, v.z);
375 }
377 return putN(v.x, v.y, v.z, v.w);
378 }
379
380 std::string toString() const noexcept override { return toString(false); }
381 std::string toString(bool withData) const noexcept override {
382 std::string r("GLArrayDataWrapper[");
383 r.append(proxy_t::m_name)
384 .append(", location ").append(std::to_string(proxy_t::m_location))
385 .append(", isVertexAttribute ").append(std::to_string(proxy_t::m_isVertexAttr))
386 .append(", usesShaderState ").append(std::to_string(nullptr!=m_shaderState))
387 .append(", dataType ").append(jau::toHexString(proxy_t::m_compType))
388 .append(", compsPerElem ").append(std::to_string(proxy_t::compsPerElem()))
389 .append(", stride ").append(std::to_string(proxy_t::m_strideB)).append("b ").append(std::to_string(proxy_t::m_strideL)).append("c")
390 .append(", mappedElements ").append(std::to_string(proxy_t::m_mappedElemCount))
391 .append(", ").append(proxy_t::elemStatsToString())
392 .append(", enabled ").append(std::to_string(m_bufferEnabled))
393 .append(", written ").append(std::to_string(m_bufferWritten));
394 if( withData ) {
395 r.append(", buffer ").append(proxy_t::usesClientMem()?m_buffer.toString():"nil");
396 }
397 r.append(", alive ").append(std::to_string(proxy_t::m_alive)).append("]");
398 return r;
399 }
400
401 /**
402 * Returning element-count from given componentCount, rounding up to componentsPerElement.
403 */
404 constexpr GLsizei compsToElemCount(GLsizei componentCount) const noexcept {
405 return (componentCount + proxy_t::compsPerElem() - 1) / proxy_t::compsPerElem();
406 }
407
408 /**
409 * Increase the capacity of the buffer if necessary to add given spareComponents components.
410 * <p>
411 * Buffer will not change if remaining free slots, capacity less position, satisfy spareComponents components.
412 * </p>
413 * @param spareComponents number of components to add if necessary.
414 * @return true if buffer size has changed, i.e. grown. Otherwise false.
415 */
416 bool growIfNeeded(glmemsize_t spareComponents) {
417 if( m_buffer.size() == 0 || m_buffer.remaining() < spareComponents ) {
418 const glmemsize_t has_comps = m_buffer.size();
419 const GLsizei required_elems = compsToElemCount(has_comps + spareComponents);
420 const GLsizei grown_elems = compsToElemCount(glmemsize_t(std::round(has_comps * m_growthFactor)));
421 return reserve( std::max(grown_elems, required_elems) );
422 }
423 return false;
424 }
425
426 /**
427 * Increase the capacity of the buffer to given elementCount element size,
428 * i.e. elementCount * componentsPerElement components.
429 *
430 * Buffer will not change if given elementCount is lower or equal current capacity.
431 *
432 * @param elementCount number of elements to hold.
433 * @return true if buffer size has changed, i.e. grown. Otherwise false.
434 */
435 bool reserve(GLsizei elementCount) {
437 throw RenderException("Invalid state: " + toString(), E_FILE_LINE);
438 }
439 // add the stride delta
440 elementCount += (elementCount / proxy_t::compsPerElem()) * (proxy_t::m_strideL - proxy_t::compsPerElem());
441
442 const glmemsize_t osize = m_buffer.size();
443 const glmemsize_t nsize = elementCount * proxy_t::compsPerElem();
444 if( nsize <= osize ) {
445 return false;
446 }
447 m_buffer.resize(nsize);
448 if( DEBUG_MODE ) {
449 jau::PLAIN_PRINT(true, "*** Size: Reserve: comps: %zd, %zd / %zd -> %zd / %zd; %s",
450 proxy_t::compsPerElem(), (osize / proxy_t::compsPerElem()), osize,
451 (nsize / proxy_t::compsPerElem()), nsize, m_buffer.toString().c_str());
452 }
453 return true;
454 }
455
456 /**
457 * Returns this buffer's growth factor.
458 * <p>
459 * Default is {@link #DEFAULT_GROWTH_FACTOR}, i.e. the golden ratio 1.618.
460 * </p>
461 * @see #setGrowthFactor(float)
462 * @see #DEFAULT_GROWTH_FACTOR
463 */
464 constexpr float growthFactor() const noexcept { return m_growthFactor; }
465
466 /**
467 * Sets a new growth factor for this buffer.
468 * <p>
469 * Default is {@link #DEFAULT_GROWTH_FACTOR}, i.e. the golden ratio 1.618.
470 * </p>
471 * @param v new growth factor, which will be clipped to a minimum of 1, i.e. 0% minimum growth.
472 * @see #getGrowthFactor()
473 * @see #DEFAULT_GROWTH_FACTOR
474 */
475 void setGrowthFactor(float v) noexcept {
476 m_growthFactor = std::max(1.0f, v);
477 }
478
479 // non public matters
480
481 protected:
482 void checkSeal(bool test) {
483 if( !proxy_t::m_alive ) {
484 throw RenderException("Invalid state: " + toString(), E_FILE_LINE);
485 }
486 if( proxy_t::sealed() != test ) {
487 if( test ) {
488 throw RenderException("Not Sealed yet, seal first:\n\t" + toString(), E_FILE_LINE);
489 } else {
490 throw RenderException("Already Sealed, can't modify VBO:\n\t" + toString(), E_FILE_LINE);
491 }
492 }
493 }
494
495 struct Private{ explicit Private() = default; };
496
497 /** Private client-mem ctor w/ passing custom buffer */
498 GLArrayDataClient(Private, std::string_view name, GLsizei componentsPerElement,
499 bool normalized, GLsizei stride, buffer_t&& data, float growthFactor,
501 GLuint vboName, uintptr_t vboOffset, GLenum vboUsage, GLenum vboTarget)
502 : proxy_t(typename proxy_t::Private(),
503 name, componentsPerElement,
506 m_buffer( std::move(data) ),
507 m_glArrayHandler(std::move(glArrayHandler)),
510 m_shaderState(nullptr), m_isValidated(false)
511 {
512 proxy_t::m_sealed = false;
513 }
514
515 /** Private client-mem ctor w/o passing custom buffer */
516 GLArrayDataClient(Private, std::string_view name, GLsizei componentsPerElement,
517 bool normalized, GLsizei stride, GLsizei initialElementCount, float growthFactor,
519 GLuint vboName, uintptr_t vboOffset, GLenum vboUsage, GLenum vboTarget)
520 : proxy_t(typename proxy_t::Private(),
521 name, componentsPerElement,
524 m_buffer(nullptr, initialElementCount),
525 m_glArrayHandler(std::move(glArrayHandler)),
528 m_shaderState(nullptr), m_isValidated(false)
529 {
530 proxy_t::m_sealed = false;
531 }
532
533 /// using memory mapped elements
535 std::string_view name, GLsizei componentsPerElement,
536 bool normalized, GLsizei stride, GLsizei mappedElementCount,
538 GLuint vboName, uintptr_t vboOffset, GLenum vboUsage, GLenum vboTarget)
539 : proxy_t(typename proxy_t::Private(),
540 name, componentsPerElement,
541 normalized, stride, mappedElementCount,
543 m_buffer(),
544 m_glArrayHandler(std::move(glArrayHandler)),
547 m_shaderState(nullptr), m_isValidated(false)
548 {
549 proxy_t::m_sealed = false;
550 }
551
552 virtual void init_vbo(const GL& gl) {
553 if( !m_isValidated ) {
554 m_isValidated = true;
556 }
557 }
558
561
567
568 private:
569 bool m_isValidated = false;
570 static constexpr bool DEBUG_MODE = false;
571 };
572
573 /**@}*/
574
575} // namespace gamp::render::gl::data
576
578 template<typename Value_type>
580 if( !m_ad || !m_ad->isVBO() ) {
581 return false;
582 }
583 if( bind ) {
584 // always bind and refresh the VBO mgr,
585 // in case more than one gl*Pointer objects are in use
586 m_ad->glBindBuffer(gl, true);
587 if( !m_ad->isVBOWritten() ) {
588 if( m_ad->usesClientMem() ) {
589 m_ad->glBufferData(gl);
590 }
591 m_ad->setVBOWritten(true);
592 }
593 } else {
594 m_ad->glBindBuffer(gl, false);
595 }
596 return true;
597 }
598}
599
600#endif /* GAMP_GLARRAYDATACLIENT_HPP_ */
#define E_FILE_LINE
Client data buffer for non VBO GLArrayData usage of given template-type Value_type.
std::string_view className() const noexcept override
Returns class name of implementing class.
constexpr bool enabled() const noexcept
const GLArrayDataClientRef< value_type > shared()
constexpr_cxx20 client_t & put2f(const float x, const float y)
constexpr_cxx20 client_t & put4f(const float x, const float y, const float z, const float w)
constexpr_cxx20 client_t & put2f(const jau::math::Vec2f &v)
constexpr float growthFactor() const noexcept
Returns this buffer's growth factor.
impl::GLArrayHandlerPtr< value_type > m_glArrayHandler
constexpr_cxx20 client_t & putf(const float v)
static client_ref createGLSL(std::string_view name, GLsizei compsPerElement, bool normalized, size_t initialElementCount)
Create a client side buffer object, using a custom GLSL array attribute name and starting with a new ...
constexpr_cxx20 client_t & putN(const Targs &...args)
bool bindBuffer(GL &gl, bool bind)
if bind is true and the data uses VBO, the latter will be bound and data written to the GPU if requir...
void seal(GL &gl, bool seal_)
Convenience method calling seal(bool) and enableBuffer(GL&, bool).
void enableBuffer(GL &gl, bool enable)
Enables the buffer if enable is true, and transfers the data if required.
void clear()
Clears this buffer and resets states accordingly.
void clear(GL &gl)
Clears this buffer and resets states accordingly.
GLArrayDataClient(Private, std::string_view name, GLsizei componentsPerElement, bool normalized, GLsizei stride, GLsizei initialElementCount, float growthFactor, bool isVertexAttribute, impl::GLArrayHandlerPtr< value_type > &&glArrayHandler, GLuint vboName, uintptr_t vboOffset, GLenum vboUsage, GLenum vboTarget)
Private client-mem ctor w/o passing custom buffer.
constexpr_cxx20 client_t & put(std::initializer_list< value_type > initlist)
void setVBOWritten(bool written) noexcept
Marks the buffer written to the VBO.
void setGrowthFactor(float v) noexcept
Sets a new growth factor for this buffer.
void setEnableAlways(bool always)
Affects the behavior of 'enableBuffer'.
void associate(ShaderState &st, bool enable) override
Implementation and type dependent object association.
constexpr bool isVBOWritten() const noexcept
Is the buffer written to the VBO ?
const jau::type_info & classSignature() const noexcept override
Returns type signature of implementing class.
static client_ref createGLSL(std::string_view name, GLsizei compsPerElement, bool normalized, GLsizei stride, buffer_t &&buffer)
Create a client side buffer object, using a custom GLSL array attribute name and starting with a give...
GLArrayDataClient(Private, std::string_view name, GLsizei componentsPerElement, bool normalized, GLsizei stride, buffer_t &&data, float growthFactor, bool isVertexAttribute, impl::GLArrayHandlerPtr< value_type > &&glArrayHandler, GLuint vboName, uintptr_t vboOffset, GLenum vboUsage, GLenum vboTarget)
Private client-mem ctor w/ passing custom buffer.
constexpr GLsizei compsToElemCount(GLsizei componentCount) const noexcept
Returning element-count from given componentCount, rounding up to componentsPerElement.
bool growIfNeeded(glmemsize_t spareComponents)
Increase the capacity of the buffer if necessary to add given spareComponents components.
constexpr_cxx20 client_t & put3f(const jau::math::Vec3f &v)
std::string toString() const noexcept override
constexpr_cxx20 client_t & puti32(const int32_t v)
jau::darray< value_type, glmemsize_t > buffer_t
constexpr_cxx20 client_t & putu32(const uint32_t v)
GLArrayDataClient(Private, std::string_view name, GLsizei componentsPerElement, bool normalized, GLsizei stride, GLsizei mappedElementCount, bool isVertexAttribute, impl::GLArrayHandlerPtr< value_type > &&glArrayHandler, GLuint vboName, uintptr_t vboOffset, GLenum vboUsage, GLenum vboTarget)
using memory mapped elements
constexpr_cxx20 client_t & put3f(const float x, const float y, const float z)
bool reserve(GLsizei elementCount)
Increase the capacity of the buffer to given elementCount element size, i.e.
constexpr_cxx20 client_t & put(const value_type v)
constexpr_cxx20 client_t & put4f(const jau::math::Vec4f &v)
std::string toString(bool withData) const noexcept override
std::string elemStatsToString() const noexcept override
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
const void * data() const noexcept override
Returns client-data pointer at current position if usesClientMem(), otherwise nullptr.
constexpr bool sealed() const noexcept
Returns true if data has been sealed (flipped to read), otherwise false (writing mode).
virtual void validate(const GL &gl) const
Validates this instance's parameter.
constexpr uintptr_t vboOffset() const noexcept
The VBO buffer offset if isVBO()
constexpr GLsizei compsPerElem() const noexcept
The number of components per element.
constexpr GLuint vboName() const noexcept
The VBO name or 0 if not a VBO.
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.
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
std::shared_ptr< ChildT > shared_from_base()
constexpr GLenum vboTarget() const noexcept
The VBO target or 0 if not a VBO.
bool bindBuffer(GL &gl, bool bind)
if bind is true and the data uses VBO, the latter will be bound and data written to the GPU if requir...
GLArrayDataClientRef< Value_type > m_ad
ShaderState allows to sharing data between shader programs, while updating the attribute and uniform ...
value_type x
Definition vec2f.hpp:62
value_type y
Definition vec2f.hpp:63
value_type z
Definition vec3f.hpp:68
value_type x
Definition vec3f.hpp:66
value_type y
Definition vec3f.hpp:67
value_type y
Definition vec4f.hpp:67
value_type w
Definition vec4f.hpp:69
value_type x
Definition vec4f.hpp:66
value_type z
Definition vec4f.hpp:68
Generic type information using either Runtime type information (RTTI) or Compile time type informatio...
consteval_cxx20 std::string_view name() noexcept
std::tuple_element_t< 0, std::tuple< Ts... > > first_type
#define constexpr_cxx20
constexpr qualifier replacement for C++20 constexpr.
constexpr bool is_all_same_v
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.
Definition GLBuffers.hpp:26
std::shared_ptr< GLArrayDataClient< Value_type > > GLArrayDataClientRef
GLArrayDataClientRef< float > GLFloatArrayDataClientRef
GLArrayDataClient< float > GLFloatArrayDataClient
std::unique_ptr< GLArrayHandler< Value_type > > GLArrayHandlerPtr
constexpr GLenum glType() noexcept
Definition GLTypes.hpp:46
Vector4F< float > Vec4f
Definition vec4f.hpp:360
Vector2F< float > Vec2f
Definition vec2f.hpp:404
Vector3F< float > Vec3f
Definition vec3f.hpp:422
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.
Definition backtrace.hpp:32
void PLAIN_PRINT(const bool printPrefix, const char *format,...) noexcept
Use for unconditional plain messages, prefix '[elapsed_time] ' if printPrefix == true.
Definition debug.cpp:264
STL namespace.
uint8_t Value_type