Package com.badlogic.gdx.graphics

Examples of com.badlogic.gdx.graphics.VertexAttribute


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

        if (attribute.type == GL20.GL_FLOAT) {
          buffer.position(attribute.offset / 4);
          shader.setVertexAttribute(location, attribute.numComponents, attribute.type, attribute.normalized, attributes.vertexSize,
              buffer);
        } else {
          byteBuffer.position(attribute.offset);
          shader.setVertexAttribute(location, attribute.numComponents, attribute.type, attribute.normalized, 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);

        if (attribute.type == GL20.GL_FLOAT) {
View Full Code Here


    }
  }

  private VertexAttribute[] buildVertexAttributes (boolean hasNormals, boolean hasColor, int numTexCoords) {
    Array<VertexAttribute> attribs = new Array<VertexAttribute>();
    attribs.add(new VertexAttribute(Usage.Position, 3, ShaderProgram.POSITION_ATTRIBUTE));
    if (hasNormals) attribs.add(new VertexAttribute(Usage.Normal, 3, ShaderProgram.NORMAL_ATTRIBUTE));
    if (hasColor) attribs.add(new VertexAttribute(Usage.ColorPacked, 4, ShaderProgram.COLOR_ATTRIBUTE));
    for (int i = 0; i < numTexCoords; i++) {
      attribs.add(new VertexAttribute(Usage.TextureCoordinates, 2, ShaderProgram.TEXCOORD_ATTRIBUTE + i));
    }
    VertexAttribute[] array = new VertexAttribute[attribs.size];
    for (int i = 0; i < attribs.size; i++)
      array[i] = attribs.get(i);
    return array;
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);

        shader.setVertexAttribute(location, attribute.numComponents, attribute.type, attribute.normalized, 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);

        shader.setVertexAttribute(location, attribute.numComponents, attribute.type, attribute.normalized, attributes.vertexSize,
View Full Code Here

          || renderable.environment.has(CubemapAttribute.EnvironmentMap)) 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";
    }
    if ((attributes & Usage.Tangent) == Usage.Tangent) prefix += "#define tangentFlag\n";
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

  /** @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

    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;
    alphaTestAttribute = new FloatAttribute(FloatAttribute.AlphaTest, config.defaultAlphaTest);
  }
View Full Code Here

    if (skinned != (numBones > 0)) return false;
    if (!skinned) return true;
    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);
    }
    return w == weights;
  }
View Full Code Here

    sin = new float[rays];
    cos = new float[rays];
    endX = new float[rays];
    endY = new float[rays];

    lightMesh = new Mesh(VertexDataType.VertexArray, false, vertexNum, 0, new VertexAttribute(Usage.Position, 2,
      "vertex_positions"), new VertexAttribute(Usage.ColorPacked, 4, "quad_colors"),
      new VertexAttribute(Usage.Generic, 1, "s"));
    softShadowMesh = new Mesh(VertexDataType.VertexArray, false, vertexNum * 2, 0, new VertexAttribute(Usage.Position, 2,
      "vertex_positions"), new VertexAttribute(Usage.ColorPacked, 4, "quad_colors"),
      new VertexAttribute(Usage.Generic, 1, "s"));
    setMesh();
  }
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.