/** * Check an incoming TexCoords object for null and correct size. * * @param tc * @param vertexCount * @param perVert * @return tc if it is not null and the right size, otherwise it will be a new TexCoords object. */ public static FloatBufferData ensureSize(final FloatBufferData tc, final int vertexCount, final int coordsPerVertex) { if (tc == null) { return new FloatBufferData(BufferUtils.createFloatBuffer(vertexCount * coordsPerVertex), coordsPerVertex); } if (tc.getBuffer().limit() == coordsPerVertex * vertexCount && tc.getValuesPerTuple() == coordsPerVertex) { tc.getBuffer().rewind(); return tc; } else if (tc.getBuffer().limit() == coordsPerVertex * vertexCount) { tc.setValuesPerTuple(coordsPerVertex); } else { return new FloatBufferData(BufferUtils.createFloatBuffer(vertexCount * coordsPerVertex), coordsPerVertex); } return tc; } }