JOGL v2.6.0-rc-20250706
JOGL, High-Performance Graphics Binding for Java™ (public API).
GLArrayDataWrapper.java
Go to the documentation of this file.
1/**
2 * Copyright 2010-2023 JogAmp Community. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without modification, are
5 * permitted provided that the following conditions are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright notice, this list of
8 * conditions and the following disclaimer.
9 *
10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
11 * of conditions and the following disclaimer in the documentation and/or other materials
12 * provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
15 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 *
24 * The views and conclusions contained in the software and documentation are those of the
25 * authors and should not be interpreted as representing official policies, either expressed
26 * or implied, of JogAmp Community.
27 */
28
29package com.jogamp.opengl.util;
30
31import java.nio.Buffer;
32import java.nio.ByteBuffer;
33import java.nio.FloatBuffer;
34import java.nio.IntBuffer;
35import java.nio.ShortBuffer;
36
37import com.jogamp.opengl.GL;
38import com.jogamp.opengl.GL2ES2;
39import com.jogamp.opengl.GLArrayData;
40import com.jogamp.opengl.GLException;
41import com.jogamp.opengl.GLProfile;
42import com.jogamp.opengl.fixedfunc.GLPointerFuncUtil;
43
44import com.jogamp.common.nio.Buffers;
45
46import jogamp.opengl.Debug;
47
48public class GLArrayDataWrapper implements GLArrayData {
49 public static final boolean DEBUG = Debug.debug("GLArrayData");
50
51 /**
52 * Create a VBO, using a predefined fixed function array index, wrapping the given data.
53 * <p>
54 * This buffer is always {@link #sealed()}.
55 * </p>
56 * @param index The GL array index
57 * @param comps The array component number
58 * @param dataType The array index GL data type
59 * @param normalized Whether the data shall be normalized
60 * @param stride
61 * @param buffer the user define data
62 * @param vboName
63 * @param vboOffset
64 * @param vboUsage {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW}
65 * @param vboTarget {@link GL#GL_ARRAY_BUFFER} or {@link GL#GL_ELEMENT_ARRAY_BUFFER}
66 * @return the new create instance
67 *
68 * @throws GLException
69 */
70 public static GLArrayDataWrapper createFixed(final int index, final int comps, final int dataType, final boolean normalized, final int stride,
71 final Buffer buffer, final int vboName, final long vboOffset, final int vboUsage, final int vboTarget)
72 throws GLException
73 {
74 return new GLArrayDataWrapper(null, index, comps, dataType, normalized, stride, buffer, 0 /* mappedElementCount */,
76 }
77
78 /**
79 * Create a VBO, using a predefined fixed function array index, wrapping the mapped data characteristics.
80 * <p>
81 * This buffer is always {@link #sealed()}.
82 * </p>
83 * @param index The GL array index
84 * @param comps The array component number
85 * @param dataType The array index GL data type
86 * @param normalized Whether the data shall be normalized
87 * @param stride
88 * @param mappedElementCount
89 * @param vboName
90 * @param vboOffset
91 * @param vboUsage {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW}
92 * @param vboTarget {@link GL#GL_ARRAY_BUFFER} or {@link GL#GL_ELEMENT_ARRAY_BUFFER}
93 * @return the new create instance
94 *
95 * @throws GLException
96 */
97 public static GLArrayDataWrapper createFixed(final int index, final int comps, final int dataType, final boolean normalized, final int stride,
98 final int mappedElementCount, final int vboName, final long vboOffset, final int vboUsage, final int vboTarget)
99 throws GLException
100 {
101 return new GLArrayDataWrapper(null, index, comps, dataType, normalized, stride, null, mappedElementCount,
103 }
104
105 /**
106 * Create a VBO, using a custom GLSL array attribute name, wrapping the given data.
107 * <p>
108 * This buffer is always {@link #sealed()}.
109 * </p>
110 * @param name The custom name for the GL attribute, maybe null if gpuBufferTarget is {@link GL#GL_ELEMENT_ARRAY_BUFFER}
111 * @param comps The array component number
112 * @param dataType The array index GL data type
113 * @param normalized Whether the data shall be normalized
114 * @param stride
115 * @param buffer the user define data
116 * @param vboName
117 * @param vboOffset
118 * @param vboUsage {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW}
119 * @param vboTarget {@link GL#GL_ARRAY_BUFFER} or {@link GL#GL_ELEMENT_ARRAY_BUFFER}
120 * @return the new create instance
121 * @throws GLException
122 */
123 public static GLArrayDataWrapper createGLSL(final String name, final int comps, final int dataType, final boolean normalized, final int stride,
124 final Buffer buffer, final int vboName, final long vboOffset, final int vboUsage, final int vboTarget)
125 throws GLException
126 {
127 return new GLArrayDataWrapper(name, -1, comps, dataType, normalized, stride, buffer, 0 /* mappedElementCount */,
129 }
130
131 /**
132 * Create a VBO, using a custom GLSL array attribute name, wrapping the mapped data characteristics.
133 * <p>
134 * This buffer is always {@link #sealed()}.
135 * </p>
136 * @param name The custom name for the GL attribute, maybe null if gpuBufferTarget is {@link GL#GL_ELEMENT_ARRAY_BUFFER}
137 * @param comps The array component number
138 * @param dataType The array index GL data type
139 * @param normalized Whether the data shall be normalized
140 * @param stride
141 * @param mappedElementCount
142 * @param vboName
143 * @param vboOffset
144 * @param vboUsage {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW}
145 * @param vboTarget {@link GL#GL_ARRAY_BUFFER} or {@link GL#GL_ELEMENT_ARRAY_BUFFER}
146 * @return the new create instance
147 * @throws GLException
148 */
149 public static GLArrayDataWrapper createGLSL(final String name, final int comps, final int dataType, final boolean normalized, final int stride,
150 final int mappedElementCount, final int vboName, final long vboOffset, final int vboUsage, final int vboTarget)
151 throws GLException
152 {
153 return new GLArrayDataWrapper(name, -1, comps, dataType, normalized, stride, null, mappedElementCount,
155 }
156
157 /**
158 * Validates this instance's parameter. Called automatically by {@link GLArrayDataClient} and {@link GLArrayDataServer}.
159 * {@link GLArrayDataWrapper} does not validate it's instance by itself.
160 *
161 * @param glp the GLProfile to use
162 * @param throwException whether to throw an exception if this instance has invalid parameter or not
163 * @return true if this instance has invalid parameter, otherwise false
164 */
165 public final boolean validate(final GLProfile glp, final boolean throwException) {
166 if(!alive) {
167 if(throwException) {
168 throw new GLException("Instance !alive "+this);
169 }
170 return false;
171 }
172 if(this.isVertexAttribute() && !glp.hasGLSL()) {
173 if(throwException) {
174 throw new GLException("GLSL not supported on "+glp+", "+this);
175 }
176 return false;
177 }
178 // Skip GLProfile based index, comps, type validation, might not be future proof.
179 // glp.isValidArrayDataType(getIndex(), getCompsPerElem(), getCompType(), isVertexAttribute(), throwException);
180 return true;
181 }
182
183 @Override
184 public void associate(final Object obj, final boolean enable) {
185 // nop
186 }
187
188 //
189 // Data read access
190 //
191
192 @Override
193 public final boolean isVertexAttribute() { return isVertexAttr; }
194
195 @Override
196 public final int getIndex() { return index; }
197
198 @Override
199 public final int getLocation() { return location; }
200
201 @Override
202 public final int setLocation(final int v) { location = v; return location; }
203
204 @Override
205 public final int setLocation(final GL2ES2 gl, final int program) {
206 location = gl.glGetAttribLocation(program, name);
207 return location;
208 }
209
210 @Override
211 public final int setLocation(final GL2ES2 gl, final int program, final int location) {
212 this.location = location;
213 gl.glBindAttribLocation(program, location, name);
214 return location;
215 }
216
217 @Override
218 public final String getName() { return name; }
219
220 @Override
221 public final long getVBOOffset() { return vboEnabled?vboOffset:0; }
222
223 @Override
224 public final int getVBOName() { return vboEnabled?vboName:0; }
225
226 @Override
227 public final boolean isVBO() { return vboEnabled; }
228
229 @Override
230 public final int getVBOUsage() { return vboEnabled?vboUsage:0; }
231
232 @Override
233 public final int getVBOTarget() { return vboEnabled?vboTarget:0; }
234
235 @Override
236 public Buffer getBuffer() { return buffer; }
237
238 @Override
239 public final int getCompsPerElem() { return compsPerElement; }
240
241 @Override
242 public final int getCompType() { return compType; }
243
244 @Override
245 public final int getBytesPerComp() { return bytesPerComp; }
246
247 @Override
248 public final boolean sealed() { return sealed; }
249
250 @Override
251 public final int getElemCount() {
252 if( 0 != mappedElemCount ) {
253 return mappedElemCount;
254 } else if( null != buffer ) {
255 if( sealed ) {
256 return ( buffer.limit() * bytesPerComp ) / strideB ;
257 } else {
258 return ( buffer.position() * bytesPerComp ) / strideB ;
259 }
260 } else {
261 return 0;
262 }
263 }
264
265 @Override
266 public final int elemPosition() {
267 if( 0 != mappedElemCount ) {
268 return mappedElemCount;
269 } else if( null != buffer ) {
270 return ( buffer.position() * bytesPerComp ) / strideB ;
271 } else {
272 return 0;
273 }
274 }
275
276 @Override
277 public int remainingElems() {
278 if( null != buffer ) {
279 return ( buffer.remaining() * bytesPerComp ) / strideB ;
280 } else {
281 return 0;
282 }
283 }
284
285 @Override
286 public int getElemCapacity() {
287 if( null != buffer ) {
288 return ( buffer.capacity() * bytesPerComp ) / strideB ;
289 } else {
290 return 0;
291 }
292 }
293
294 @Override
295 public final int getByteCount() {
296 if( 0 != mappedElemCount ) {
298 } else if( null != buffer ) {
299 if( sealed ) {
300 return buffer.limit() * bytesPerComp ;
301 } else {
302 return buffer.position() * bytesPerComp ;
303 }
304 } else {
305 return 0;
306 }
307 }
308
309 @Override
310 public final int bytePosition() {
311 if( 0 != mappedElemCount ) {
313 } else if( null != buffer ) {
314 return buffer.position() * bytesPerComp;
315 } else {
316 return 0;
317 }
318 }
319
320 @Override
321 public int remainingBytes() {
322 if( null != buffer ) {
323 return buffer.remaining() * bytesPerComp;
324 } else {
325 return 0;
326 }
327 }
328
329 @Override
330 public int getByteCapacity() {
331 if( null != buffer ) {
332 return buffer.capacity() * bytesPerComp;
333 } else {
334 return 0;
335 }
336 }
337
338 @Override
339 public String fillStatsToString() {
340 final int cnt_bytes = getByteCount();
341 final int cap_bytes = getByteCapacity();
342 final float filled = (float)cnt_bytes/(float)cap_bytes;
343 return String.format("elements %,d cnt / %,d cap, bytes %,d cnt / %,d cap, filled %.1f%%, left %.1f%%",
344 getElemCount(), getElemCapacity(), cnt_bytes, cap_bytes, filled*100f, (1f-filled)*100f);
345 }
346
347 @Override
348 public String elemStatsToString() {
349 final int elem_limit = null != buffer ? ( buffer.limit() * bytesPerComp ) / strideB : 0;
350 return String.format("sealed %b, elements %,d cnt, [%,d pos .. %,d rem .. %,d lim .. %,d cap]",
352 }
353
354 @Override
355 public final boolean getNormalized() { return normalized; }
356
357 @Override
358 public final int getStride() { return strideB; }
359
360 public final Class<?> getBufferClass() { return compClazz; }
361
362 @Override
363 public void destroy(final GL gl) {
364 buffer = null;
365 vboName=0;
366 vboEnabled=false;
367 vboOffset=0;
368 alive = false;
369 }
370
371 @Override
372 public String toString() {
373 return "GLArrayDataWrapper["+name+
374 ", index "+index+
375 ", location "+location+
376 ", isVertexAttribute "+isVertexAttr+
377 ", dataType 0x"+Integer.toHexString(compType)+
378 ", bufferClazz "+compClazz+
379 ", compsPerElem "+compsPerElement+
380 ", stride "+strideB+"b "+strideL+"c"+
381 ", mappedElemCount "+mappedElemCount+
382 ", "+elemStatsToString()+
383 ", buffer "+buffer+
384 ", vboEnabled "+vboEnabled+
385 ", vboName "+vboName+
386 ", vboUsage 0x"+Integer.toHexString(vboUsage)+
387 ", vboTarget 0x"+Integer.toHexString(vboTarget)+
388 ", vboOffset "+vboOffset+
389 ", alive "+alive+
390 "]";
391 }
392
393 public static final Class<?> getBufferClass(final int dataType) {
394 switch(dataType) {
395 case GL.GL_BYTE:
396 case GL.GL_UNSIGNED_BYTE:
397 return ByteBuffer.class;
398 case GL.GL_SHORT:
400 return ShortBuffer.class;
401 case GL.GL_UNSIGNED_INT:
402 case GL.GL_FIXED:
403 case GL2ES2.GL_INT:
404 return IntBuffer.class;
405 case GL.GL_FLOAT:
406 return FloatBuffer.class;
407 default:
408 throw new GLException("Given OpenGL data type not supported: "+dataType);
409 }
410 }
411
412 @Override
413 public void setName(final String newName) {
414 location = -1;
415 name = newName;
416 }
417
418 /**
419 * Enable or disable use of VBO.
420 * Only possible if a VBO buffer name is defined.
421 * @see #setVBOName(int)
422 */
423 public void setVBOEnabled(final boolean vboEnabled) {
424 this.vboEnabled=vboEnabled;
425 }
426
427 /**
428 * Set the VBO buffer name, if valid (!= 0) enable use of VBO,
429 * otherwise (==0) disable VBO usage.
430 *
431 * @see #setVBOEnabled(boolean)
432 */
433 public void setVBOName(final int vboName) {
434 this.vboName=vboName;
436 }
437
438 /**
439 * @param vboUsage {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW}
440 */
441 public void setVBOUsage(final int vboUsage) {
442 this.vboUsage = vboUsage;
443 }
444
445 /**
446 * @param vboTarget either {@link GL#GL_ARRAY_BUFFER} or {@link GL#GL_ELEMENT_ARRAY_BUFFER}
447 */
448 public void setVBOTarget(final int vboTarget) {
449 this.vboTarget = vboTarget;
450 }
451
452 protected GLArrayDataWrapper(final String name, final int index, final int componentsPerElement, final int componentType,
453 final boolean normalized, final int stride, final Buffer data, final int mappedElementCount,
454 final boolean isVertexAttribute, final int vboName, final long vboOffset, final int vboUsage, final int vboTarget)
455 throws GLException
456 {
457 if( 0<mappedElementCount && null != data ) {
458 throw new IllegalArgumentException("mappedElementCount:="+mappedElementCount+" specified, but passing non null buffer");
459 }
460 // We can't have any dependence on the FixedFuncUtil class here for build bootstrapping reasons
461
463 // OK ..
464 } else if( ( 0 == vboUsage && 0 == vboTarget ) || GL.GL_ARRAY_BUFFER == vboTarget ) {
465 // Set/Check name .. - Required for GLSL case. Validation and debug-name for FFP.
466 this.name = ( null == name ) ? GLPointerFuncUtil.getPredefinedArrayIndexName(index) : name ;
467 if(null == this.name ) {
468 throw new GLException("Not a valid array buffer index: "+index);
469 }
470 } else if( 0 < vboTarget ) {
471 throw new GLException("Invalid GPUBuffer target: 0x"+Integer.toHexString(vboTarget));
472 }
473
474 // immutable types
475 this.compType = componentType;
476 compClazz = getBufferClass(componentType);
477 bytesPerComp = GLBuffers.sizeOfGLType(componentType);
478 if(0 > bytesPerComp) {
479 throw new GLException("Given componentType not supported: "+componentType+":\n\t"+this);
480 }
481 if(0 >= componentsPerElement) {
482 throw new GLException("Invalid number of components: " + componentsPerElement);
483 }
484 this.compsPerElement = componentsPerElement;
485
486 if(0<stride && stride<componentsPerElement*bytesPerComp) {
487 throw new GLException("stride ("+stride+") lower than component bytes, "+componentsPerElement+" * "+bytesPerComp);
488 }
489 if(0<stride && stride%bytesPerComp!=0) {
490 throw new GLException("stride ("+stride+") not a multiple of bpc "+bytesPerComp);
491 }
492 this.strideB=(0==stride)?componentsPerElement*bytesPerComp:stride;
494
495 if( GLBuffers.isGLTypeFixedPoint(componentType) ) {
496 this.normalized = normalized;
497 } else {
498 this.normalized = false;
499 }
500 this.mappedElemCount = mappedElementCount;
501 this.isVertexAttr = isVertexAttribute;
502
503 // mutable types
504 this.index = index;
505 this.location = -1;
506 this.buffer = data;
507 this.vboName= vboName;
508 this.vboOffset=vboOffset;
509 this.vboEnabled= 0 != vboName ;
510
511 switch(vboUsage) {
512 case 0: // nop
513 case GL.GL_STATIC_DRAW:
514 case GL.GL_DYNAMIC_DRAW:
516 break;
517 default:
518 throw new GLException("invalid gpuBufferUsage: "+vboUsage+":\n\t"+this);
519 }
520 switch(vboTarget) {
521 case 0: // nop
522 case GL.GL_ARRAY_BUFFER:
524 break;
525 default:
526 throw new GLException("invalid gpuBufferTarget: "+vboTarget+":\n\t"+this);
527 }
528 this.vboUsage=vboUsage;
529 this.vboTarget=vboTarget;
530 this.alive=true;
531 this.sealed = true;
532 }
533
534 /**
535 * Copy Constructor
536 * <p>
537 * Buffer is {@link Buffers#slice(Buffer) sliced}, i.e. sharing content but using own state.
538 * </p>
539 * <p>
540 * All other values are simply copied.
541 * </p>
542 */
544 // immutable types
545 this.compType = src.compType;
546 this.compClazz = src.compClazz;
547 this.bytesPerComp = src.bytesPerComp;
548 this.compsPerElement = src.compsPerElement;
549 this.strideB = src.strideB;
550 this.strideL = src.strideL;
551 this.normalized = src.normalized;
552 this.mappedElemCount = src.mappedElemCount;
553 this.isVertexAttr = src.isVertexAttr;
554
555 // mutable types
556 this.alive = src.alive;
557 this.index = src.index;
558 this.location = src.location;
559 this.name = src.name;
560 if( null != src.buffer ) {
561 if( src.buffer.position() == 0 ) {
562 this.buffer = Buffers.slice(src.buffer);
563 } else {
564 this.buffer = Buffers.slice(src.buffer, 0, src.buffer.limit());
565 }
566 } else {
567 this.buffer = null;
568 }
569 this.vboName = src.vboName;
570 this.vboOffset = src.vboOffset;
571 this.vboEnabled = src.vboEnabled;
572 this.vboUsage = src.vboUsage;
573 this.vboTarget = src.vboTarget;
574 this.sealed = src.sealed;
575 }
576
577 protected final int compType;
578 protected final Class<?> compClazz;
579 protected final int bytesPerComp;
580 protected final int compsPerElement;
581 /** stride in bytes; strideB >= compsPerElement * bytesPerComp */
582 protected final int strideB;
583 /** stride in logical components */
584 protected final int strideL;
585 protected final boolean normalized;
586 protected final int mappedElemCount;
587 protected final boolean isVertexAttr;
588
589 // mutable types
590 protected boolean alive;
591 protected int index;
592 protected int location;
593 protected String name;
594 protected Buffer buffer;
595 protected int vboName;
596 protected long vboOffset;
597 protected boolean vboEnabled;
598 protected int vboUsage;
599 protected int vboTarget;
600 protected boolean sealed;
601}
602
A generic exception for OpenGL errors used throughout the binding as a substitute for RuntimeExceptio...
Specifies the the OpenGL profile.
Definition: GLProfile.java:77
final boolean hasGLSL()
Indicates whether this profile supports GLSL, i.e.
static String getPredefinedArrayIndexName(final int glArrayIndex)
final int getCompsPerElem()
The number of components per element.
final long getVBOOffset()
The VBO buffer offset or 0 if not a VBO.
final boolean isVBO()
Determines whether the data is server side (VBO) and enabled, or a client side array (false).
GLArrayDataWrapper(final String name, final int index, final int componentsPerElement, final int componentType, final boolean normalized, final int stride, final Buffer data, final int mappedElementCount, final boolean isVertexAttribute, final int vboName, final long vboOffset, final int vboUsage, final int vboTarget)
static GLArrayDataWrapper createFixed(final int index, final int comps, final int dataType, final boolean normalized, final int stride, final Buffer buffer, final int vboName, final long vboOffset, final int vboUsage, final int vboTarget)
Create a VBO, using a predefined fixed function array index, wrapping the given data.
final int bytePosition()
Returns the bytes position.
final int getByteCount()
Returns the byte position (written elements) if not sealed() or the byte limit (available to read) af...
final int getElemCount()
Returns the element position (written elements) if not sealed() or the element limit (available to re...
static GLArrayDataWrapper createGLSL(final String name, final int comps, final int dataType, final boolean normalized, final int stride, final Buffer buffer, final int vboName, final long vboOffset, final int vboUsage, final int vboTarget)
Create a VBO, using a custom GLSL array attribute name, wrapping the given data.
final int elemPosition()
Returns the element position.
void setVBOName(final int vboName)
Set the VBO buffer name, if valid (!= 0) enable use of VBO, otherwise (==0) disable VBO usage.
String elemStatsToString()
Returns a string with detailed buffer element stats, i.e.
final int setLocation(final GL2ES2 gl, final int program)
Retrieves the location of the shader attribute from the linked shader program.
final boolean isVertexAttribute()
Returns true if this data set is intended for a GLSL vertex shader attribute, otherwise false,...
void associate(final Object obj, final boolean enable)
Implementation and type dependent object association.
void setName(final String newName)
Set a new name for this array.
final int strideB
stride in bytes; strideB >= compsPerElement * bytesPerComp
String fillStatsToString()
Returns a string with detailed buffer fill stats.
final int setLocation(final int v)
Sets the given location of the shader attribute.
void setVBOEnabled(final boolean vboEnabled)
Enable or disable use of VBO.
final int strideL
stride in logical components
final boolean getNormalized()
True, if GL shall normalize fixed point data while converting them into float.
final int getCompType()
The component's GL data type, ie.
final String getName()
The name of the reflecting shader array attribute.
final int getVBOName()
The VBO name or 0 if not a VBO.
final int getLocation()
Returns the shader attribute location for this name, -1 if not yet determined.
final int setLocation(final GL2ES2 gl, final int program, final int location)
Binds the location of the shader attribute to the given location for the unlinked shader program.
int remainingBytes()
The current number of remaining bytes.
final int getIndex()
The index of the predefined array index, see list below, or -1 in case of a shader attribute array.
Buffer getBuffer()
The Buffer holding the data, may be null if a GPU buffer without client bound data.
final int getBytesPerComp()
The component's size in bytes.
int getByteCapacity()
Return the capacity in bytes.
static GLArrayDataWrapper createFixed(final int index, final int comps, final int dataType, final boolean normalized, final int stride, final int mappedElementCount, final int vboName, final long vboOffset, final int vboUsage, final int vboTarget)
Create a VBO, using a predefined fixed function array index, wrapping the mapped data characteristics...
final int getVBOUsage()
The VBO usage or 0 if not a VBO.
final boolean sealed()
Returns true if data has been sealed (flipped to read), otherwise false (writing mode).
static final Class<?> getBufferClass(final int dataType)
final int getVBOTarget()
The VBO target or 0 if not a VBO.
static GLArrayDataWrapper createGLSL(final String name, final int comps, final int dataType, final boolean normalized, final int stride, final int mappedElementCount, final int vboName, final long vboOffset, final int vboUsage, final int vboTarget)
Create a VBO, using a custom GLSL array attribute name, wrapping the mapped data characteristics.
final boolean validate(final GLProfile glp, final boolean throwException)
Validates this instance's parameter.
GLArrayDataWrapper(final GLArrayDataWrapper src)
Copy Constructor.
int remainingElems()
The current number of remaining elements.
int getElemCapacity()
Return the element capacity.
Utility routines for dealing with direct buffers.
Definition: GLBuffers.java:60
static final boolean isGLTypeFixedPoint(final int glType)
Definition: GLBuffers.java:90
static final int sizeOfGLType(final int glType)
Definition: GLBuffers.java:128
void glBindAttribLocation(int program, int index, String name)
Entry point to C language function: void {@native glBindAttribLocation}(GLuint program,...
static final int GL_STREAM_DRAW
GL_VERSION_1_5, GL_ES_VERSION_2_0, GL_ARB_vertex_buffer_object Alias for: GL_STREAM_DRAW_ARB Define ...
Definition: GL2ES2.java:153
int glGetAttribLocation(int program, String name)
Entry point to C language function: GLint {@native glGetAttribLocation}(GLuint program,...
static final int GL_INT
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0 Define "GL_INT" with expression '0x1404',...
Definition: GL2ES2.java:200
The total number of bytes hold by the referenced buffer is: getComponentSize()* getComponentNumber() ...
static final int GL_STATIC_DRAW
GL_VERSION_1_5, GL_ES_VERSION_2_0, GL_VERSION_ES_1_0, GL_ARB_vertex_buffer_object Alias for: GL_STATI...
Definition: GL.java:673
static final int GL_FIXED
GL_ARB_ES2_compatibility, GL_ES_VERSION_2_0, GL_VERSION_4_1, GL_VERSION_ES_1_0, GL_OES_fixed_point Al...
Definition: GL.java:148
static final int GL_SHORT
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_SHORT" with expressio...
Definition: GL.java:125
static final int GL_UNSIGNED_INT
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_OES_element_index_uint Define "GL_UNSIGNED_INT"...
Definition: GL.java:294
static final int GL_FLOAT
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_FLOAT" with expressio...
Definition: GL.java:786
static final int GL_UNSIGNED_SHORT
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_UNSIGNED_SHORT" with ...
Definition: GL.java:346
static final int GL_DYNAMIC_DRAW
GL_VERSION_1_5, GL_ES_VERSION_2_0, GL_VERSION_ES_1_0, GL_ARB_vertex_buffer_object Alias for: GL_DYNAM...
Definition: GL.java:53
static final int GL_UNSIGNED_BYTE
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_UNSIGNED_BYTE" with e...
Definition: GL.java:284
static final int GL_ELEMENT_ARRAY_BUFFER
GL_VERSION_1_5, GL_ES_VERSION_2_0, GL_VERSION_ES_1_0, GL_ARB_vertex_buffer_object Alias for: GL_ELEME...
Definition: GL.java:318
static final int GL_BYTE
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_BYTE" with expression...
Definition: GL.java:159
static final int GL_ARRAY_BUFFER
GL_VERSION_1_5, GL_ES_VERSION_2_0, GL_VERSION_ES_1_0, GL_ARB_vertex_buffer_object Alias for: GL_ARRAY...
Definition: GL.java:633