Java 类com.badlogic.gdx.graphics.glutils.VertexBufferObject 实例源码

项目:teavm-libgdx    文件:OverlayTransformer.java   
@Override
public void transformClass(ClassHolder cls, ClassReaderSource innerSource, Diagnostics diagnostics) {
    if (cls.getName().equals(BufferUtils.class.getName())) {
        transformBufferUtils(cls, innerSource);
    } else if (cls.getName().equals(TextureData.Factory.class.getName())) {
        transformTextureData(cls, innerSource);
    } else if (cls.getName().equals(FileHandle.class.getName())) {
        transformFileHandle(cls);
    } else if (cls.getName().equals(Pixmap.class.getName())) {
        replaceClass(cls, innerSource.get(PixmapEmulator.class.getName()));
    } else if (cls.getName().equals(Matrix4.class.getName())) {
        transformMatrix(cls, innerSource);
    } else if (cls.getName().equals(VertexArray.class.getName()) ||
            cls.getName().equals(VertexBufferObject.class.getName())) {
        replaceClass(cls, innerSource.get(VertexArrayEmulator.class.getName()));
    } else if (cls.getName().equals(IndexArray.class.getName()) ||
            cls.getName().equals(IndexBufferObject.class.getName())) {
        replaceClass(cls, innerSource.get(IndexArrayEmulator.class.getName()));
    }
}
项目:libgdxcn    文件:IndexBufferObjectShaderTest.java   
@Override
public void create () {
    String vertexShader = "attribute vec4 a_position;    \n" + "attribute vec4 a_color;\n" + "attribute vec2 a_texCoords;\n"
        + "varying vec4 v_color;" + "varying vec2 v_texCoords;" + "void main()                  \n"
        + "{                            \n" + "   v_color = vec4(a_color.x, a_color.y, a_color.z, 1); \n"
        + "   v_texCoords = a_texCoords; \n" + "   gl_Position =  a_position;  \n" + "}                            \n";
    String fragmentShader = "#ifdef GL_ES\n" + "precision mediump float;\n" + "#endif\n" + "varying vec4 v_color;\n"
        + "varying vec2 v_texCoords;\n" + "uniform sampler2D u_texture;\n" + "void main()                                  \n"
        + "{                                            \n" + "  gl_FragColor = v_color * texture2D(u_texture, v_texCoords);\n"
        + "}";

    shader = new ShaderProgram(vertexShader, fragmentShader);
    vbo = new VertexBufferObject(true, 3, new VertexAttribute(VertexAttributes.Usage.Position, 2, "a_position"),
        new VertexAttribute(VertexAttributes.Usage.TextureCoordinates, 2, "a_texCoords"), new VertexAttribute(
            VertexAttributes.Usage.ColorPacked, 4, "a_color"));
    float[] vertices = new float[] {-1, -1, 0, 0, Color.toFloatBits(1f, 0f, 0f, 1f), 0, 1, 0.5f, 1.0f,
        Color.toFloatBits(0f, 1f, 0f, 1f), 1, -1, 1, 0, Color.toFloatBits(0f, 0f, 1f, 1f)};
    vbo.setVertices(vertices, 0, vertices.length);

    ibo = new IndexBufferObject(true, 3);
    ibo.setIndices(new short[] {0, 1, 2}, 0, 3);

    texture = new Texture(Gdx.files.internal("data/badlogic.jpg"));
}
项目:ingress-indonesia-dev    文件:SpriteBatch.java   
protected void renderMesh()
{
  if (this.idx == 0)
    return;
  this.renderCalls = (1 + this.renderCalls);
  this.totalRenderCalls = (1 + this.totalRenderCalls);
  int i = this.idx / 20;
  this.maxSpritesInBatch = Math.max(this.maxSpritesInBatch, i);
  this.lastTexture.bind();
  VertexBufferObject localVertexBufferObject = uploadVertexData();
  if (Gdx.gl20 != null)
  {
    if (this.customShader != null);
    for (ShaderProgram localShaderProgram = this.customShader; ; localShaderProgram = this.shader)
    {
      localVertexBufferObject.bind(localShaderProgram);
      Gdx.gl20.glDrawElements(4, i * 6, 5123, 0);
      localVertexBufferObject.unbind(localShaderProgram);
      return;
    }
  }
  localVertexBufferObject.bind();
  Gdx.gl11.glDrawElements(4, i * 6, 5123, 0);
  localVertexBufferObject.unbind();
}
项目:ingress-indonesia-dev    文件:Mesh.java   
public Mesh(Mesh.VertexDataType paramVertexDataType, boolean paramBoolean, int paramInt1, int paramInt2, VertexAttribute[] paramArrayOfVertexAttribute)
{
  if (paramVertexDataType == Mesh.VertexDataType.VertexBufferObject)
  {
    this.vertices = new VertexBufferObject(paramBoolean, paramInt1, paramArrayOfVertexAttribute);
    this.indices = new IndexBufferObject(paramBoolean, paramInt2);
    this.isVertexArray = false;
  }
  while (true)
  {
    addManagedMesh(Gdx.app, this);
    return;
    if (paramVertexDataType == Mesh.VertexDataType.VertexBufferObjectSubData)
    {
      this.vertices = new VertexBufferObjectSubData(paramBoolean, paramInt1, paramArrayOfVertexAttribute);
      this.indices = new IndexBufferObjectSubData(paramBoolean, paramInt2);
      this.isVertexArray = false;
    }
    else
    {
      this.vertices = new VertexArray(paramInt1, paramArrayOfVertexAttribute);
      this.indices = new IndexArray(paramInt2);
      this.isVertexArray = true;
    }
  }
}
项目:ingress-indonesia-dev    文件:t.java   
private void b(int paramInt)
{
  if (paramInt <= 32767);
  for (boolean bool = true; ; bool = false)
  {
    an.a(bool, "Vertex count larger than usable with GL_SIGNED_SHORT");
    if (this.h < paramInt)
    {
      this.h = paramInt;
      this.e = new float[paramInt * (this.b.vertexSize / 4)];
      this.f = true;
      dispose();
      this.c = new VertexBufferObject(false, paramInt, this.b);
      this.d = new VertexBufferObject(false, paramInt, this.b);
      a.add(this);
    }
    return;
  }
}
项目:libgdxcn    文件:Mesh.java   
/** Creates a new Mesh with the given attributes.
 * 
 * @param isStatic whether this mesh is static or not. Allows for internal optimizations.
 * @param maxVertices the maximum number of vertices this mesh can hold
 * @param maxIndices the maximum number of indices this mesh can hold
 * @param attributes the {@link VertexAttribute}s. Each vertex attribute defines one property of a vertex such as position,
 *           normal or texture coordinate */
