use of com.badlogic.gdx.utils.GdxRuntimeException in project libgdx by libgdx.
the class FileHandle method list.
/** Returns the paths to the children of this directory that satisfy the specified filter. Returns an empty list if this file
* handle represents a file and not a directory. On the desktop, an {@link FileType#Internal} handle to a directory on the
* classpath will return a zero length array.
* @param filter the {@link FileFilter} to filter files
* @throws GdxRuntimeException if this file is an {@link FileType#Classpath} file. */
public FileHandle[] list(FileFilter filter) {
if (type == FileType.Classpath)
throw new GdxRuntimeException("Cannot list a classpath directory: " + file);
File file = file();
String[] relativePaths = file.list();
if (relativePaths == null)
return new FileHandle[0];
FileHandle[] handles = new FileHandle[relativePaths.length];
int count = 0;
for (int i = 0, n = relativePaths.length; i < n; i++) {
String path = relativePaths[i];
FileHandle child = child(path);
if (!filter.accept(child.file()))
continue;
handles[count] = child;
count++;
}
if (count < relativePaths.length) {
FileHandle[] newHandles = new FileHandle[count];
System.arraycopy(handles, 0, newHandles, 0, count);
handles = newHandles;
}
return handles;
}
use of com.badlogic.gdx.utils.GdxRuntimeException in project libgdx by libgdx.
the class Pixmap method dispose.
/** Releases all resources associated with this Pixmap. */
public void dispose() {
if (disposed)
throw new GdxRuntimeException("Pixmap already disposed!");
pixmap.dispose();
disposed = true;
}
use of com.badlogic.gdx.utils.GdxRuntimeException in project libgdx by libgdx.
the class Texture method load.
public void load(TextureData data) {
if (this.data != null && data.isManaged() != this.data.isManaged())
throw new GdxRuntimeException("New data must have the same managed status as the old data");
this.data = data;
if (!data.isPrepared())
data.prepare();
bind();
uploadImageData(GL20.GL_TEXTURE_2D, data);
setFilter(minFilter, magFilter);
setWrap(uWrap, vWrap);
Gdx.gl.glBindTexture(glTarget, 0);
}
use of com.badlogic.gdx.utils.GdxRuntimeException in project libgdx by libgdx.
the class Texture method reload.
/** Used internally to reload after context loss. Creates a new GL handle then calls {@link #load(TextureData)}. Use this only
* if you know what you do! */
@Override
protected void reload() {
if (!isManaged())
throw new GdxRuntimeException("Tried to reload unmanaged Texture");
glHandle = Gdx.gl.glGenTexture();
load(data);
}
use of com.badlogic.gdx.utils.GdxRuntimeException in project libgdx by libgdx.
the class Mesh method calculateRadiusSquared.
/** Calculates the squared radius of the bounding sphere around the specified center for the specified part.
* @param centerX The X coordinate of the center of the bounding sphere
* @param centerY The Y coordinate of the center of the bounding sphere
* @param centerZ The Z coordinate of the center of the bounding sphere
* @param offset the start index of the part.
* @param count the amount of indices the part contains.
* @return the squared radius of the bounding sphere. */
public float calculateRadiusSquared(final float centerX, final float centerY, final float centerZ, int offset, int count, final Matrix4 transform) {
int numIndices = getNumIndices();
if (offset < 0 || count < 1 || offset + count > numIndices)
throw new GdxRuntimeException("Not enough indices");
final FloatBuffer verts = vertices.getBuffer();
final ShortBuffer index = indices.getBuffer();
final VertexAttribute posAttrib = getVertexAttribute(Usage.Position);
final int posoff = posAttrib.offset / 4;
final int vertexSize = vertices.getAttributes().vertexSize / 4;
final int end = offset + count;
float result = 0;
switch(posAttrib.numComponents) {
case 1:
for (int i = offset; i < end; i++) {
final int idx = index.get(i) * vertexSize + posoff;
tmpV.set(verts.get(idx), 0, 0);
if (transform != null)
tmpV.mul(transform);
final float r = tmpV.sub(centerX, centerY, centerZ).len2();
if (r > result)
result = r;
}
break;
case 2:
for (int i = offset; i < end; i++) {
final int idx = index.get(i) * vertexSize + posoff;
tmpV.set(verts.get(idx), verts.get(idx + 1), 0);
if (transform != null)
tmpV.mul(transform);
final float r = tmpV.sub(centerX, centerY, centerZ).len2();
if (r > result)
result = r;
}
break;
case 3:
for (int i = offset; i < end; i++) {
final int idx = index.get(i) * vertexSize + posoff;
tmpV.set(verts.get(idx), verts.get(idx + 1), verts.get(idx + 2));
if (transform != null)
tmpV.mul(transform);
final float r = tmpV.sub(centerX, centerY, centerZ).len2();
if (r > result)
result = r;
}
break;
}
return result;
}
Aggregations