Package com.badlogic.gdx.graphics

Examples of com.badlogic.gdx.graphics.VertexAttribute


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

    vertices = new float[size * Sprite.SPRITE_SIZE];

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

    vertices = new float[size * Sprite.SPRITE_SIZE];
 
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

          prefix += "#define environmentCubemapFlag\n";
      }
    }
    final int n = renderable.mesh.getVertexAttributes().size();
    for (int i = 0; i < n; i++) {
      final VertexAttribute attr = renderable.mesh.getVertexAttributes().get(i);
      if (attr.usage == Usage.BoneWeight)
        prefix += "#define boneWeight"+attr.unit+"Flag\n";
      else if (attr.usage == Usage.TextureCoordinates)
        prefix += "#define texCoord"+attr.unit+"Flag\n";
    }
View Full Code Here

  /** @param usage bitwise mask of the {@link com.badlogic.gdx.graphics.VertexAttributes.Usage},
   * only Position, Color, Normal and TextureCoordinates is supported. */
  public static VertexAttributes createAttributes(long usage) {
    final Array<VertexAttribute> attrs = new Array<VertexAttribute>();
    if ((usage & Usage.Position) == Usage.Position)
      attrs.add(new VertexAttribute(Usage.Position, 3, ShaderProgram.POSITION_ATTRIBUTE));
    if ((usage & Usage.Color) == Usage.Color)
      attrs.add(new VertexAttribute(Usage.Color, 4, ShaderProgram.COLOR_ATTRIBUTE));
    if ((usage & Usage.Normal) == Usage.Normal)
      attrs.add(new VertexAttribute(Usage.Normal, 3, ShaderProgram.NORMAL_ATTRIBUTE));
    if ((usage & Usage.TextureCoordinates) == Usage.TextureCoordinates)
      attrs.add(new VertexAttribute(Usage.TextureCoordinates, 2, ShaderProgram.TEXCOORD_ATTRIBUTE+"0"));
    final VertexAttribute attributes[] = new VertexAttribute[attrs.size];
    for (int i = 0; i < attributes.length; i++)
      attributes[i] = attrs.get(i);
    return new VertexAttributes(attributes);
  }
View Full Code Here

    this.vindex = 0;
    this.istart = 0;
    this.part = null;
    this.stride = attributes.vertexSize / 4;
    this.vertex = new float[stride];
    VertexAttribute a = attributes.findByUsage(Usage.Position);
    if (a == null)
      throw new GdxRuntimeException("Cannot build mesh without position attribute");
    posOffset = a.offset / 4;
    posSize = a.numComponents;
    a = attributes.findByUsage(Usage.Normal);
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());

    vertices = new float[size * Sprite.SPRITE_SIZE];
 
View Full Code Here

    final long mask = renderable.material.getMask();
    final long attributes = renderable.mesh.getVertexAttributes().getMask();
    if ((attributes & Usage.BoneWeight) == Usage.BoneWeight) {
      final int n = renderable.mesh.getVertexAttributes().size();
      for (int i = 0; i < n; i++) {
        final VertexAttribute attr = renderable.mesh.getVertexAttributes().get(i);
        if (attr.usage == Usage.BoneWeight)
          prefix += "#define boneWeight"+attr.unit+"Flag\n";
      }
    }
    // FIXME Add transparent texture support
View Full Code Here

    super(renderable, config, shaderProgram);
    this.numBones = renderable.bones == null ? 0 : config.numBones;
    int w = 0;
    final int n = renderable.mesh.getVertexAttributes().size();
    for (int i = 0; i < n; i++) {
      final VertexAttribute attr = renderable.mesh.getVertexAttributes().get(i);
      if (attr.usage == Usage.BoneWeight)
        w |= (1 << attr.unit);
    }
    weights = w;
  }
View Full Code Here

TOP

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

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.