use of com.badlogic.gdx.utils.GdxRuntimeException in project libgdx by libgdx.
the class JglfwTestStarter method runTest.
/** Runs the {@link GdxTest} with the given name.
* @param testName the name of a test class
* @return {@code true} if the test was found and run, {@code false} otherwise */
public static JglfwApplication runTest(String testName) {
final GdxTest test = GdxTests.newTest(testName);
if (test == null)
throw new GdxRuntimeException("Test not found: " + testName);
final JglfwApplicationConfiguration config = new JglfwApplicationConfiguration();
config.width = 640;
config.height = 480;
config.title = testName;
config.forceExit = false;
return new JglfwApplication(test, config);
}
use of com.badlogic.gdx.utils.GdxRuntimeException in project RubeLoader by tescott.
the class RubeLoaderTest method testSceneSettings.
/**
* Validation on custom settings in the RUBE file.
*
*/
private void testSceneSettings() {
//
// validate the custom settings attached to world object..
//
boolean testBool = (Boolean) mScene.getCustom(mWorld, "testCustomBool", false);
int testInt = (Integer) mScene.getCustom(mWorld, "testCustomInt", 0);
float testFloat = (Float) mScene.getCustom(mWorld, "testCustomFloat", 0);
Color color = (Color) mScene.getCustom(mWorld, "testCustomColor", null);
Vector2 vec = (Vector2) mScene.getCustom(mWorld, "testCustomVec2", null);
String string = (String) mScene.getCustom(mWorld, "testCustomString", null);
int bodies1Custom = (Integer) mScene.getCustom(mWorld, "bodies1Custom", 0);
int bodies2Custom = (Integer) mScene.getCustom(mWorld, "bodies2Custom", 0);
int bodiesCommonCustom = (Integer) mScene.getCustom(mWorld, "bodiesCommonCustom", 0);
// validate multiple file reading...
if (mRubeFileList == 1) {
if (bodies1Custom != 1) {
throw new GdxRuntimeException("bodies1Custom not read correctly! Expected: " + 1 + " Actual: " + bodies1Custom);
}
if (bodies2Custom != 2) {
throw new GdxRuntimeException("bodies2Custom not read correctly! Expected: " + 2 + " Actual: " + bodies2Custom);
}
// this is common between two files, but the last value will hold...
if (bodiesCommonCustom != 4321) {
throw new GdxRuntimeException("bodiesCommonCustom not read correctly! Expected: " + 4321 + " Actual: " + bodiesCommonCustom);
}
System.out.println("Multiple file testing: PASSED!");
}
if (testBool == false) {
throw new GdxRuntimeException("testCustomBool not read correctly! Expected: " + true + " Actual: " + testBool);
}
if (testInt != 8675309) {
throw new GdxRuntimeException("testCustomInt not read correctly! Expected: " + 8675309 + " Actual: " + testInt);
}
if (testFloat != 1.25f) {
throw new GdxRuntimeException("testCustomFloat not read correctly! Expected: " + 1.25f + " Actual: " + testFloat);
}
if (color == null) {
throw new GdxRuntimeException("testCustomColor is reporting null!");
}
if ((color.r != 17f / 255) || (color.g != 29f / 255) || (color.b != 43f / 255) || (color.a != 61f / 255)) {
throw new GdxRuntimeException("testCustomColor not read correctly! Expected: " + new Color(17f / 255, 29f / 255, 43f / 255, 61f / 255) + " Actual: " + color);
}
if (vec == null) {
throw new GdxRuntimeException("testCustomVec2 is reporting null!");
}
if ((vec.x != 314159) || (vec.y != 21718)) {
throw new GdxRuntimeException("testCustomVec2 is not read correctly! Expected: " + new Vector2(314159, 21718) + " Actual: " + vec);
}
if (string == null) {
throw new GdxRuntimeException("testCustomString is reporting null!");
}
if (!string.equalsIgnoreCase("excelsior!")) {
throw new GdxRuntimeException("testCustomString is not read correctly! Expected: Excelsior! Actual: " + string);
}
System.out.println("*** TESTING PASSED ***");
}
use of com.badlogic.gdx.utils.GdxRuntimeException in project libgdx by libgdx.
the class ETC1TextureData method prepare.
@Override
public void prepare() {
if (isPrepared)
throw new GdxRuntimeException("Already prepared");
if (file == null && data == null)
throw new GdxRuntimeException("Can only load once from ETC1Data");
if (file != null) {
data = new ETC1Data(file);
}
width = data.width;
height = data.height;
isPrepared = true;
}
use of com.badlogic.gdx.utils.GdxRuntimeException in project libgdx by libgdx.
the class FileTextureArrayData method prepare.
@Override
public void prepare() {
int width = -1;
int height = -1;
for (TextureData data : textureDatas) {
data.prepare();
if (width == -1) {
width = data.getWidth();
height = data.getHeight();
continue;
}
if (width != data.getWidth() || height != data.getHeight()) {
throw new GdxRuntimeException("Error whilst preparing TextureArray: TextureArray Textures must have equal dimensions.");
}
}
prepared = true;
}
use of com.badlogic.gdx.utils.GdxRuntimeException in project libgdx by libgdx.
the class ModelBuilder method end.
/** End building the model.
* @return The newly created model. Call the {@link Model#dispose()} method when no longer used. */
public Model end() {
if (model == null)
throw new GdxRuntimeException("Call begin() first");
final Model result = model;
endnode();
model = null;
for (final MeshBuilder mb : builders) mb.end();
builders.clear();
rebuildReferences(result);
return result;
}
Aggregations