Skip to content

Commit

Permalink
Add SpriteBatch.defaultVertexDataType for testing VBO instead of VA, …
Browse files Browse the repository at this point in the history
…see #3912
  • Loading branch information
xoppa committed Mar 10, 2016
1 parent 8eb080c commit 0edef77
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
6 changes: 3 additions & 3 deletions gdx/src/com/badlogic/gdx.gwt.xml
Expand Up @@ -84,8 +84,8 @@
<include name="graphics/Pixmap.java"/> <!-- Emulated -->
<exclude name="graphics/PixmapIO.java"/> <!-- Reason: No DeflaterOutputStream -->
<include name="graphics/Texture.java"/>
<include name="graphics/TextureArray.java"/>
<include name="graphics/TextureArrayData.java"/>
<exclude name="graphics/TextureArray.java"/> <!-- GLES 3.0 -->
<exclude name="graphics/TextureArrayData.java"/> <!-- GLES 3.0 -->
<exclude name="graphics/TextureData.java"/> <!-- emulated: TextureData.Factory requires ETC1 -->
<include name="graphics/VertexAttribute.java"/>
<include name="graphics/VertexAttributes.java"/>
Expand Down Expand Up @@ -220,7 +220,7 @@
<exclude name="graphics/glutils/ETC1.java"/> <!-- Reason: No ETC1 Support -->
<include name="graphics/glutils/ETC1TextureData.java"/> <!-- Emulated: explodes on construction -->
<include name="graphics/glutils/FacedCubemapData.java"/>
<include name="graphics/glutils/FileTextureArrayData.java"/>
<exclude name="graphics/glutils/FileTextureArrayData.java"/> <!-- GLES 3.0 -->
<include name="graphics/glutils/FileTextureData.java"/> <!-- Emulated: No PixmapIO -->
<include name="graphics/glutils/FloatFrameBuffer.java"/>
<include name="graphics/glutils/FloatTextureData.java"/>
Expand Down
11 changes: 7 additions & 4 deletions gdx/src/com/badlogic/gdx/graphics/g2d/SpriteBatch.java
Expand Up @@ -20,6 +20,7 @@
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Mesh;
import com.badlogic.gdx.graphics.Mesh.VertexDataType;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.VertexAttribute;
import com.badlogic.gdx.graphics.VertexAttributes.Usage;
Expand All @@ -34,6 +35,10 @@
* @author mzechner
* @author Nathan Sweet */
public class SpriteBatch implements Batch {
/** @deprecated Do not use, this field is for testing only and is likely to be removed. Sets the {@link VertexDataType} to be
* used when gles 3 is not available, defaults to {@link VertexDataType#VertexArray}. */
@Deprecated public static VertexDataType defaultVertexDataType = VertexDataType.VertexArray;

private Mesh mesh;

final float[] vertices;
Expand Down Expand Up @@ -91,10 +96,8 @@ public SpriteBatch (int size, ShaderProgram defaultShader) {
// 32767 is max index, so 32767 / 6 - (32767 / 6 % 3) = 5460.
if (size > 5460) throw new IllegalArgumentException("Can't have more than 5460 sprites per batch: " + size);

Mesh.VertexDataType vertexDataType = Mesh.VertexDataType.VertexArray;
if (Gdx.gl30 != null) {
vertexDataType = Mesh.VertexDataType.VertexBufferObjectWithVAO;
}
VertexDataType vertexDataType = (Gdx.gl30 != null) ? VertexDataType.VertexBufferObjectWithVAO : defaultVertexDataType;

mesh = new Mesh(vertexDataType, false, size * 4, size * 6, new VertexAttribute(Usage.Position, 2,
ShaderProgram.POSITION_ATTRIBUTE), new VertexAttribute(Usage.ColorPacked, 4, ShaderProgram.COLOR_ATTRIBUTE),
new VertexAttribute(Usage.TextureCoordinates, 2, ShaderProgram.TEXCOORD_ATTRIBUTE + "0"));
Expand Down

0 comments on commit 0edef77

Please sign in to comment.