Revision 7958d843
Added by Leszek Koltunski almost 3 years ago
src/main/java/org/distorted/library/uniformblock/UniformBlockCenter.java | ||
---|---|---|
22 | 22 |
import android.opengl.GLES30; |
23 | 23 |
|
24 | 24 |
import org.distorted.library.main.InternalBuffer; |
25 |
|
|
26 |
import static org.distorted.library.mesh.MeshBase.MAX_EFFECT_COMPONENTS; |
|
25 |
import org.distorted.library.mesh.MeshBase; |
|
27 | 26 |
|
28 | 27 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
29 | 28 |
/** |
... | ... | |
33 | 32 |
*/ |
34 | 33 |
public class UniformBlockCenter |
35 | 34 |
{ |
36 |
private static final int BLOCK_SIZE = 16*MAX_EFFECT_COMPONENTS; |
|
37 |
|
|
38 | 35 |
private final InternalBuffer mUBO; |
39 | 36 |
private final float[] mArray; |
37 |
private final int mMax; |
|
40 | 38 |
|
41 | 39 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
42 | 40 |
|
43 | 41 |
public UniformBlockCenter() |
44 | 42 |
{ |
45 |
mArray= new float[BLOCK_SIZE/4]; |
|
46 |
mUBO = new InternalBuffer(GLES30.GL_UNIFORM_BUFFER, GLES30.GL_STATIC_READ); |
|
43 |
mMax = MeshBase.getMaxEffComponents(); |
|
44 |
mArray= new float[4*mMax]; |
|
45 |
mUBO = new InternalBuffer(GLES30.GL_UNIFORM_BUFFER, GLES30.GL_STATIC_READ); |
|
47 | 46 |
} |
48 | 47 |
|
49 | 48 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
50 | 49 |
|
51 | 50 |
public UniformBlockCenter(UniformBlockCenter original) |
52 | 51 |
{ |
52 |
mMax = original.mMax; |
|
53 | 53 |
int size = original.mArray.length; |
54 | 54 |
mArray= new float[size]; |
55 | 55 |
System.arraycopy(original.mArray, 0, mArray, 0, size); |
... | ... | |
71 | 71 |
|
72 | 72 |
public int getIndex() |
73 | 73 |
{ |
74 |
return mUBO.createImmediatelyFloat( BLOCK_SIZE, mArray);
|
|
74 |
return mUBO.createImmediatelyFloat( 16*mMax, mArray);
|
|
75 | 75 |
} |
76 | 76 |
|
77 | 77 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
MeshBase's 'MAX_NUM_COMPONENTS' is not a constant - rename!