/** * Constructs a new interleaved VertexBufferObjectWithVAO. * * @param isStatic whether the vertex data is static. * @param numVertices the maximum number of vertices * @param attributes the {@link com.badlogic.gdx.graphics.VertexAttribute}s. */ public VertexBufferObjectWithVAO (boolean isStatic, int numVertices, VertexAttribute... attributes) { this(isStatic, numVertices, new VertexAttributes(attributes)); }
/** Constructs a new interleaved VertexBufferObject. * * @param isStatic whether the vertex data is static. * @param numVertices the maximum number of vertices * @param attributes the {@link VertexAttributes}. */ public VertexBufferObjectSubData (boolean isStatic, int numVertices, VertexAttribute... attributes) { this(isStatic, numVertices, new VertexAttributes(attributes)); }
/** * Constructs a new interleaved VertexBufferObjectWithVAO. * * @param isStatic whether the vertex data is static. * @param numVertices the maximum number of vertices * @param attributes the {@link com.badlogic.gdx.graphics.VertexAttribute}s. */ public VertexBufferObjectWithVAO (boolean isStatic, int numVertices, VertexAttribute... attributes) { this(isStatic, numVertices, new VertexAttributes(attributes)); }
/** Constructs a new interleaved VertexBufferObject. * * @param isStatic whether the vertex data is static. * @param numVertices the maximum number of vertices * @param attributes the {@link VertexAttribute}s. */ public VertexBufferObject (boolean isStatic, int numVertices, VertexAttribute... attributes) { this(isStatic, numVertices, new VertexAttributes(attributes)); }
/** Creates a new Mesh with the given attributes. This is an expert method with no error checking. Use at your own risk. * * @param type the {@link VertexDataType} to be used, VBO or VA. * @param isStatic whether this mesh is static or not. Allows for internal optimizations. * @param maxVertices the maximum number of vertices this mesh can hold * @param maxIndices the maximum number of indices this mesh can hold * @param attributes the {@link VertexAttribute}s. Each vertex attribute defines one property of a vertex such as position, * normal or texture coordinate */ public Mesh (VertexDataType type, boolean isStatic, int maxVertices, int maxIndices, VertexAttribute... attributes) { this(type, isStatic, maxVertices, maxIndices, new VertexAttributes(attributes)); }
/** * Constructs a new interleaved VertexBufferObjectWithVAO. * * @param isStatic whether the vertex data is static. * @param numVertices the maximum number of vertices * @param attributes the {@link com.badlogic.gdx.graphics.VertexAttribute}s. */ public VertexBufferObjectWithVAO (boolean isStatic, int numVertices, VertexAttribute... attributes) { this(isStatic, numVertices, new VertexAttributes(attributes)); }
/** Constructs a new interleaved VertexArray * * @param numVertices the maximum number of vertices * @param attributes the {@link VertexAttribute}s */ public VertexArray (int numVertices, VertexAttribute... attributes) { this(numVertices, new VertexAttributes(attributes)); }
/** Constructs a new interleaved VertexBufferObject. * * @param isStatic whether the vertex data is static. * @param numVertices the maximum number of vertices * @param attributes the {@link VertexAttributes}. */ public VertexBufferObjectSubData (boolean isStatic, int numVertices, VertexAttribute... attributes) { this(isStatic, numVertices, new VertexAttributes(attributes)); }
/** Constructs a new interleaved VertexArray * * @param numVertices the maximum number of vertices * @param attributes the {@link VertexAttribute}s */ public VertexArray (int numVertices, VertexAttribute... attributes) { this(numVertices, new VertexAttributes(attributes)); }
/** * Constructs a new interleaved VertexBufferObjectWithVAO. * * @param isStatic whether the vertex data is static. * @param numVertices the maximum number of vertices * @param attributes the {@link com.badlogic.gdx.graphics.VertexAttribute}s. */ public VertexBufferObjectWithVAO (boolean isStatic, int numVertices, VertexAttribute... attributes) { this(isStatic, numVertices, new VertexAttributes(attributes)); }
/** Creates a new Mesh with the given attributes. This is an expert method with no error checking. Use at your own risk. * * @param type the {@link VertexDataType} to be used, VBO or VA. * @param isStatic whether this mesh is static or not. Allows for internal optimizations. * @param maxVertices the maximum number of vertices this mesh can hold * @param maxIndices the maximum number of indices this mesh can hold * @param attributes the {@link VertexAttribute}s. Each vertex attribute defines one property of a vertex such as position, * normal or texture coordinate */ public Mesh (VertexDataType type, boolean isStatic, int maxVertices, int maxIndices, VertexAttribute... attributes) { this(type, isStatic, maxVertices, maxIndices, new VertexAttributes(attributes)); }
/** Constructs a new interleaved VertexBufferObject. * * @param isStatic whether the vertex data is static. * @param numVertices the maximum number of vertices * @param attributes the {@link VertexAttribute}s. */ public VertexBufferObject (boolean isStatic, int numVertices, VertexAttribute... attributes) { this(isStatic, numVertices, new VertexAttributes(attributes)); }
public OldVertexBufferObjectWithVAO (boolean isStatic, int numVertices, VertexAttribute... attributes) { this(isStatic, numVertices, new VertexAttributes(attributes)); }
/** Creates a new Mesh with the given attributes. * * @param isStatic whether this mesh is static or not. Allows for internal optimizations. * @param maxVertices the maximum number of vertices this mesh can hold * @param maxIndices the maximum number of indices this mesh can hold * @param attributes the {@link VertexAttribute}s. Each vertex attribute defines one property of a vertex such as position, * normal or texture coordinate */ public Mesh (boolean isStatic, int maxVertices, int maxIndices, VertexAttribute... attributes) { vertices = makeVertexBuffer(isStatic, maxVertices, new VertexAttributes(attributes)); indices = new IndexBufferObject(isStatic, maxIndices); isVertexArray = false; addManagedMesh(Gdx.app, this); }
/** Creates a new Mesh with the given attributes. * * @param isStatic whether this mesh is static or not. Allows for internal optimizations. * @param maxVertices the maximum number of vertices this mesh can hold * @param maxIndices the maximum number of indices this mesh can hold * @param attributes the {@link VertexAttribute}s. Each vertex attribute defines one property of a vertex such as position, * normal or texture coordinate */ public Mesh (boolean isStatic, int maxVertices, int maxIndices, VertexAttribute... attributes) { vertices = makeVertexBuffer(isStatic, maxVertices, new VertexAttributes(attributes)); indices = new IndexBufferObject(isStatic, maxIndices); isVertexArray = false; addManagedMesh(Gdx.app, this); }
/** Create a ShapeCache with default values */ public ShapeCache () { this(5000, 5000, new VertexAttributes(new VertexAttribute(Usage.Position, 3, "a_position"), new VertexAttribute( Usage.ColorPacked, 4, "a_color")), GL20.GL_LINES); }
/** Create a ShapeCache with default values */ public ShapeCache () { this(5000, 5000, new VertexAttributes(new VertexAttribute(Usage.Position, 3, "a_position"), new VertexAttribute( Usage.ColorPacked, 4, "a_color")), GL20.GL_LINES); }
protected void convertMesh (ModelMesh modelMesh) { int numIndices = 0; for (ModelMeshPart part : modelMesh.parts) { numIndices += part.indices.length; } VertexAttributes attributes = new VertexAttributes(modelMesh.attributes); int numVertices = modelMesh.vertices.length / (attributes.vertexSize / 4); Mesh mesh = new Mesh(true, numVertices, numIndices, attributes); meshes.add(mesh); disposables.add(mesh); BufferUtils.copy(modelMesh.vertices, mesh.getVerticesBuffer(), modelMesh.vertices.length, 0); int offset = 0; mesh.getIndicesBuffer().clear(); for (ModelMeshPart part : modelMesh.parts) { MeshPart meshPart = new MeshPart(); meshPart.id = part.id; meshPart.primitiveType = part.primitiveType; meshPart.offset = offset; meshPart.size = part.indices.length; meshPart.mesh = mesh; mesh.getIndicesBuffer().put(part.indices); offset += meshPart.size; meshParts.add(meshPart); } mesh.getIndicesBuffer().position(0); for (MeshPart part : meshParts) part.update(); }
/** @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.ColorUnpacked) == Usage.ColorUnpacked) attrs.add(new VertexAttribute(Usage.ColorUnpacked, 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); }
/** @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.ColorUnpacked) == Usage.ColorUnpacked) attrs.add(new VertexAttribute(Usage.ColorUnpacked, 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); }