Package com.badlogic.gdx.graphics

Examples of com.badlogic.gdx.graphics.Mesh


   * </p>
   *
   * @param size the batch size in number of sprites */
  public SpriteBatch (int size) {
    this.buffers = new Mesh[1];
    this.buffers[0] = new Mesh(VertexDataType.VertexArray, 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"));

    projectionMatrix.setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

View Full Code Here


   * @param buffers the number of buffers to use. only makes sense with VBOs. This is an expert function. */
  public SpriteBatch (int size, int buffers) {
    this.buffers = new Mesh[buffers];

    for (int i = 0; i < buffers; i++) {
      this.buffers[i] = new Mesh(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"));
    }

    projectionMatrix.setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
View Full Code Here

    verts[V3] = 1f;

    verts[U4] = 0f;
    verts[V4] = 1f;

    Mesh tmpMesh = new Mesh(VertexDataType.VertexArray, true, 4, 0, new VertexAttribute(Usage.Position, 2, "a_position"),
      new VertexAttribute(Usage.TextureCoordinates, 2, "a_texCoord0"));

    tmpMesh.setVertices(verts);
    return tmpMesh;
  }
View Full Code Here

    }
    dropRadius = 0.1f + dropRadiusK;
    dropRadiusPixel = (int) (dropRadius * PARTICLE_SIZE);
    dropRadiusPixel2 = dropRadiusPixel * dropRadiusPixel;
    if (IS_DESKTOP) {
      lineMesh = new Mesh(false, (SIZE) * 2, 0, new VertexAttribute(Usage.Position, 2, "a_pos"), new VertexAttribute(Usage.ColorPacked, 4, "a_color"));
      lineVertices = new float[(SIZE) * 2 * 2 * 3];
      disposableParticles = new ArrayList<Particle>(SIZE);
    } else {
      lineMesh = new Mesh(false, (ANDROID_SIZE) * 2, 0, new VertexAttribute(Usage.Position, 2, "a_pos"), new VertexAttribute(Usage.ColorPacked, 4, "a_color"));
      lineVertices = new float[(ANDROID_SIZE) * 2 * 2 * 3];
    }

    // On Android populate directly
    if (!IS_DESKTOP) {
View Full Code Here

  public Mesh end() {
    if (this.attributes == null)
      throw new RuntimeException("Call begin() first");
    endpart();
   
    final Mesh mesh = new Mesh(true, vertices.size, indices.size, attributes);
    mesh.setVertices(vertices.items, 0, vertices.size);
    mesh.setIndices(indices.items, 0, indices.size);
   
    for (MeshPart p : parts)
      p.mesh = mesh;
    parts.clear();
   
View Full Code Here

    // 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);

    this.buffers = new Mesh[buffers];
    for (int i = 0; i < buffers; i++) {
      this.buffers[i] = new Mesh(VertexDataType.VertexArray, 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"));
    }

    projectionMatrix.setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
View Full Code Here

    int spritesInBatch = idx / 20;
    if (spritesInBatch > maxSpritesInBatch) maxSpritesInBatch = spritesInBatch;
    int count = spritesInBatch * 6;

    lastTexture.bind();
    Mesh mesh = this.mesh;
    mesh.setVertices(vertices, 0, idx);
    mesh.getIndicesBuffer().position(0);
    mesh.getIndicesBuffer().limit(count);

    if (blendingDisabled) {
      Gdx.gl.glDisable(GL20.GL_BLEND);
    } else {
      Gdx.gl.glEnable(GL20.GL_BLEND);
      if (blendSrcFunc != -1) Gdx.gl.glBlendFunc(blendSrcFunc, blendDstFunc);
    }

    if (Gdx.graphics.isGL20Available())
      mesh.render(customShader != null ? customShader : shader, GL10.GL_TRIANGLES, 0, count);
    else
      mesh.render(GL10.GL_TRIANGLES, 0, count);

    idx = 0;
    currBufferIdx++;
    if (currBufferIdx == buffers.length) currBufferIdx = 0;
    this.mesh = buffers[currBufferIdx];
View Full Code Here

    // 32767 is max index, so 32767 / 3 - (32767 / 3 % 3) = 10920.
    if (size > 10920) throw new IllegalArgumentException("Can't have more than 10920 triangles per batch: " + size);

    this.buffers = new Mesh[buffers];
    for (int i = 0; i < buffers; i++) {
      this.buffers[i] = new Mesh(VertexDataType.VertexArray, false, size, size * 3, 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"));
    }
    mesh = this.buffers[0];

View Full Code Here

    totalRenderCalls++;
    int trianglesInBatch = triangleIndex;
    if (trianglesInBatch > maxTrianglesInBatch) maxTrianglesInBatch = trianglesInBatch;

    lastTexture.bind();
    Mesh mesh = this.mesh;
    mesh.setVertices(vertices, 0, vertexIndex);
    mesh.setIndices(triangles, 0, triangleIndex);

    if (blendingDisabled) {
      Gdx.gl.glDisable(GL20.GL_BLEND);
    } else {
      Gdx.gl.glEnable(GL20.GL_BLEND);
      if (blendSrcFunc != -1) Gdx.gl.glBlendFunc(blendSrcFunc, blendDstFunc);
    }

    if (Gdx.graphics.isGL20Available())
      mesh.render(customShader != null ? customShader : shader, GL10.GL_TRIANGLES, 0, trianglesInBatch);
    else
      mesh.render(GL10.GL_TRIANGLES, 0, trianglesInBatch);

    vertexIndex = 0;
    triangleIndex = 0;
    bufferIndex++;
    if (bufferIndex == buffers.length) bufferIndex = 0;
View Full Code Here

   * @param size The maximum number of images this cache can hold. The memory required to hold the images is allocated up front.
   * @param useIndices If true, indexed geometry will be used. */
  public SpriteCache (int size, ShaderProgram shader, boolean useIndices) {
    this.shader = shader;

    mesh = new Mesh(true, size * (useIndices ? 4 : 6), useIndices ? size * 6 : 0, 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"));
    mesh.setAutoBind(false);

    if (useIndices) {
View Full Code Here

TOP

Related Classes of com.badlogic.gdx.graphics.Mesh

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.