Ordered GPURenderer
This commit is contained in:
parent
575e9f4871
commit
7e82bde264
@ -26,13 +26,13 @@ public class GPURenderer implements Renderer {
|
|||||||
|
|
||||||
public static GL2ES1 gl;
|
public static GL2ES1 gl;
|
||||||
|
|
||||||
private static final int ELEMENT_VERTICES_COUNT = 6;
|
private static final int ELEMENT_VERTICES_COUNT = 6, vertSize = 3, texSize = 2, colSize = 4;
|
||||||
private static final int ELEMENTS_MAX_COUNT_PER_BUFFER = StaticVars.enableVBO ? 128 : 1;
|
private static final int ELEMENTS_MAX_COUNT_PER_BUFFER = StaticVars.enableVBO ? 128 : 1;
|
||||||
|
|
||||||
private final DeallocationHelper deallocationHelper = new DeallocationHelper();
|
private final DeallocationHelper deallocationHelper = new DeallocationHelper();
|
||||||
FloatBuffer fbVertices;
|
FloatBuffer fbVertices;
|
||||||
FloatBuffer txVertices;
|
FloatBuffer fbTextures;
|
||||||
FloatBuffer colVertices;
|
FloatBuffer fbColors;
|
||||||
int fbElements;
|
int fbElements;
|
||||||
|
|
||||||
float[] currentColor = new float[24];
|
float[] currentColor = new float[24];
|
||||||
@ -151,8 +151,8 @@ public class GPURenderer implements Renderer {
|
|||||||
final float[] tex_vertices = { uvX, uvY, uvX + uvWidth, uvY, uvX, uvY + uvHeight, uvX, uvY + uvHeight, uvX + uvWidth, uvY, uvX + uvWidth, uvY + uvHeight };
|
final float[] tex_vertices = { uvX, uvY, uvX + uvWidth, uvY, uvX, uvY + uvHeight, uvX, uvY + uvHeight, uvX + uvWidth, uvY, uvX + uvWidth, uvY + uvHeight };
|
||||||
fbElements++;
|
fbElements++;
|
||||||
fbVertices.put(vertices);
|
fbVertices.put(vertices);
|
||||||
txVertices.put(tex_vertices);
|
fbTextures.put(tex_vertices);
|
||||||
colVertices.put(currentColor);
|
fbColors.put(currentColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -177,8 +177,8 @@ public class GPURenderer implements Renderer {
|
|||||||
final float[] tex_vertices = { 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, };
|
final float[] tex_vertices = { 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, };
|
||||||
fbElements++;
|
fbElements++;
|
||||||
fbVertices.put(vertices);
|
fbVertices.put(vertices);
|
||||||
txVertices.put(tex_vertices);
|
fbTextures.put(tex_vertices);
|
||||||
colVertices.put(currentColor);
|
fbColors.put(currentColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -299,9 +299,9 @@ public class GPURenderer implements Renderer {
|
|||||||
changeTexture();
|
changeTexture();
|
||||||
}
|
}
|
||||||
if (fbVertices == null) {
|
if (fbVertices == null) {
|
||||||
fbVertices = Buffers.newDirectFloatBuffer(3 * ELEMENT_VERTICES_COUNT * ELEMENTS_MAX_COUNT_PER_BUFFER);
|
fbVertices = Buffers.newDirectFloatBuffer(vertSize * ELEMENT_VERTICES_COUNT * ELEMENTS_MAX_COUNT_PER_BUFFER);
|
||||||
txVertices = Buffers.newDirectFloatBuffer(2 * ELEMENT_VERTICES_COUNT * ELEMENTS_MAX_COUNT_PER_BUFFER);
|
fbTextures = Buffers.newDirectFloatBuffer(texSize * ELEMENT_VERTICES_COUNT * ELEMENTS_MAX_COUNT_PER_BUFFER);
|
||||||
colVertices = Buffers.newDirectFloatBuffer(4 * ELEMENT_VERTICES_COUNT * ELEMENTS_MAX_COUNT_PER_BUFFER);
|
fbColors = Buffers.newDirectFloatBuffer(colSize * ELEMENT_VERTICES_COUNT * ELEMENTS_MAX_COUNT_PER_BUFFER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -360,18 +360,18 @@ public class GPURenderer implements Renderer {
|
|||||||
|
|
||||||
public void endDrawSegment() {
|
public void endDrawSegment() {
|
||||||
fbVertices.limit(fbVertices.position());
|
fbVertices.limit(fbVertices.position());
|
||||||
txVertices.limit(txVertices.position());
|
fbTextures.limit(fbTextures.position());
|
||||||
colVertices.limit(colVertices.position());
|
fbColors.limit(fbColors.position());
|
||||||
fbVertices.rewind();
|
fbVertices.rewind();
|
||||||
txVertices.rewind();
|
fbTextures.rewind();
|
||||||
colVertices.rewind();
|
fbColors.rewind();
|
||||||
|
|
||||||
gl.glVertexPointer(3, GL.GL_FLOAT, 0, fbVertices);
|
gl.glVertexPointer(vertSize, GL.GL_FLOAT, 0, fbVertices);
|
||||||
gl.glTexCoordPointer(2, GL.GL_FLOAT, 0, txVertices);
|
gl.glTexCoordPointer(texSize, GL.GL_FLOAT, 0, fbTextures);
|
||||||
gl.glColorPointer(4, GL.GL_FLOAT, 0, colVertices);
|
gl.glColorPointer(colSize, GL.GL_FLOAT, 0, fbColors);
|
||||||
fbVertices.limit(fbVertices.capacity());
|
fbVertices.limit(fbVertices.capacity());
|
||||||
txVertices.limit(txVertices.capacity());
|
fbTextures.limit(fbTextures.capacity());
|
||||||
colVertices.limit(colVertices.capacity());
|
fbColors.limit(fbColors.capacity());
|
||||||
|
|
||||||
gl.glDrawArrays(GL.GL_TRIANGLES, 0, fbElements * ELEMENT_VERTICES_COUNT);
|
gl.glDrawArrays(GL.GL_TRIANGLES, 0, fbElements * ELEMENT_VERTICES_COUNT);
|
||||||
//gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, fbElements * ELEMENT_VERTICES_COUNT);
|
//gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, fbElements * ELEMENT_VERTICES_COUNT);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user