Gamp v0.0.7-36-g24b1eb6
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 GLArrayDataServerRef = 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_ref;
63 using typename proxy_t::buffer_ref;
64 using typename proxy_t::buffer_t;
66
68 typedef std::shared_ptr<server_t> server_ref;
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 The custom name for the GL attribute
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_ref createGLSL(const std::string& name, GLsizei compsPerElement,
86 bool normalized, GLsizei initialElementCount, GLenum vboUsage) {
87 server_ref 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 The custom name for the GL attribute
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_ref createGLSL(const std::string& name, GLsizei compsPerElement,
109 bool normalized, GLsizei stride, buffer_t&& buffer, GLenum vboUsage) {
110 server_ref 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 The custom name for the GL attribute
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_ref createGLSLMapped(const std::string& name, GLsizei compsPerElement,
131 bool normalized, GLsizei mappedElementCount, GLenum vboUsage) {
132 server_ref 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_ref createData(GLsizei compsPerElement,
153 GLsizei initialElementCount, GLenum vboUsage, GLenum vboTarget) {
154 server_ref r = std::make_shared<GLArrayDataServer>(Private(),
155 "", 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_ref createData(GLsizei compsPerElement,
177 GLsizei stride, buffer_t&& buffer, GLenum vboUsage, GLenum vboTarget) {
178 server_ref r = std::make_shared<GLArrayDataServer>(Private(),
179 "", 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_ref createDataMapped(GLsizei compsPerElement,
200 GLsizei mappedElementCount, GLenum vboUsage, GLenum vboTarget) {
201 server_ref r = std::make_shared<GLArrayDataServer>(Private(),
202 "", 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_ref createGLSLInterleaved(GLsizei compsPerElement,
223 bool normalized, GLsizei initialElementCount, GLenum vboUsage) {
224 server_ref r = std::make_shared<GLArrayDataServer>(Private(),
225 std::string(mgl_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_ref createGLSLInterleaved(GLsizei compsPerElement,
246 bool normalized, GLsizei stride, buffer_t&& buffer, GLenum vboUsage) {
247 server_ref r = std::make_shared<GLArrayDataServer>(Private(),
248 std::string(mgl_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_ref createGLSLInterleavedMapped(GLsizei compsPerElement,
269 bool normalized, GLsizei mappedElementCount, GLenum vboUsage) {
270 server_ref r = std::make_shared<GLArrayDataServer>(Private(),
271 std::string(mgl_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 The custom name for the GL attribute, maybe null if vboTarget is {@link GL#GL_ELEMENT_ARRAY_BUFFER}
297 * @param compsPerElement This interleaved array segment's component count per element
298 * @param vboTarget {@link GL#GL_ARRAY_BUFFER} or {@link GL#GL_ELEMENT_ARRAY_BUFFER}
299 */
300 proxy_ref addGLSLSubArray(const std::string& name, GLsizei compsPerElement, GLenum vboTarget) {
301 if( m_interleavedOffset >= uintptr_t(client_t::compsPerElem()) * uintptr_t(client_t::bytesPerComp()) ) {
302 const GLsizei iOffC = m_interleavedOffset / client_t::bytesPerComp();
303 throw RenderException("Interleaved offset > total components (" + std::to_string(iOffC) + " > " + std::to_string(client_t::compsPerElem()) + ")", E_FILE_LINE);
304 }
305 const long subStrideB = (0 == client_t::stride()) ? client_t::compsPerElem() * client_t::bytesPerComp() : client_t::stride();
306 proxy_ref ad;
308 ad = proxy_t::createGLSL(name, compsPerElement,
311 } else {
312 ad = proxy_t::createGLSL(name, compsPerElement,
315 }
317 m_interleavedOffset += compsPerElement * client_t::bytesPerComp();
318 if( GL_ARRAY_BUFFER == vboTarget ) {
319 GLArrayDataRef ad0 = std::static_pointer_cast<GLArrayData>(ad);
320 client_t::m_glArrayHandler->addSubHandler( std::move( impl::GLSLSubArrayHandler( ad0 ) ) );
321 }
322 return ad;
323 }
324
326 uintptr_t interleavedOffset() const noexcept { return interleavedOffset; }
327
328 //
329 // Data matters GLArrayData
330 //
331
332 //
333 // Data and GL state modification ..
334 //
335
336 void destroy(GL& gl) override {
337 // super.destroy(gl):
338 // - GLArrayDataClient.destroy(gl): disables & clears client-side buffer
339 // - GLArrayDataWrapper.destroy(gl) (clears all values 'vboName' ..)
340 GLuint vboName = client_t::vboName();
342 if( vboName != 0 ) {
343 ::glDeleteBuffers(1, &vboName);
345 }
346 }
347
348 //
349 // data matters
350 //
351
352 /**
353 * Convenient way do disable the VBO behavior and
354 * switch to client side data one
355 * Only possible if buffer is defined.
356 */
357 void setVBOEnabled(bool vboEnabled) override {
358 client_t::checkSeal(false);
359 client_t::setVBOEnabled(vboEnabled);
360 }
361
362#if 0
363 GLMappedBuffer mapStorage(const GL& gl, final int access) {
364 if( proxy_t::usesClientMem() ) {
365 throw jau::IllegalStateError("user buffer not null", E_FILE_LINE);
366 }
367 if( m_mappedStorage ) {
368 throw IllegalStateException("already mapped: " + m_mappedStorage);
369 }
370 proxy_t::checkSeal(true);
371 proxy_t::bindBuffer(gl, true);
372 ::glBufferData(getVBOTarget(), getByteCount(), null, getVBOUsage());
373 GLMappedBuffer storage = gl.mapBuffer(getVBOTarget(), access);
374 setMappedBuffer(storage);
375 proxy_t::bindBuffer(gl, false);
376 proxy_t::seal(false);
377 proxy_t::rewind();
378 return storage;
379 }
380 GLMappedBuffer mapStorage(const GL& gl, final long offset, final long length, final int access) {
381 if( proxyproxy_t::usesClientBuffer() ) {
382 throw IllegalStateException("user buffer not null");
383 }
384 if( null != m_mappedStorage ) {
385 throw IllegalStateException("already mapped: " + m_mappedStorage);
386 }
387 checkSeal(true);
388 bindBuffer(gl, true);
389 ::glBufferData(getVBOTarget(), getByteCount(), null, getVBOUsage());
390 GLMappedBuffer storage = gl.mapBufferRange(getVBOTarget(), offset, length, access);
391 setMappedBuffer(storage);
392 bindBuffer(gl, false);
393 seal(false);
394 rewind();
395 return storage;
396 }
397
398 private:
399 void setMappedBuffer(const GLMappedBuffer& storage) {
400 m_mappedStorage = storage;
401 TODO:
402 m_buffer = storage.getMappedBuffer();
403 }
404
405 void unmapStorage(const GL& gl) {
406 if( null == m_mappedStorage ) {
407 throw IllegalStateException("not mapped");
408 }
410 buffer = null;
411 seal(true);
412 bindBuffer(gl, true);
413 gl.glUnmapBuffer(getVBOTarget());
414 bindBuffer(gl, false);
415 }
416
417 public:
418#endif
419
420 std::string toString() const noexcept override { return toString(false); }
421 std::string toString(bool withData) const noexcept override {
422 std::string r(className());
423 r.append("[").append(proxy_t::m_name)
424 .append(", location ")
425 .append(std::to_string(proxy_t::m_location))
426 .append(", isVertexAttribute ")
427 .append(std::to_string(proxy_t::m_isVertexAttr))
428 .append(", usesShaderState ")
429 .append(std::to_string(nullptr != client_t::m_shaderState))
430 .append(", dataType ")
432 .append(", compsPerElem ")
433 .append(std::to_string(proxy_t::compsPerElem()))
434 .append(", stride ")
435 .append(std::to_string(proxy_t::m_strideB))
436 .append("b ")
437 .append(std::to_string(proxy_t::m_strideL))
438 .append("c")
439 .append(", mappedElements ")
440 .append(std::to_string(proxy_t::m_mappedElemCount))
441 .append(", ")
443 .append(", mappedStorage ")
444 .append(jau::to_hexstring(m_mappedStorage ? m_mappedStorage.get() : nullptr))
445 .append(", vboEnabled ")
446 .append(std::to_string(client_t::m_vboEnabled))
447 .append(", vboName ")
448 .append(std::to_string(client_t::m_vboName))
449 .append(", vboUsage ")
451 .append(", vboTarget ")
453 .append(", vboOffset ")
454 .append(std::to_string(client_t::m_vboOffset))
455 .append(", enabled ")
456 .append(std::to_string(client_t::m_bufferEnabled))
457 .append(", written ")
458 .append(std::to_string(client_t::m_bufferWritten));
459 if( withData ) {
460 r.append(", buffer ").append(proxy_t::usesClientMem() ? m_buffer.toString() : "nil");
461 }
462 r.append(", alive ")
463 .append(std::to_string(proxy_t::m_alive))
464 .append("]");
465 return r;
466 }
467
468 //
469 // non public matters ..
470 //
471
472 protected:
473 struct Private {
474 explicit Private() = default;
475 };
476
477 public:
478 /** Private client-mem ctor w/ passing custom buffer */
479 GLArrayDataServer(Private, const std::string& name, GLsizei componentsPerElement,
480 bool normalized, GLsizei stride, buffer_t&& data, float growthFactor,
482 GLuint vboName, uintptr_t vboOffset, GLenum vboUsage, GLenum vboTarget)
483 : client_t(typename client_t::Private(),
484 name, componentsPerElement,
486 isVertexAttribute, std::move(glArrayHandler),
489 }
490
491 /** Private client-mem ctor w/o passing custom buffer */
492 GLArrayDataServer(Private, const std::string& name, GLsizei componentsPerElement,
493 bool normalized, GLsizei stride, GLsizei initialElementCount, float growthFactor,
495 GLuint vboName, uintptr_t vboOffset, GLenum vboUsage, GLenum vboTarget)
496 : client_t(typename client_t::Private(),
497 name, componentsPerElement,
498 normalized, stride, initialElementCount, growthFactor,
499 isVertexAttribute, std::move(glArrayHandler),
502 }
503
504 /// using memory mapped elements
505 GLArrayDataServer(Private, const std::string& name, GLsizei componentsPerElement,
506 bool normalized, GLsizei stride, GLsizei mappedElementCount,
508 GLuint vboName, uintptr_t vboOffset, GLenum vboUsage, GLenum vboTarget)
509 : client_t(typename client_t::Private(),
510 name, componentsPerElement,
511 normalized, stride, mappedElementCount,
512 isVertexAttribute, std::move(glArrayHandler),
515 }
516
517 protected:
518 void init_vbo(const GL& gl) override {
520 if( proxy_t::isVBO() && proxy_t::m_vboName == 0 ) {
521 GLuint tmp = 0;
522 ::glGenBuffers(1, &tmp);
523 proxy_t::m_vboName = tmp;
524 if( 0 < m_interleavedOffset ) {
526 }
527 }
528 }
529
530 uintptr_t m_interleavedOffset = 0;
532 };
533
534 /**@}*/
535} // namespace gamp::render::gl::data
536
537#endif /* GAMP_GLARRAYDATACLIENT_HPP_ */
#define E_FILE_LINE
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, const std::string &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.
Proxying a data buffer for GLArrayData usage of given template-type Value_type.
static proxy_ref createGLSL(const std::string &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
jau::darray< value_type, glmemsize_t > buffer_t
void glBufferData(const GL &gl) const noexcept
Server data buffer for VBO GLArrayData usage of given template-type Value_type.
static server_ref createGLSLMapped(const std::string &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,...
static server_ref 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...
static server_ref 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.
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_ref createDataMapped(GLsizei compsPerElement, GLsizei mappedElementCount, GLenum vboUsage, GLenum vboTarget)
Create a VBO data object for any target w/o render pipeline association, i.e.
std::string toString() const noexcept override
static server_ref 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...
const GLArrayDataServerRef< value_type > shared()
static server_ref createGLSL(const std::string &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_ref createGLSL(const std::string &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 ...
static server_ref 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...
GLArrayDataServer(Private, const std::string &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.
std::string toString(bool withData) const noexcept override
static server_ref createGLSLInterleavedMapped(GLsizei compsPerElement, bool normalized, GLsizei mappedElementCount, GLenum vboUsage)
Create a VBO for GLSL interleaved array data intended for GPU buffer storage mapping,...
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.
GLArrayDataServer(Private, const std::string &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
GLArrayDataServer(Private, const std::string &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.
proxy_ref addGLSLSubArray(const std::string &name, GLsizei compsPerElement, GLenum vboTarget)
Configure a segment of this GLSL interleaved array (see createGLSLInterleaved(int,...
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
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
std::shared_ptr< GLArrayData > GLArrayDataRef
std::shared_ptr< GLArrayDataServer< Value_type > > GLArrayDataServerRef
GLArrayDataServerRef< float > GLFloatArrayDataServerRef
GLArrayDataServer< uint32_t > GLUIntArrayDataServer
GLArrayDataServerRef< uint32_t > GLUIntArrayDataServerRef
std::unique_ptr< GLMappedBuffer > GLMappedBufferPtr
std::unique_ptr< GLArrayHandler< Value_type > > GLArrayHandlerPtr
static constexpr std::string_view mgl_InterleaveArray
std::string to_hexstring(value_type const &v, const bool skipLeading0x=false) noexcept
Produce a lower-case hexadecimal string representation with leading 0x in MSB of the given pointer.
STL namespace.
uint8_t Value_type