/** Binds the underlying {@link VertexBufferObject} and {@link IndexBufferObject} if indices where given. Use this with OpenGL * ES 2.0 and when auto-bind is disabled. * * @param shader the shader (does not bind the shader) * @param locations array containing the attribute locations. */ public void bind (final ShaderProgram shader, final int[] locations) { vertices.bind(shader, locations); if (indices.getNumIndices() > 0) indices.bind(); }
/** Frees all resources associated with this Mesh */ public void dispose () { if (meshes.get(Gdx.app) != null) meshes.get(Gdx.app).removeValue(this, true); vertices.dispose(); indices.dispose(); }
/** @return the backing shortbuffer holding the indices. Does not have to be a direct buffer on Android! */ public ShortBuffer getIndicesBuffer () { return indices.getBuffer(); }
/** Unbinds the underlying {@link VertexBufferObject} and {@link IndexBufferObject} is indices were given. Use this with OpenGL * ES 1.x and when auto-bind is disabled. * * @param shader the shader (does not unbind the shader) * @param locations array containing the attribute locations. */ public void unbind (final ShaderProgram shader, final int[] locations) { vertices.unbind(shader, locations); if (indices.getNumIndices() > 0) indices.unbind(); }
if (indices.getNumIndices() > 0) { ShortBuffer buffer = indices.getBuffer(); int oldPosition = buffer.position(); int oldLimit = buffer.limit(); if (indices.getNumIndices() > 0) { if (count + offset > indices.getNumMaxIndices()) { throw new GdxRuntimeException("Mesh attempting to access memory outside of the index buffer (count: " + count + ", offset: " + offset + ", max: " + indices.getNumMaxIndices() + ")");
/** Sets the indices of this Mesh * * @param indices the indices * @return the mesh for invocation chaining. */ public Mesh setIndices (short[] indices) { this.indices.setIndices(indices, 0, indices.length); return this; }
/** @return the maximum number of indices this mesh can hold */ public int getMaxIndices () { return indices.getNumMaxIndices(); }
/** @return the number of defined indices */ public int getNumIndices () { return indices.getNumIndices(); }
/** Invalidates all meshes so the next time they are rendered new VBO handles are generated. * @param app */ public static void invalidateAllMeshes (Application app) { Array<Mesh> meshesArray = meshes.get(app); if (meshesArray == null) return; for (int i = 0; i < meshesArray.size; i++) { meshesArray.get(i).vertices.invalidate(); meshesArray.get(i).indices.invalidate(); } }
if (indices.getNumIndices() > 0) { ShortBuffer buffer = indices.getBuffer(); int oldPosition = buffer.position(); int oldLimit = buffer.limit(); if (indices.getNumIndices() > 0) { if (count + offset > indices.getNumMaxIndices()) { throw new GdxRuntimeException("Mesh attempting to access memory outside of the index buffer (count: " + count + ", offset: " + offset + ", max: " + indices.getNumMaxIndices() + ")");
/** Unbinds the underlying {@link VertexBufferObject} and {@link IndexBufferObject} is indices were given. Use this with OpenGL * ES 1.x and when auto-bind is disabled. * * @param shader the shader (does not unbind the shader) * @param locations array containing the attribute locations. */ public void unbind (final ShaderProgram shader, final int[] locations) { vertices.unbind(shader, locations); if (indices.getNumIndices() > 0) indices.unbind(); }
/** Sets the indices of this Mesh. * * @param indices the indices * @param offset the offset into the indices array * @param count the number of indices to copy * @return the mesh for invocation chaining. */ public Mesh setIndices (short[] indices, int offset, int count) { this.indices.setIndices(indices, offset, count); return this; }
/** @return the maximum number of indices this mesh can hold */ public int getMaxIndices () { return indices.getNumMaxIndices(); }
/** @return the number of defined indices */ public int getNumIndices () { return indices.getNumIndices(); }
/** Invalidates all meshes so the next time they are rendered new VBO handles are generated. * @param app */ public static void invalidateAllMeshes (Application app) { Array<Mesh> meshesArray = meshes.get(app); if (meshesArray == null) return; for (int i = 0; i < meshesArray.size; i++) { meshesArray.get(i).vertices.invalidate(); meshesArray.get(i).indices.invalidate(); } }
if (indices.getNumIndices() > 0) { ShortBuffer buffer = indices.getBuffer(); int oldPosition = buffer.position(); int oldLimit = buffer.limit(); if (indices.getNumIndices() > 0) { if (count + offset > indices.getNumMaxIndices()) { throw new GdxRuntimeException("Mesh attempting to access memory outside of the index buffer (count: " + count + ", offset: " + offset + ", max: " + indices.getNumMaxIndices() + ")");
/** Unbinds the underlying {@link VertexBufferObject} and {@link IndexBufferObject} is indices were given. Use this with OpenGL * ES 1.x and when auto-bind is disabled. * * @param shader the shader (does not unbind the shader) * @param locations array containing the attribute locations. */ public void unbind (final ShaderProgram shader, final int[] locations) { vertices.unbind(shader, locations); if (indices.getNumIndices() > 0) indices.unbind(); }
/** Binds the underlying {@link VertexBufferObject} and {@link IndexBufferObject} if indices where given. Use this with OpenGL * ES 2.0 and when auto-bind is disabled. * * @param shader the shader (does not bind the shader) * @param locations array containing the attribute locations. */ public void bind (final ShaderProgram shader, final int[] locations) { vertices.bind(shader, locations); if (indices.getNumIndices() > 0) indices.bind(); }
/** @return the backing shortbuffer holding the indices. Does not have to be a direct buffer on Android! */ public ShortBuffer getIndicesBuffer () { return indices.getBuffer(); }
/** Sets the indices of this Mesh. * * @param indices the indices * @param offset the offset into the indices array * @param count the number of indices to copy * @return the mesh for invocation chaining. */ public Mesh setIndices (short[] indices, int offset, int count) { this.indices.setIndices(indices, offset, count); return this; }