Search in sources :

Example 11 with GdxRuntimeException

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);
}
Also used : GdxRuntimeException(com.badlogic.gdx.utils.GdxRuntimeException) JglfwApplication(com.badlogic.gdx.backends.jglfw.JglfwApplication) GdxTest(com.badlogic.gdx.tests.utils.GdxTest) JglfwApplicationConfiguration(com.badlogic.gdx.backends.jglfw.JglfwApplicationConfiguration)

Example 12 with GdxRuntimeException

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 ***");
}
Also used : GdxRuntimeException(com.badlogic.gdx.utils.GdxRuntimeException) Vector2(com.badlogic.gdx.math.Vector2) Color(com.badlogic.gdx.graphics.Color)

Example 13 with GdxRuntimeException

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;
}
Also used : GdxRuntimeException(com.badlogic.gdx.utils.GdxRuntimeException) ETC1Data(com.badlogic.gdx.graphics.glutils.ETC1.ETC1Data)

Example 14 with GdxRuntimeException

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;
}
Also used : GdxRuntimeException(com.badlogic.gdx.utils.GdxRuntimeException) TextureData(com.badlogic.gdx.graphics.TextureData)

Example 15 with GdxRuntimeException

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;
}
Also used : GdxRuntimeException(com.badlogic.gdx.utils.GdxRuntimeException) Model(com.badlogic.gdx.graphics.g3d.Model)

Aggregations

GdxRuntimeException (com.badlogic.gdx.utils.GdxRuntimeException)202 IOException (java.io.IOException)40 FileHandle (com.badlogic.gdx.files.FileHandle)14 Array (com.badlogic.gdx.utils.Array)13 Texture (com.badlogic.gdx.graphics.Texture)12 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)11 AtlasRegion (com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion)9 InputStream (java.io.InputStream)9 Pixmap (com.badlogic.gdx.graphics.Pixmap)8 Sprite (com.badlogic.gdx.graphics.g2d.Sprite)8 TextureAtlas (com.badlogic.gdx.graphics.g2d.TextureAtlas)7 AtlasSprite (com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasSprite)7 BufferedInputStream (java.io.BufferedInputStream)7 File (java.io.File)7 OutputStream (java.io.OutputStream)7 VertexAttribute (com.badlogic.gdx.graphics.VertexAttribute)6 LifecycleListener (com.badlogic.gdx.LifecycleListener)5 ByteBuffer (java.nio.ByteBuffer)5 BitmapFont (com.badlogic.gdx.graphics.g2d.BitmapFont)4 NinePatch (com.badlogic.gdx.graphics.g2d.NinePatch)4