Gamp v0.0.8
Gamp: Graphics, Audio, Multimedia and Processing
Loading...
Searching...
No Matches
GLArrayDataServer.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_GLARRAYDATASERVER_HPP_
13#define GAMP_GLARRAYDATASERVER_HPP_
14
15#include <cmath>
16
17#include <jau/basic_types.hpp>
18#include <jau/float_types.hpp>
19#include <jau/string_util.hpp>
20
31#include <memory>
32
33namespace gamp::render::gl::data {
34 using namespace gamp::render::gl;
35
36 /** \addtogroup Gamp_GLData
37 *
38 * @{
39 */
40 template <typename Value_type>
42
43 template <typename Value_type>
44 using GLArrayDataServerSRef = std::shared_ptr<GLArrayDataServer<Value_type>>;
45
50
51 /**
52 * Server data buffer for VBO GLArrayData usage of given template-type Value_type.
53 *
54 * The GL data type is determined via template type glType<Value_type>().
55 */
56 template <typename Value_type>
57 class GLArrayDataServer : public GLArrayDataClient<Value_type> {
58 public:
62 typedef std::shared_ptr<proxy_t> proxy_sref;
63 using typename proxy_t::buffer_sref;
64 using typename proxy_t::buffer_t;
66
68 typedef std::shared_ptr<server_t> server_sref;
69
70 //
71 // lifetime matters
72 //
73
74 /**
75 * Create a VBO, using a custom GLSL array attribute name
76 * and starting with a new created Buffer object with initialElementCount size
77 *
78 * The GL data type is determined via template type glType<Value_type>().
79 * @param name Persistent custom name for the GL attribute, must be valid through the lifecycle of this instance
80 * @param compsPerElement component count per element
81 * @param normalized Whether the data shall be normalized
82 * @param initialElementCount
83 * @param vboUsage {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW}
84 */
85 static server_sref createGLSL(std::string_view name, GLsizei compsPerElement,
86 bool normalized, GLsizei initialElementCount, GLenum vboUsage) {
87 server_sref r = std::make_shared<GLArrayDataServer>(Private(),
88 name, compsPerElement,
89 normalized, /*stride=*/0, initialElementCount, client_t::DEFAULT_GROWTH_FACTOR,
90 /*isVertexAttribute=*/true, std::move(std::make_unique<impl::GLSLArrayHandler<value_type>>()),
91 /*vboName=*/0, /*vboOffset=*/0, vboUsage, GL_ARRAY_BUFFER);
92 r->m_glArrayHandler->set(r);
93 return r;
94 }
95
96 /**
97 * Create a VBO, using a custom GLSL array attribute name
98 * and starting with a given Buffer object incl it's stride
99 *
100 * The GL data type is determined via template type glType<Value_type>().
101 * @param name Persistent custom name for the GL attribute, must be valid through the lifecycle of this instance
102 * @param compsPerElement component count per element
103 * @param normalized Whether the data shall be normalized
104 * @param stride in bytes from one element to the other. If zero, compsPerElement * compSizeInBytes
105 * @param buffer the user define data, taking ownership
106 * @param vboUsage {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW}
107 */
108 static server_sref createGLSL(std::string_view name, GLsizei compsPerElement,
109 bool normalized, GLsizei stride, buffer_t&& buffer, GLenum vboUsage) {
110 server_sref r = std::make_shared<GLArrayDataServer>(Private(),
111 name, compsPerElement,
113 /*isVertexAttribute=*/true, std::move(std::make_unique<impl::GLSLArrayHandler<value_type>>()),
114 /*vboName=*/0, /*vboOffset=*/0, vboUsage, GL_ARRAY_BUFFER);
115 r->m_glArrayHandler->set(r);
116 return r;
117 }
118
119 /**
120 * Create a VBO, using a custom GLSL array attribute name
121 * intended for GPU buffer storage mapping, see {@link GLMappedBuffer}, via {@link #mapStorage(GL, int)} and {@link #mapStorage(GL, long, long, int)}.
122 *
123 * The GL data type is determined via template type glType<Value_type>().
124 * @param name Persistent custom name for the GL attribute, must be valid through the lifecycle of this instance
125 * @param compsPerElement component count per element
126 * @param normalized Whether the data shall be normalized
127 * @param mappedElementCount
128 * @param vboUsage {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW}
129 */
130 static server_sref createGLSLMapped(std::string_view name, GLsizei compsPerElement,
131 bool normalized, GLsizei mappedElementCount, GLenum vboUsage) {
132 server_sref r = std::make_shared<GLArrayDataServer>(Private(),
133 name, compsPerElement,
134 normalized, /*stride=*/0, mappedElementCount,
135 /*isVertexAttribute=*/true, std::move(std::make_unique<impl::GLSLArrayHandler<value_type>>()),
136 /*vboName=*/0, /*vboOffset=*/0, vboUsage, GL_ARRAY_BUFFER);
137 r->m_glArrayHandler->set(r);
138 return r;
139 }
140
141 /**
142 * Create a VBO data object for any target w/o render pipeline association, ie {@link GL#GL_ELEMENT_ARRAY_BUFFER}.
143 *
144 * Hence no index, name for a fixed function pipeline nor vertex attribute is given.
145 *
146 * The GL data type is determined via template type glType<Value_type>().
147 * @param compsPerElement component count per element
148 * @param initialElementCount
149 * @param vboUsage {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW}
150 * @param vboTarget {@link GL#GL_ELEMENT_ARRAY_BUFFER}, ..
151 */
152 static server_sref createData(GLsizei compsPerElement,
153 GLsizei initialElementCount, GLenum vboUsage, GLenum vboTarget) {
154 server_sref r = std::make_shared<GLArrayDataServer>(Private(),
155 "data", compsPerElement,
156 /*normalized=*/false, /*stride=*/0, initialElementCount, client_t::DEFAULT_GROWTH_FACTOR,
157 /*isVertexAttribute=*/false, std::move(std::make_unique<impl::GLDataArrayHandler<value_type>>()),
158 /*vboName=*/0, /*vboOffset=*/0, vboUsage, vboTarget);
159 r->m_glArrayHandler->set(r);
160 return r;
161 }
162
163 /**
164 * Create a VBO data object for any target w/o render pipeline association, ie {@link GL#GL_ELEMENT_ARRAY_BUFFER}.
165 *
166 * Hence no index, name for a fixed function pipeline nor vertex attribute is given.
167 *
168 * The GL data type is determined via template type glType<Value_type>().
169 * @param compsPerElement component count per element
170 * @param stride in bytes from one element to the other. If zero, compsPerElement * compSizeInBytes
171 * @param buffer the user define data, taking ownership
172 * @param vboUsage {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW}
173 * @param vboTarget {@link GL#GL_ELEMENT_ARRAY_BUFFER}, ..
174 * {@link GL#glGenBuffers(int, int[], int)
175 */
176 static server_sref createData(GLsizei compsPerElement,
177 GLsizei stride, buffer_t&& buffer, GLenum vboUsage, GLenum vboTarget) {
178 server_sref r = std::make_shared<GLArrayDataServer>(Private(),
179 "data", compsPerElement,
180 /*normalized=*/false, stride, std::move(buffer), client_t::DEFAULT_GROWTH_FACTOR,
181 /*isVertexAttribute=*/false, std::move(std::make_unique<impl::GLDataArrayHandler<value_type>>()),
182 /*vboName=*/0, /*vboOffset=*/0, vboUsage, vboTarget);
183 r->m_glArrayHandler->set(r);
184 return r;
185 }
186
187 /**
188 * Create a VBO data object for any target w/o render pipeline association, i.e. {@link GL#GL_ELEMENT_ARRAY_BUFFER},
189 * intended for GPU buffer storage mapping, see {@link GLMappedBuffer}, via {@link #mapStorage(GL, int)} and {@link #mapStorage(GL, long, long, int)}.
190 *
191 * No index, name for a fixed function pipeline nor vertex attribute is given.
192 *
193 * The GL data type is determined via template type glType<Value_type>().
194 * @param compsPerElement component count per element
195 * @param mappedElementCount
196 * @param vboUsage {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW}
197 * @param vboTarget {@link GL#GL_ELEMENT_ARRAY_BUFFER}, ..
198 */
199 static server_sref createDataMapped(GLsizei compsPerElement,
200 GLsizei mappedElementCount, GLenum vboUsage, GLenum vboTarget) {
201 server_sref r = std::make_shared<GLArrayDataServer>(Private(),
202 "mdata", compsPerElement,
203 /*normalized=*/false, /*stride=*/0, mappedElementCount,
204 /*isVertexAttribute=*/false, std::move(std::make_unique<impl::GLDataArrayHandler<value_type>>()),
205 /*vboName=*/0, /*vboOffset=*/0, vboUsage, vboTarget);
206 r->m_glArrayHandler->set(r);
207 return r;
208 }
209
210 /**
211 * Create a VBO for GLSL interleaved array data
212 * starting with a new created Buffer object with initialElementCount size.
213 *
214 * User needs to <i>configure</i> the interleaved segments via {@link #addGLSLSubArray(int, int, int)}.
215 *
216 * The GL data type is determined via template type glType<Value_type>().
217 * @param compsPerElement The total number of all interleaved components per element.
218 * @param normalized Whether the data shall be normalized
219 * @param initialElementCount The initial number of all interleaved elements
220 * @param vboUsage {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW}
221 */
222 static server_sref createGLSLInterleaved(GLsizei compsPerElement,
223 bool normalized, GLsizei initialElementCount, GLenum vboUsage) {
224 server_sref r = std::make_shared<GLArrayDataServer>(Private(),
225 gca_InterleaveArray, compsPerElement,
226 normalized, /*stride=*/0, initialElementCount, client_t::DEFAULT_GROWTH_FACTOR,
227 /*isVertexAttribute=*/false, std::move(std::make_unique<impl::GLSLArrayHandlerInterleaved<value_type>>()),
228 /*vboName=*/0, /*vboOffset=*/0, vboUsage, GL_ARRAY_BUFFER);
229 r->m_glArrayHandler->set(r);
230 return r;
231 }
232
233 /**
234 * Create a VBO for GLSL interleaved array data
235 * starting with a given Buffer object incl it's stride
236 * <p>User needs to <i>configure</i> the interleaved segments via {@link #addGLSLSubArray(int, int, int)}.</p>
237 *
238 * The GL data type is determined via template type glType<Value_type>().
239 * @param compsPerElement The total number of all interleaved components per element.
240 * @param normalized Whether the data shall be normalized
241 * @param stride in bytes from one element of a sub-array to the other. If zero, compsPerElement * compSizeInBytes
242 * @param buffer The user define data of all interleaved elements, taking ownership
243 * @param vboUsage {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW}
244 */
245 static server_sref createGLSLInterleaved(GLsizei compsPerElement,
246 bool normalized, GLsizei stride, buffer_t&& buffer, GLenum vboUsage) {
247 server_sref r = std::make_shared<GLArrayDataServer>(Private(),
248 gca_InterleaveArray, compsPerElement,
250 /*isVertexAttribute=*/true, std::move(std::make_unique<impl::GLSLArrayHandlerInterleaved<value_type>>()),
251 /*vboName=*/0, /*vboOffset=*/0, vboUsage, GL_ARRAY_BUFFER);
252 r->m_glArrayHandler->set(r);
253 return r;
254 }
255
256 /**
257 * Create a VBO for GLSL interleaved array data
258 * intended for GPU buffer storage mapping, see {@link GLMappedBuffer}, via {@link #mapStorage(GL, int)} and {@link #mapStorage(GL, long, long, int)}.
259 *
260 * User needs to <i>configure</i> the interleaved segments via {@link #addGLSLSubArray(int, int, int)}.
261 *
262 * The GL data type is determined via template type glType<Value_type>().
263 * @param compsPerElement The total number of all interleaved components per element.
264 * @param normalized Whether the data shall be normalized
265 * @param mappedElementCount The total number of all interleaved elements
266 * @param vboUsage {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW}
267 */
268 static server_sref createGLSLInterleavedMapped(GLsizei compsPerElement,
269 bool normalized, GLsizei mappedElementCount, GLenum vboUsage) {
270 server_sref r = std::make_shared<GLArrayDataServer>(Private(),
271 gca_InterleaveArray, compsPerElement,
272 normalized, /*stride=*/0, mappedElementCount,
273 /*isVertexAttribute=*/false, std::move(std::make_unique<impl::GLSLArrayHandlerInterleaved<value_type>>()),
274 /*vboName=*/0, /*vboOffset=*/0, vboUsage, GL_ARRAY_BUFFER);
275 r->m_glArrayHandler->set(r);
276 return r;
277 }
278
279 std::string_view className() const noexcept override { return "GLArrayDataServer"; }
280
281 const jau::type_info& classSignature() const noexcept override {
283 }
284
286
287 /**
288 * Configure a segment of this GLSL interleaved array (see {@link #createGLSLInterleaved(int, int, boolean, int, int)}).
289 *
290 * This method may be called several times as long the sum of interleaved components does not
291 * exceed the total component count of the created interleaved array.
292 *
293 * The memory of this interleaved array is being used (shared)
294 *
295 * Must be called before using the array, eg: {@link #seal(boolean)}, {@link #putf(float)}, ..
296 * @param name Persistent custom name for the GL attribute, maybe null if vboTarget is {@link GL#GL_ELEMENT_ARRAY_BUFFER}.
297 * must be valid through the lifecycle of this instance.
298 * @param compsPerElement This interleaved array segment's component count per element
299 * @param vboTarget {@link GL#GL_ARRAY_BUFFER} or {@link GL#GL_ELEMENT_ARRAY_BUFFER}
300 */
301 proxy_sref addGLSLSubArray(std::string_view name, GLsizei compsPerElement, GLenum vboTarget) {
302 if( m_interleavedOffset >= uintptr_t(client_t::compsPerElem()) * uintptr_t(client_t::bytesPerComp()) ) {
303 const GLsizei iOffC = m_interleavedOffset / client_t::bytesPerComp();
304 throw RenderException("Interleaved offset > total components (" + std::to_string(iOffC) + " > " + std::to_string(client_t::compsPerElem()) + ")", E_FILE_LINE);
305 }
306 const long subStrideB = (0 == client_t::stride()) ? client_t::compsPerElem() * client_t::bytesPerComp() : client_t::stride();
307 proxy_sref ad;
309 ad = proxy_t::createGLSL(name, compsPerElement,
312 } else {
313 ad = proxy_t::createGLSL(name, compsPerElement,
316 }
318 m_interleavedOffset += compsPerElement * client_t::bytesPerComp();
319 if( GL_ARRAY_BUFFER == vboTarget ) {
320 GLArrayDataSRef ad0 = std::static_pointer_cast<GLArrayData>(ad);
321 client_t::m_glArrayHandler->addSubHandler( std::move( impl::GLSLSubArrayHandler( ad0 ) ) );
322 }
323 return ad;
324 }
325
327 uintptr_t interleavedOffset() const noexcept { return interleavedOffset; }
328
329 //
330 // Data matters GLArrayData
331 //
332
333 //
334 // Data and GL state modification ..
335 //
336
337 void destroy(GL& gl) override {
338 // super.destroy(gl):
339 // - GLArrayDataClient.destroy(gl): disables & clears client-side buffer
340 // - GLArrayDataWrapper.destroy(gl) (clears all values 'vboName' ..)
341 GLuint vboName = client_t::vboName();
343 if( vboName != 0 ) {
344 ::glDeleteBuffers(1, &vboName);
346 }
347 }
348
349 //
350 // data matters
351 //
352
353 /**
354 * Convenient way do disable the VBO behavior and
355 * switch to client side data one
356 * Only possible if buffer is defined.
357 */
358 void setVBOEnabled(bool vboEnabled) override {
359 client_t::checkSeal(false);
360 client_t::setVBOEnabled(vboEnabled);
361 }
362
363#if 0
364 GLMappedBuffer mapStorage(const GL& gl, final int access) {
365 if( proxy_t::usesClientMem() ) {
366 throw jau::IllegalStateError("user buffer not null", E_FILE_LINE);
367 }
368 if( m_mappedStorage ) {
369 throw IllegalStateException("already mapped: " + m_mappedStorage);
370 }
371 proxy_t::checkSeal(true);
372 proxy_t::bindBuffer(gl, true);
373 ::glBufferData(getVBOTarget(), getByteCount(), null, getVBOUsage());
374 GLMappedBuffer storage = gl.mapBuffer(getVBOTarget(), access);
375 setMappedBuffer(storage);
376 proxy_t::bindBuffer(gl, false);
377 proxy_t::seal(false);
378 proxy_t::rewind();
379 return storage;
380 }
381 GLMappedBuffer mapStorage(const GL& gl, final long offset, final long length, final int access) {
382 if( proxyproxy_t::usesClientBuffer() ) {
383 throw IllegalStateException("user buffer not null");
384 }
385 if( null != m_mappedStorage ) {
386 throw IllegalStateException("already mapped: " + m_mappedStorage);
387 }
388 checkSeal(true);
389 bindBuffer(gl, true);
390 ::glBufferData(getVBOTarget(), getByteCount(), null, getVBOUsage());
391 GLMappedBuffer storage = gl.mapBufferRange(getVBOTarget(), offset, length, access);
392 setMappedBuffer(storage);
393 bindBuffer(gl, false);
394 seal(false);
395 rewind();
396 return storage;
397 }
398
399 private:
400 void setMappedBuffer(const GLMappedBuffer& storage) {
401 m_mappedStorage = storage;
402 TODO:
403 m_buffer = storage.getMappedBuffer();
404 }
405
406 void unmapStorage(const GL& gl) {
407 if( null == m_mappedStorage ) {
408 throw IllegalStateException("not mapped");
409 }
411 buffer = null;
412 seal(true);
413 bindBuffer(gl, true);
414 gl.glUnmapBuffer(getVBOTarget());
415 bindBuffer(gl, false);
416 }
417
418 public:
419#endif
420
421 std::string toString() const noexcept override { return toString(false); }
422 std::string toString(bool withData) const noexcept override {
423 std::string r(className());
424 r.append("[").append(proxy_t::m_name)
425 .append(", location ")
426 .append(std::to_string(proxy_t::m_location))
427 .append(", isVertexAttribute ")
428 .append(std::to_string(proxy_t::m_isVertexAttr))
429 .append(", usesShaderState ")
430 .append(std::to_string(nullptr != client_t::m_shaderState))
431 .append(", dataType ")
433 .append(", compsPerElem ")
434 .append(std::to_string(proxy_t::compsPerElem()))
435 .append(", stride ")
436 .append(std::to_string(proxy_t::m_strideB))
437 .append("b ")
438 .append(std::to_string(proxy_t::m_strideL))
439 .append("c")
440 .append(", mappedElements ")
441 .append(std::to_string(proxy_t::m_mappedElemCount))
442 .append(", ")
444 .append(", mappedStorage ")
445 .append(jau::toHexString(m_mappedStorage ? m_mappedStorage.get() : nullptr))
446 .append(", vboEnabled ")
447 .append(std::to_string(client_t::m_vboEnabled))
448 .append(", vboName ")
449 .append(std::to_string(client_t::m_vboName))
450 .append(", vboUsage ")
452 .append(", vboTarget ")
454 .append(", vboOffset ")
455 .append(std::to_string(client_t::m_vboOffset))
456 .append(", enabled ")
457 .append(std::to_string(client_t::m_bufferEnabled))
458 .append(", written ")
459 .append(std::to_string(client_t::m_bufferWritten));
460 if( withData ) {
461 r.append(", buffer ").append(proxy_t::usesClientMem() ? m_buffer.toString() : "nil");
462 }
463 r.append(", alive ")
464 .append(std::to_string(proxy_t::m_alive))
465 .append("]");
466 return r;
467 }
468
469 //
470 // non public matters ..
471 //
472
473 protected:
474 struct Private {
475 explicit Private() = default;
476 };
477
478 public:
479 /** Private client-mem ctor w/ passing custom buffer */
480 GLArrayDataServer(Private, std::string_view name, GLsizei componentsPerElement,
481 bool normalized, GLsizei stride, buffer_t&& data, float growthFactor,
482 bool isVertexAttribute, impl::GLArrayHandlerPtr<value_type>&& glArrayHandler,
483 GLuint vboName, uintptr_t vboOffset, GLenum vboUsage, GLenum vboTarget)
484 : client_t(typename client_t::Private(),
485 name, componentsPerElement,
487 isVertexAttribute, std::move(glArrayHandler),
490 }
491
492 /** Private client-mem ctor w/o passing custom buffer */
493 GLArrayDataServer(Private, std::string_view name, GLsizei componentsPerElement,
494 bool normalized, GLsizei stride, GLsizei initialElementCount, float growthFactor,
495 bool isVertexAttribute, impl::GLArrayHandlerPtr<value_type>&& glArrayHandler,
496 GLuint vboName, uintptr_t vboOffset, GLenum vboUsage, GLenum vboTarget)
497 : client_t(typename client_t::Private(),
498 name, componentsPerElement,
499 normalized, stride, initialElementCount, growthFactor,
500 isVertexAttribute, std::move(glArrayHandler),
503 }
504
505 /// using memory mapped elements
506 GLArrayDataServer(Private, std::string_view name, GLsizei componentsPerElement,
507 bool normalized, GLsizei stride, GLsizei mappedElementCount,
508 bool isVertexAttribute, impl::GLArrayHandlerPtr<value_type>&& glArrayHandler,
509 GLuint vboName, uintptr_t vboOffset, GLenum vboUsage, GLenum vboTarget)
510 : client_t(typename client_t::Private(),
511 name, componentsPerElement,
512 normalized, stride, mappedElementCount,
513 isVertexAttribute, std::move(glArrayHandler),
516 }
517
518 protected:
519 void init_vbo(const GL& gl) override {
521 if( proxy_t::isVBO() && proxy_t::m_vboName == 0 ) {
522 ::glGenBuffers(1, &(proxy_t::m_vboName));
523 if( 0 < m_interleavedOffset ) {
525 }
526 }
527 }
528
529 uintptr_t m_interleavedOffset = 0;
531 };
532
533 /**@}*/
534} // namespace gamp::render::gl::data
535
536#endif /* GAMP_GLARRAYDATACLIENT_HPP_ */
impl::GLArrayHandlerPtr< value_type > m_glArrayHandler
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).
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/o passing custom buffer.
Proxying a data buffer for GLArrayData usage of given template-type Value_type.
std::string elemStatsToString() const noexcept override
jau::darray< value_type, glmemsize_t > buffer_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 glBufferData(const GL &gl) const noexcept
Server data buffer for VBO GLArrayData usage of given template-type Value_type.
static server_sref createGLSLInterleaved(GLsizei compsPerElement, bool normalized, GLsizei initialElementCount, GLenum vboUsage)
Create a VBO for GLSL interleaved array data starting with a new created Buffer object with initialEl...
GLArrayDataServer(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.
void setVBOEnabled(bool vboEnabled) override
Convenient way do disable the VBO behavior and switch to client side data one Only possible if buffer...
void setInterleavedOffset(uintptr_t interleavedOffset) noexcept
static server_sref createGLSL(std::string_view name, GLsizei compsPerElement, bool normalized, GLsizei initialElementCount, GLenum vboUsage)
Create a VBO, using a custom GLSL array attribute name and starting with a new created Buffer object ...
GLArrayDataServer(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
std::string toString() const noexcept override
proxy_sref addGLSLSubArray(std::string_view name, GLsizei compsPerElement, GLenum vboTarget)
Configure a segment of this GLSL interleaved array (see createGLSLInterleaved(int,...
const GLArrayDataServerSRef< value_type > shared()
static server_sref createGLSLInterleaved(GLsizei compsPerElement, bool normalized, GLsizei stride, buffer_t &&buffer, GLenum vboUsage)
Create a VBO for GLSL interleaved array data starting with a given Buffer object incl it's stride.
static server_sref createGLSLInterleavedMapped(GLsizei compsPerElement, bool normalized, GLsizei mappedElementCount, GLenum vboUsage)
Create a VBO for GLSL interleaved array data intended for GPU buffer storage mapping,...
static server_sref createData(GLsizei compsPerElement, GLsizei stride, buffer_t &&buffer, GLenum vboUsage, GLenum vboTarget)
Create a VBO data object for any target w/o render pipeline association, ie GL#GL_ELEMENT_ARRAY_BUFFE...
static server_sref createGLSLMapped(std::string_view name, GLsizei compsPerElement, bool normalized, GLsizei mappedElementCount, GLenum vboUsage)
Create a VBO, using a custom GLSL array attribute name intended for GPU buffer storage mapping,...
std::string toString(bool withData) const noexcept override
jau::darray< value_type, glmemsize_t > buffer_t
const jau::type_info & classSignature() const noexcept override
Returns type signature of implementing class.
std::string_view className() const noexcept override
Returns class name of implementing class.
static server_sref createGLSL(std::string_view name, GLsizei compsPerElement, bool normalized, GLsizei stride, buffer_t &&buffer, GLenum vboUsage)
Create a VBO, using a custom GLSL array attribute name and starting with a given Buffer object incl i...
static server_sref createDataMapped(GLsizei compsPerElement, GLsizei mappedElementCount, GLenum vboUsage, GLenum vboTarget)
Create a VBO data object for any target w/o render pipeline association, i.e.
GLArrayDataServer(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.
static server_sref createData(GLsizei compsPerElement, GLsizei initialElementCount, GLenum vboUsage, GLenum vboTarget)
Create a VBO data object for any target w/o render pipeline association, ie GL#GL_ELEMENT_ARRAY_BUFFE...
constexpr uintptr_t vboOffset() const noexcept
The VBO buffer offset if isVBO()
constexpr GLsizei compsPerElem() const noexcept
The number of components per element.
virtual void setVBOEnabled(bool vboEnabled)
Enable or disable use of VBO.
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 GLsizei bytesPerComp() const noexcept
The component's size in bytes.
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
constexpr bool isVBO() const noexcept
Determines whether the data is server side (VBO) and enabled, or a client side array (false).
std::shared_ptr< ChildT > shared_from_base()
constexpr GLenum vboTarget() const noexcept
The VBO target or 0 if not a VBO.
OpenGL mapped buffer storage object reflecting it's.
Generic type information using either Runtime type information (RTTI) or Compile time type informatio...
consteval_cxx20 std::string_view name() noexcept
#define E_FILE_LINE
const jau::type_info & static_ctti() noexcept
Returns a static global reference of make_ctti<T>(true) w/ identity instance.
@ null
Denotes a func::null_target_t.
GLArrayDataServer< float > GLFloatArrayDataServer
GLArrayDataServerSRef< float > GLFloatArrayDataServerSRef
std::shared_ptr< GLArrayData > GLArrayDataSRef
GLArrayDataServer< uint32_t > GLUIntArrayDataServer
GLArrayDataServerSRef< uint32_t > GLUIntArrayDataServerSRef
std::shared_ptr< GLArrayDataServer< Value_type > > GLArrayDataServerSRef
std::unique_ptr< GLMappedBuffer > GLMappedBufferPtr
static constexpr std::string_view gca_InterleaveArray
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.
STL namespace.
uint8_t Value_type