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

项目: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   
private static IndexBufferObject createIndexBuffer(int paramInt)
{
  short[] arrayOfShort = new short[paramInt];
  int i = 0;
  for (int j = 0; i < paramInt; j = (short)(j + 4))
  {
    arrayOfShort[(i + 0)] = ((short)(j + 0));
    arrayOfShort[(i + 1)] = ((short)(j + 1));
    arrayOfShort[(i + 2)] = ((short)(j + 2));
    arrayOfShort[(i + 3)] = ((short)(j + 2));
    arrayOfShort[(i + 4)] = ((short)(j + 3));
    arrayOfShort[(i + 5)] = ((short)(j + 0));
    i += 6;
  }
  IndexBufferObject localIndexBufferObject = new IndexBufferObject(true, paramInt);
  localIndexBufferObject.setIndices(arrayOfShort, 0, paramInt);
  return localIndexBufferObject;
}
项目: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    文件:s.java   
private void a(int paramInt, boolean paramBoolean)
{
  if (paramInt <= 65536);
  for (boolean bool = true; ; bool = false)
  {
    an.a(bool, "Suspiciously large # of indices");
    if (this.g < paramInt)
    {
      short[] arrayOfShort = this.d;
      this.g = paramInt;
      this.d = new short[paramInt];
      this.e = true;
      if ((paramBoolean) && (arrayOfShort != null))
        System.arraycopy(arrayOfShort, 0, this.d, 0, arrayOfShort.length);
      dispose();
      this.b = new IndexBufferObject(paramInt);
      this.c = new IndexBufferObject(paramInt);
      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    文件: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    文件:am.java   
public am(short[] paramArrayOfShort)
{
  this.c = paramArrayOfShort.length;
  this.b = new IndexBufferObject(true, this.c);
  this.b.setIndices(paramArrayOfShort, 0, this.c);
  a.add(this);
}
项目:ingress-indonesia-dev    文件:s.java   
public final void a(int paramInt1, int paramInt2, t paramt, ShaderProgram paramShaderProgram)
{
  boolean bool1;
  if (!this.f)
  {
    bool1 = true;
    an.b(bool1);
    if (paramInt2 > this.g)
      break label141;
  }
  label141: for (boolean bool2 = true; ; bool2 = false)
  {
    an.a(bool2);
    if (this.e)
    {
      this.e = false;
      IndexBufferObject localIndexBufferObject = this.b;
      this.b = this.c;
      this.c = localIndexBufferObject;
      this.b.setIndices(this.d, 0, paramInt2);
    }
    this.b.bind();
    this.f = true;
    paramt.a(paramInt1, paramShaderProgram);
    Gdx.gl20.glDrawElements(4, paramInt2, 5123, 0);
    paramt.a(paramShaderProgram);
    an.b(this.f);
    this.b.unbind();
    this.f = false;
    return;
    bool1 = false;
    break;
  }
}
项目:ingress-indonesia-dev    文件:ai.java   
private static IndexBufferObject a(short[] paramArrayOfShort)
{
  if (paramArrayOfShort == null)
    return null;
  IndexBufferObject localIndexBufferObject = new IndexBufferObject(paramArrayOfShort.length);
  localIndexBufferObject.setIndices(paramArrayOfShort, 0, paramArrayOfShort.length);
  return localIndexBufferObject;
}