DecalBatch.java 文件源码

java
阅读 19 收藏 0 点赞 0 评论 0

项目:libgdxcn 作者:
/** Initializes the batch with the given amount of decal objects the buffer is able to hold when full.
 * 
 * @param size Maximum size of decal objects to hold in memory */
public void initialize (int size) {
    vertices = new float[size * Decal.SIZE];
    mesh = new Mesh(Mesh.VertexDataType.VertexArray, false, size * 4, size * 6, new VertexAttribute(
        VertexAttributes.Usage.Position, 3, ShaderProgram.POSITION_ATTRIBUTE), new VertexAttribute(
        VertexAttributes.Usage.ColorPacked, 4, ShaderProgram.COLOR_ATTRIBUTE), new VertexAttribute(
        VertexAttributes.Usage.TextureCoordinates, 2, ShaderProgram.TEXCOORD_ATTRIBUTE + "0"));

    short[] indices = new short[size * 6];
    int v = 0;
    for (int i = 0; i < indices.length; i += 6, v += 4) {
        indices[i] = (short)(v);
        indices[i + 1] = (short)(v + 2);
        indices[i + 2] = (short)(v + 1);
        indices[i + 3] = (short)(v + 1);
        indices[i + 4] = (short)(v + 2);
        indices[i + 5] = (short)(v + 3);
    }
    mesh.setIndices(indices);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号