43 case GL_UNSIGNED_BYTE:
44 case GL_UNSIGNED_SHORT:
103 case GL_UNSIGNED_BYTE:
104 case GL_UNSIGNED_BYTE_3_3_2:
105 case GL_UNSIGNED_BYTE_2_3_3_REV:
106 return sizeof(uint8_t);
109 case GL_UNSIGNED_SHORT:
110 case GL_UNSIGNED_SHORT_5_6_5:
111 case GL_UNSIGNED_SHORT_5_6_5_REV:
112 case GL_UNSIGNED_SHORT_4_4_4_4:
113 case GL_UNSIGNED_SHORT_4_4_4_4_REV:
114 case GL_UNSIGNED_SHORT_5_5_5_1:
115 case GL_UNSIGNED_SHORT_1_5_5_5_REV:
116 case GL_UNSIGNED_SHORT_8_8_APPLE:
117 case GL_UNSIGNED_SHORT_8_8_REV_APPLE:
120 return sizeof(uint16_t);
124 case GL_UNSIGNED_INT:
125 case GL_UNSIGNED_INT_8_8_8_8:
126 case GL_UNSIGNED_INT_8_8_8_8_REV:
127 case GL_UNSIGNED_INT_10_10_10_2:
128 case GL_UNSIGNED_INT_2_10_10_10_REV:
129 case GL_UNSIGNED_INT_24_8:
130 case GL_UNSIGNED_INT_10F_11F_11F_REV:
131 case GL_UNSIGNED_INT_5_9_9_9_REV:
133 case GL_SIGNED_HILO16_NV:
134 return sizeof(uint32_t);
136 case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
137 return sizeof(uint64_t);
178 return jau::DataBuffer<int8_t, glmemsize_t>::create(numElements);
180 case GL_UNSIGNED_BYTE:
181 case GL_UNSIGNED_BYTE_3_3_2:
182 case GL_UNSIGNED_BYTE_2_3_3_REV:
183 return jau::DataBuffer<uint8_t, glmemsize_t>::create(numElements);
186 return jau::DataBuffer<int16_t, glmemsize_t>::create(numElements);
188 case GL_UNSIGNED_SHORT:
189 case GL_UNSIGNED_SHORT_5_6_5:
190 case GL_UNSIGNED_SHORT_5_6_5_REV:
191 case GL_UNSIGNED_SHORT_4_4_4_4:
192 case GL_UNSIGNED_SHORT_4_4_4_4_REV:
193 case GL_UNSIGNED_SHORT_5_5_5_1:
194 case GL_UNSIGNED_SHORT_1_5_5_5_REV:
195 case GL_UNSIGNED_SHORT_8_8_APPLE:
196 case GL_UNSIGNED_SHORT_8_8_REV_APPLE:
199 return jau::DataBuffer<uint16_t, glmemsize_t>::create(numElements);
202 return jau::DataBuffer<int32_t, glmemsize_t>::create(numElements);
205 case GL_SIGNED_HILO16_NV:
206 case GL_UNSIGNED_INT:
207 case GL_UNSIGNED_INT_8_8_8_8:
208 case GL_UNSIGNED_INT_8_8_8_8_REV:
209 case GL_UNSIGNED_INT_10_10_10_2:
210 case GL_UNSIGNED_INT_2_10_10_10_REV:
211 case GL_UNSIGNED_INT_24_8:
212 case GL_UNSIGNED_INT_10F_11F_11F_REV:
213 case GL_UNSIGNED_INT_5_9_9_9_REV:
215 return jau::DataBuffer<uint32_t, glmemsize_t>::create(numElements);
217 case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
218 return jau::DataBuffer<uint64_t, glmemsize_t>::create(numElements);
221 return jau::DataBuffer<jau::float32_t, glmemsize_t>::create(numElements);
224 return jau::DataBuffer<jau::float64_t, glmemsize_t>::create(numElements);
226 default:
return nullptr;
255 if (!parent || length == 0) {
260 case GL_UNSIGNED_BYTE:
261 case GL_UNSIGNED_BYTE_3_3_2:
262 case GL_UNSIGNED_BYTE_2_3_3_REV:
263 return parent->slice(pos, length);
266 case GL_UNSIGNED_SHORT:
267 case GL_UNSIGNED_SHORT_5_6_5:
268 case GL_UNSIGNED_SHORT_5_6_5_REV:
269 case GL_UNSIGNED_SHORT_4_4_4_4:
270 case GL_UNSIGNED_SHORT_4_4_4_4_REV:
271 case GL_UNSIGNED_SHORT_5_5_5_1:
272 case GL_UNSIGNED_SHORT_1_5_5_5_REV:
273 case GL_UNSIGNED_SHORT_8_8_APPLE:
274 case GL_UNSIGNED_SHORT_8_8_REV_APPLE:
277 return parent->slice(pos, length);
281 case GL_UNSIGNED_INT:
282 case GL_UNSIGNED_INT_8_8_8_8:
283 case GL_UNSIGNED_INT_8_8_8_8_REV:
284 case GL_UNSIGNED_INT_10_10_10_2:
285 case GL_UNSIGNED_INT_2_10_10_10_REV:
286 case GL_UNSIGNED_INT_24_8:
287 case GL_UNSIGNED_INT_10F_11F_11F_REV:
289 case GL_UNSIGNED_INT_5_9_9_9_REV:
290 case GL_SIGNED_HILO16_NV:
291 return parent->slice(pos, length);
293 case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
294 return parent->slice(pos, length);
298 return parent->slice(pos, length);
301 return parent->slice(pos, length);
303 default:
return nullptr;
312 glGetIntegerv(pname, tmp);
334 GLsizei
bytesPerPixel, GLsizei width, GLsizei height, GLsizei depth,
340 GLsizei alignment = 1;
342 GLsizei skipImages = 0;
346 if(
gl.glProfile().isGL2ES3() ) {
350 if (depth > 1 &&
gl.glProfile().isGL2GL3() &&
gl.version() >=
Version1_2) {
357 if(
gl.glProfile().isGL2ES3() ) {
362 (
gl.glProfile().isGL3ES3() ||
373 width2 = std::max<glmemsize_t>(0, width);
374 height = std::max<GLsizei>(1, height);
375 depth = std::max<GLsizei>(1, depth );
376 skipRows = std::max<glmemsize_t>(0, skipRows);
377 skipPixels = std::max<glmemsize_t>(0, skipPixels);
378 alignment = std::max<GLsizei>(1, alignment);
379 skipImages = std::max<GLsizei>(0, skipImages);
381 imageHeight = ( imageHeight > 0 ) ? imageHeight : height;
382 rowLength = ( rowLength > 0 ) ? rowLength : width2;
394 glmemsize_t remainder = rowLengthInBytes & ( alignment - 1L );
396 rowLengthInBytes += alignment - remainder;
398 remainder = skipBytes & ( alignment - 1L );
400 skipBytes += alignment - remainder;
405 throw RenderException(
"Invalid alignment "+std::to_string(alignment)+
", must be 2**n (1,2,4,8). Pls notify the maintainer in case this is our bug.",
E_FILE_LINE);
420 ( skipImages + depth - 1 ) * imageHeight * rowLengthInBytes +
421 ( skipRows + height - 1 ) * rowLengthInBytes +
491 GLenum format, GLenum type, GLsizei width, GLsizei height, GLsizei depth,
494 if (width < 0)
return 0;
495 if (height < 0)
return 0;
496 if (depth < 0)
return 0;
499 return byteSize(
gl, bytesPerPixel_, width, height, depth, pack);
559 GLsizei compSize = 0;
565 if (GL_COLOR_INDEX == format || GL_STENCIL_INDEX == format) {
572 case GL_UNSIGNED_BYTE:
576 case GL_UNSIGNED_SHORT:
583 case GL_UNSIGNED_INT:
591 case GL_UNSIGNED_BYTE_3_3_2:
592 case GL_UNSIGNED_BYTE_2_3_3_REV:
596 case GL_UNSIGNED_SHORT_5_6_5:
597 case GL_UNSIGNED_SHORT_5_6_5_REV:
598 case GL_UNSIGNED_SHORT_4_4_4_4:
599 case GL_UNSIGNED_SHORT_4_4_4_4_REV:
600 case GL_UNSIGNED_SHORT_5_5_5_1:
601 case GL_UNSIGNED_SHORT_1_5_5_5_REV:
602 case GL_UNSIGNED_SHORT_8_8_APPLE:
603 case GL_UNSIGNED_SHORT_8_8_REV_APPLE:
608 case GL_SIGNED_HILO16_NV:
612 case GL_UNSIGNED_INT_8_8_8_8:
613 case GL_UNSIGNED_INT_8_8_8_8_REV:
614 case GL_UNSIGNED_INT_10_10_10_2:
615 case GL_UNSIGNED_INT_2_10_10_10_REV:
616 case GL_UNSIGNED_INT_24_8:
617 case GL_UNSIGNED_INT_10F_11F_11F_REV:
618 case GL_UNSIGNED_INT_5_9_9_9_REV:
622 case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
630 return compCount * compSize;
669 case GL_STENCIL_INDEX:
670 case GL_DEPTH_COMPONENT:
671 case GL_DEPTH_STENCIL:
675 case GL_GREEN_INTEGER:
677 case GL_BLUE_INTEGER:
682 case GL_LUMINANCE_ALPHA:
686 case GL_SIGNED_HILO_NV:
695 case GL_YCBCR_422_APPLE:
699 case GL_RGBA_INTEGER:
701 case GL_BGRA_INTEGER:
static glmemsize_t byteSize(const GL &gl, GLsizei bytesPerPixel, GLsizei width, GLsizei height, GLsizei depth, bool pack)
Returns the number of bytes required to read/write a memory buffer via OpenGL using the current GL pi...
static size_t byteSize(const GL &gl, GLenum format, GLenum type, GLsizei width, GLsizei height, GLsizei depth, bool pack)
Returns the number of bytes required to read/write a memory buffer via OpenGL using the current GL pi...