public Mesh (boolean isStatic, int maxVertices, int maxIndices, VertexAttribute... attributes) {
    vertices = new VertexBufferObject(isStatic, maxVertices, attributes);
    indices = new IndexBufferObject(isStatic, maxIndices);
    isVertexArray = false;

    addManagedMesh(Gdx.app, this);
}
项目:libgdxcn    文件:Mesh.java   
/** Creates a new Mesh with the given attributes.
 * 
 * @param isStatic whether this mesh is static or not. Allows for internal optimizations.
 * @param maxVertices the maximum number of vertices this mesh can hold
 * @param maxIndices the maximum number of indices this mesh can hold
 * @param attributes the {@link VertexAttributes}. Each vertex attribute defines one property of a vertex such as position,
 *           normal or texture coordinate */
public Mesh (boolean isStatic, int maxVertices, int maxIndices, VertexAttributes attributes) {
    vertices = new VertexBufferObject(isStatic, maxVertices, attributes);
    indices = new IndexBufferObject(isStatic, maxIndices);
    isVertexArray = false;

    addManagedMesh(Gdx.app, this);
}
项目:libgdxcn    文件:VertexBufferObjectShaderTest.java   
@Override
public void create () {
    //@off
    String vertexShader = 
          "attribute vec4 a_position;    \n"
        + "attribute vec4 a_color;\n"
        + "attribute vec2 a_texCoords;\n"
        + "varying vec4 v_color;"
        + "varying vec2 v_texCoords;" + "void main()                  \n"
        + "{                            \n"
        + "   v_color = vec4(a_color.x, a_color.y, a_color.z, 1); \n"
        + "   v_texCoords = a_texCoords; \n"
        + "   gl_Position =  a_position;  \n"
        + "}                            \n";
    String fragmentShader = 
          "#ifdef GL_ES\n"
        + "precision mediump float;\n"
        + "#endif\n" 
        + "varying vec4 v_color;\n"
        + "varying vec2 v_texCoords;\n" 
        + "uniform sampler2D u_texture;\n" 
        + "void main()                                  \n"
        + "{                                            \n" 
        + "  gl_FragColor = v_color * texture2D(u_texture, v_texCoords);\n"
        + "}";
    //@on

    shader = new ShaderProgram(vertexShader, fragmentShader);
    vbo = new VertexBufferObject(true, 3, new VertexAttribute(VertexAttributes.Usage.Position, 2, "a_position"),
        new VertexAttribute(VertexAttributes.Usage.TextureCoordinates, 2, "a_texCoords"), new VertexAttribute(
            VertexAttributes.Usage.ColorPacked, 4, "a_color"));
    float[] vertices = new float[] {-1, -1, 0, 0, Color.toFloatBits(1f, 0f, 0f, 1f), 0, 1, 0.5f, 1.0f,
        Color.toFloatBits(0f, 1f, 0f, 1f), 1, -1, 1, 0, Color.toFloatBits(0f, 0f, 1f, 1f)};
    vbo.setVertices(vertices, 0, vertices.length);
    indices = new IndexBufferObject(3);
    indices.setIndices(new short[] {0, 1, 2}, 0, 3);

    texture = new Texture(Gdx.files.internal("data/badlogic.jpg"));
}
项目:ingress-indonesia-dev    文件:SpriteBatch.java   
private static VertexBufferObject[] createVertexBuffers(int paramInt1, int paramInt2)
{
  VertexBufferObject[] arrayOfVertexBufferObject = new VertexBufferObject[paramInt2];
  for (int i = 0; i < paramInt2; i++)
  {
    VertexAttribute[] arrayOfVertexAttribute = new VertexAttribute[3];
    arrayOfVertexAttribute[0] = new VertexAttribute(0, 2, "a_position");
    arrayOfVertexAttribute[1] = new VertexAttribute(5, 4, "a_color");
    arrayOfVertexAttribute[2] = new VertexAttribute(3, 2, "a_texCoord0");
    arrayOfVertexBufferObject[i] = new VertexBufferObject(false, paramInt1, arrayOfVertexAttribute);
  }
  return arrayOfVertexBufferObject;
}
项目:ingress-indonesia-dev    文件:SpriteBatch.java   
protected VertexBufferObject uploadVertexData()
{
  VertexBufferObject localVertexBufferObject = this.vertexBuffers[this.currBufferIdx];
  localVertexBufferObject.setVertices(this.vertices, 0, this.idx);
  this.idx = 0;
  this.currBufferIdx = (1 + this.currBufferIdx);
  if (this.currBufferIdx == this.vertexBuffers.length)
    this.currBufferIdx = 0;
  return localVertexBufferObject;
}
项目:ingress-indonesia-dev    文件:Mesh.java   
public Mesh(boolean paramBoolean, int paramInt1, int paramInt2, VertexAttributes paramVertexAttributes)
{
  if ((Gdx.gl20 != null) || (Gdx.gl11 != null) || (forceVBO))
  {
    this.vertices = new VertexBufferObject(paramBoolean, paramInt1, paramVertexAttributes);
    this.indices = new IndexBufferObject(paramBoolean, paramInt2);
  }
  for (this.isVertexArray = false; ; this.isVertexArray = true)
  {
    addManagedMesh(Gdx.app, this);
    return;
    this.vertices = new VertexArray(paramInt1, paramVertexAttributes);
    this.indices = new IndexArray(paramInt2);
  }
}
项目:ingress-indonesia-dev    文件:Mesh.java   
public Mesh(boolean paramBoolean, int paramInt1, int paramInt2, VertexAttribute[] paramArrayOfVertexAttribute)
{
  if ((Gdx.gl20 != null) || (Gdx.gl11 != null) || (forceVBO))
  {
    this.vertices = new VertexBufferObject(paramBoolean, paramInt1, paramArrayOfVertexAttribute);
    this.indices = new IndexBufferObject(paramBoolean, paramInt2);
  }
  for (this.isVertexArray = false; ; this.isVertexArray = true)
  {
    addManagedMesh(Gdx.app, this);
    return;
    this.vertices = new VertexArray(paramInt1, paramArrayOfVertexAttribute);
    this.indices = new IndexArray(paramInt2);
  }
}
项目:ingress-indonesia-dev    文件:Mesh.java   
public static void invalidateAllMeshes(Application paramApplication)
{
  List localList = (List)meshes.get(paramApplication);
  if (localList == null);
  while (true)
  {
    return;
    for (int i = 0; i < localList.size(); i++)
    {
      if ((((Mesh)localList.get(i)).vertices instanceof VertexBufferObject))
        ((VertexBufferObject)((Mesh)localList.get(i)).vertices).invalidate();
      ((Mesh)localList.get(i)).indices.invalidate();
    }
  }
}
项目:ingress-indonesia-dev    文件:s.java   
protected final VertexBufferObject uploadVertexData()
{
  o.f().b();
  aj.a("SpriteBatch.uploadVertexData");
  VertexBufferObject localVertexBufferObject = super.uploadVertexData();
  aj.b();
  o.f();
  b.c();
  return localVertexBufferObject;
}
项目:ingress-indonesia-dev    文件:t.java   
public final void a(int paramInt, ShaderProgram paramShaderProgram)
{
  boolean bool1;
  if (!this.g)
  {
    bool1 = true;
    an.b(bool1);
    if (paramInt > this.h)
      break label103;
  }
  label103: for (boolean bool2 = true; ; bool2 = false)
  {
    an.a(bool2);
    if (this.f)
    {
      this.f = false;
      VertexBufferObject localVertexBufferObject = this.c;
      this.c = this.d;
      this.d = localVertexBufferObject;
      this.c.setVertices(this.e, 0, paramInt * (this.b.vertexSize / 4));
    }
    this.c.bind(paramShaderProgram);
    this.g = true;
    return;
    bool1 = false;
    break;
  }
}
项目:ingress-indonesia-dev    文件:an.java   
public an(float[] paramArrayOfFloat, VertexAttribute[] paramArrayOfVertexAttribute)
{
  this.b = new VertexAttributes(paramArrayOfVertexAttribute);
  this.d = paramArrayOfFloat.length;
  this.c = new VertexBufferObject(true, this.d, paramArrayOfVertexAttribute);
  this.c.setVertices(paramArrayOfFloat, 0, this.d);
  a.add(this);
}