JOGL v2.6.0-rc-20250712
JOGL, High-Performance Graphics Binding for Java™ (public API).
GLArrayDataEditable.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 com.jogamp.opengl.*;
32
33import java.nio.*;
34
35/**
36 *
37 * The total number of bytes hold by the referenced buffer is:
38 * getComponentSize()* getComponentNumber() * getElementNumber()
39 *
40 */
41public interface GLArrayDataEditable extends GLArrayData {
42
43 public boolean enabled();
44
45 /**
46 * Is the buffer written to the VBO ?
47 */
48 public boolean isVBOWritten();
49
50 /**
51 * Marks the buffer written to the VBO
52 */
53 public void setVBOWritten(boolean written);
54
55 //
56 // Data and GL state modification ..
57 //
58
59 @Override
60 public void destroy(GL gl);
61
62 /**
63 * Clears this buffer and resets states accordingly.
64 * <p>
65 * Implementation calls {@link #seal(GL, boolean) seal(gl, false)} and {@link #clear()},
66 * i.e. turns-off the GL buffer and then clearing it.
67 * </p>
68 * <p>
69 * The position is set to zero, the limit is set to the capacity, and the mark is discarded.
70 * </p>
71 * <p>
72 * Invoke this method before using a sequence of get or put operations to fill this buffer.
73 * </p>
74 * <p>
75 * This method does not actually erase the data in the buffer and will most often be used when erasing the underlying memory is suitable.
76 * </p>
77 * @see #seal(GL, boolean)
78 * @see #clear()
79 */
80 public void clear(GL gl);
81
82 /**
83 * Convenience method calling {@link #seal(boolean)} and {@link #enableBuffer(GL, boolean)}.
84 *
85 * @see #seal(boolean)
86 * @see #enableBuffer(GL, boolean)
87 *
88 */
89 public void seal(GL gl, boolean seal);
90
91 /**
92 * Enables the buffer if <code>enable</code> is <code>true</code>,
93 * and transfers the data if required.
94 * In case {@link #isVBO() VBO is used}, it is bound accordingly for the data transfer and association,
95 * i.e. it issued {@link #bindBuffer(GL, boolean)}.
96 * The VBO buffer is unbound when the method returns.
97 * <p>
98 * Disables the buffer if <code>enable</code> is <code>false</code>.
99 * </p>
100 *
101 * <p>The action will only be executed,
102 * if the internal enable state differs,
103 * or 'setEnableAlways' was called with 'true'.</b>
104 *
105 * <p>It is up to the user to enable/disable the array properly,
106 * ie in case of multiple data sets for the same vertex attribute (VA).
107 * Meaning in such case usage of one set while expecting another one
108 * to be used for the same VA implies decorating each usage with enable/disable.</p>
109 *
110 * @see #setEnableAlways(boolean)
111 */
112 public void enableBuffer(GL gl, boolean enable);
113
114 /**
115 * if <code>bind</code> is true and the data uses {@link #isVBO() VBO},
116 * the latter will be bound and data written to the GPU if required.
117 * <p>
118 * If <code>bind</code> is false and the data uses {@link #isVBO() VBO},
119 * the latter will be unbound.
120 * </p>
121 * <p>
122 * This method is exposed to allow data VBO arrays, i.e. {@link GL#GL_ELEMENT_ARRAY_BUFFER},
123 * to be bounded and written while keeping the VBO bound. The latter is in contrast to {@link #enableBuffer(GL, boolean)},
124 * which leaves the VBO unbound, since it's not required for vertex attributes or pointers.
125 * </p>
126 *
127 * @param gl current GL object
128 * @param bind true if VBO shall be bound and data written,
129 * otherwise clear VBO binding.
130 * @return true if data uses VBO and action was performed, otherwise false
131 */
132 public boolean bindBuffer(GL gl, boolean bind);
133
134 /**
135 * Affects the behavior of 'enableBuffer'.
136 *
137 * The default is 'false'
138 *
139 * This is useful when you mix up
140 * GLArrayData usage with conventional GL array calls
141 * or in case of a buggy GL VBO implementation.
142 *
143 * @see #enableBuffer(GL, boolean)
144 */
145 public void setEnableAlways(boolean always);
146
147 //
148 // Data modification ..
149 //
150
151 /**
152 * Clears this buffer and resets states accordingly.
153 * <p>
154 * The position is set to zero, the limit is set to the capacity, and the mark is discarded.
155 * </p>
156 * <p>
157 * Invoke this method before using a sequence of get or put operations to fill this buffer.
158 * </p>
159 * <p>
160 * This method does not actually erase the data in the buffer and will most often be used when erasing the underlying memory is suitable.
161 * </p>
162 * @see #clear(GL)
163 */
164 public void clear();
165
166 /**
167 * <p>If <i>seal</i> is true, it
168 * disables write operations to the buffer.
169 * Calls flip, ie limit:=position and position:=0.</p>
170 *
171 * <p>If <i>seal</i> is false, it
172 * enable write operations continuing
173 * at the buffer position, where you left off at seal(true),
174 * ie position:=limit and limit:=capacity.</p>
175 *
176 * @see #seal(boolean)
177 * @see #sealed()
178 */
179 public void seal(boolean seal);
180
181 /**
182 * Rewinds this buffer. The position is set to zero and the mark is discarded.
183 * <p>
184 * Invoke this method before a sequence of put or get operations.
185 * </p>
186 */
187 public void rewind();
188
189 public void padding(int doneInByteSize);
190 public void put(Buffer v);
191
192 public void putb(byte v);
193 public void put3b(byte v1, byte v2, byte v3);
194 public void put4b(byte v1, byte v2, byte v3, byte v4);
195 public void putb(byte[] src, int offset, int length);
196
197 public void puts(short v);
198 public void put3s(short v1, short v2, short v3);
199 public void put4s(short v1, short v2, short v3, short v4);
200 public void puts(short[] src, int offset, int length);
201
202 public void puti(int v);
203 public void put3i(int v1, int v2, int v3);
204 public void put4i(int v1, int v2, int v3, int v4);
205 public void puti(int[] src, int offset, int length);
206
207 public void putx(int v);
208
209 public void putf(float v);
210 public void put3f(float v1, float v2, float v3);
211 public void put4f(float v1, float v2, float v3, float v4);
212 public void putf(float[] src, int offset, int length);
213}
214
The total number of bytes hold by the referenced buffer is: getComponentSize()* getComponentNumber() ...
The total number of bytes hold by the referenced buffer is: getComponentSize()* getComponentNumber() ...
void seal(GL gl, boolean seal)
Convenience method calling seal(boolean) and enableBuffer(GL, boolean).
void puti(int[] src, int offset, int length)
void put4s(short v1, short v2, short v3, short v4)
void enableBuffer(GL gl, boolean enable)
Enables the buffer if enable is true, and transfers the data if required.
void setVBOWritten(boolean written)
Marks the buffer written to the VBO.
boolean bindBuffer(GL gl, boolean bind)
if bind is true and the data uses VBO, the latter will be bound and data written to the GPU if requir...
void puts(short[] src, int offset, int length)
void put3s(short v1, short v2, short v3)
void clear()
Clears this buffer and resets states accordingly.
void put4b(byte v1, byte v2, byte v3, byte v4)
void putb(byte[] src, int offset, int length)
boolean isVBOWritten()
Is the buffer written to the VBO ?
void rewind()
Rewinds this buffer.
void put3b(byte v1, byte v2, byte v3)
void put3f(float v1, float v2, float v3)
void putf(float[] src, int offset, int length)
void clear(GL gl)
Clears this buffer and resets states accordingly.
void setEnableAlways(boolean always)
Affects the behavior of 'enableBuffer'.
void put4i(int v1, int v2, int v3, int v4)
void put4f(float v1, float v2, float v3, float v4)
void put3i(int v1, int v2, int v3)