Package com.badlogic.gdx.graphics

Examples of com.badlogic.gdx.graphics.VertexAttribute


    int textureUnit = 0;
    int numAttributes = attributes.size();

    for (int i = 0; i < numAttributes; i++) {

      VertexAttribute attribute = attributes.get(i);
      switch (attribute.usage) {
      case Usage.Position:
        break; // no-op, we always need a position bound in gles
      case Usage.Color:
      case Usage.ColorPacked:
View Full Code Here


    final GL20 gl = Gdx.gl20;
    final int numAttributes = attributes.size();
    byteBuffer.limit(buffer.limit() * 4);
    if (locations == null) {
      for (int i = 0; i < numAttributes; i++) {
        final VertexAttribute attribute = attributes.get(i);
        final int location = shader.getAttributeLocation(attribute.alias);
        if (location < 0)
          continue;
        shader.enableVertexAttribute(location);
       
        byteBuffer.position(attribute.offset);
        if (attribute.usage == Usage.ColorPacked)
          shader.setVertexAttribute(location, attribute.numComponents, GL20.GL_UNSIGNED_BYTE, true,
            attributes.vertexSize, byteBuffer);
        else
          shader.setVertexAttribute(location, attribute.numComponents, GL20.GL_FLOAT, false,
            attributes.vertexSize, byteBuffer);
      }
    } else {
      for (int i = 0; i < numAttributes; i++) {
        final VertexAttribute attribute = attributes.get(i);
        final int location = locations[i];
        if (location < 0)
          continue;
        shader.enableVertexAttribute(location);
       
View Full Code Here

    }

    final int numAttributes = attributes.size();
    if (locations == null) {
      for (int i = 0; i < numAttributes; i++) {
        final VertexAttribute attribute = attributes.get(i);
        final int location = shader.getAttributeLocation(attribute.alias);
        if (location < 0)
          continue;
        shader.enableVertexAttribute(location);
 
        if (attribute.usage == Usage.ColorPacked)
          shader.setVertexAttribute(location, attribute.numComponents, GL20.GL_UNSIGNED_BYTE, true, attributes.vertexSize,
            attribute.offset);
        else
          shader.setVertexAttribute(location, attribute.numComponents, GL20.GL_FLOAT, false, attributes.vertexSize,
            attribute.offset);
      }
    } else {
      for (int i = 0; i < numAttributes; i++) {
        final VertexAttribute attribute = attributes.get(i);
        final int location = locations[i];
        if (location < 0)
          continue;
        shader.enableVertexAttribute(location);
 
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.ColorPacked) == Usage.ColorPacked)
      attrs.add(new VertexAttribute(Usage.ColorPacked, 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);
    norOffset = a == null ? -1 : a.offset / 4;
View Full Code Here

  public SpriteCache (int size, ShaderProgram shader, boolean useIndices) {
    this.shader = shader;

    if (useIndices && size > 5460) throw new IllegalArgumentException("Can't have more than 5460 sprites per batch: " + size);

    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) {
      int length = size * 6;
      short[] indices = new short[length];
View Full Code Here

    int textureUnit = 0;
    int numAttributes = attributes.size();

    for (int i = 0; i < numAttributes; i++) {
      VertexAttribute attribute = attributes.get(i);

      switch (attribute.usage) {
      case Usage.Position:
        gl.glEnableClientState(GL11.GL_VERTEX_ARRAY);
        gl.glVertexPointer(attribute.numComponents, GL10.GL_FLOAT, attributes.vertexSize, attribute.offset);
View Full Code Here

    }

    final int numAttributes = attributes.size();
    if (locations == null) {
      for (int i = 0; i < numAttributes; i++) {
        final VertexAttribute attribute = attributes.get(i);
        final int location = shader.getAttributeLocation(attribute.alias);
        if (location < 0)
          continue;
        shader.enableVertexAttribute(location);
 
        if (attribute.usage == Usage.ColorPacked)
          shader.setVertexAttribute(location, attribute.numComponents, GL20.GL_UNSIGNED_BYTE, true, attributes.vertexSize,
            attribute.offset);
        else
          shader.setVertexAttribute(location, attribute.numComponents, GL20.GL_FLOAT, false, attributes.vertexSize,
            attribute.offset);
      }
    } else {
      for (int i = 0; i < numAttributes; i++) {
        final VertexAttribute attribute = attributes.get(i);
        final int location = locations[i];
        if (location < 0)
          continue;
        shader.enableVertexAttribute(location);
 
View Full Code Here

    int textureUnit = 0;
    int numAttributes = attributes.size();

    for (int i = 0; i < numAttributes; i++) {

      VertexAttribute attribute = attributes.get(i);
      switch (attribute.usage) {
      case Usage.Position:
        break; // no-op, we also need a position bound in gles
      case Usage.Color:
      case Usage.ColorPacked:
View Full Code Here

   * The buffers for the vertices and indices are shared amonst both. */
  public void set(final Mesh mesh, int offset, int count) {
    if ((count <= 0) || ((count % 3) != 0))
      throw new com.badlogic.gdx.utils.GdxRuntimeException("Mesh must be indexed and triangulated");

    VertexAttribute posAttr = mesh.getVertexAttribute(Usage.Position);
   
    if (posAttr == null)
      throw new com.badlogic.gdx.utils.GdxRuntimeException("Mesh doesn't have a position attribute");
   
    setVertices(mesh.getVerticesBuffer(), mesh.getVertexSize(), mesh.getNumVertices(), posAttr.offset);
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.