MCPcopy
hub / github.com/libgdx/libgdx / add

Method add

gdx/src/com/badlogic/gdx/graphics/g2d/SpriteCache.java:252–265  ·  view source on GitHub ↗

Adds the specified vertices to the cache. Each vertex should have 5 elements, one for each of the attributes: x, y, color, u, and v. If indexed geometry is used, each image should be specified as 4 vertices, otherwise each image should be specified as 6 vertices.

(Texture texture, float[] vertices, int offset, int length)

Source from the content-addressed store, hash-verified

250 * u, and v. If indexed geometry is used, each image should be specified as 4 vertices, otherwise each image should be
251 * specified as 6 vertices. */
252 public void add (Texture texture, float[] vertices, int offset, int length) {
253 if (currentCache == null) throw new IllegalStateException("beginCache must be called before add.");
254
255 int verticesPerImage = mesh.getNumIndices() > 0 ? 4 : 6;
256 int count = length / (verticesPerImage * VERTEX_SIZE) * 6;
257 int lastIndex = textures.size - 1;
258 if (lastIndex < 0 || textures.get(lastIndex) != texture) {
259 textures.add(texture);
260 counts.add(count);
261 } else
262 counts.incr(lastIndex, count);
263
264 mesh.getVerticesBuffer(true).put(vertices, offset, length);
265 }
266
267 /** Adds the specified texture to the cache. */
268 public void add (Texture texture, float x, float y) {

Callers 2

createMethod · 0.95
createMethod · 0.95

Calls 14

cosDegMethod · 0.95
sinDegMethod · 0.95
getVerticesBufferMethod · 0.80
getRegionWidthMethod · 0.80
getRegionHeightMethod · 0.80
getNumIndicesMethod · 0.65
getMethod · 0.65
addMethod · 0.65
putMethod · 0.65
getWidthMethod · 0.65
getHeightMethod · 0.65
incrMethod · 0.45

Tested by 2

createMethod · 0.76
createMethod · 0.76