Search in sources :

Example 86 with GdxRuntimeException

use of com.badlogic.gdx.utils.GdxRuntimeException in project libgdx by libgdx.

the class BaseShadowSystem method begin.

@Override
public void begin(int n) {
    if (n >= passShaderProviders.length)
        throw new GdxRuntimeException("Pass " + n + " doesn't exist in " + getClass().getName());
    currentPass = n;
    spotCameraIterator = spotCameras.iterator();
    dirCameraIterator = dirCameras.iterator();
    pointCameraIterator = pointCameras.iterator();
    currentPointSide = 6;
    beginPass(n);
}
Also used : GdxRuntimeException(com.badlogic.gdx.utils.GdxRuntimeException)

Example 87 with GdxRuntimeException

use of com.badlogic.gdx.utils.GdxRuntimeException in project libgdx by libgdx.

the class GwtTest method create.

@Override
public void create() {
    Preferences pref = Gdx.app.getPreferences("test");
    boolean resultb = pref.getBoolean("test");
    int resulti = pref.getInteger("test");
    shader = new ShaderProgram(Gdx.files.internal("data/shaders/shader-vs.glsl"), Gdx.files.internal("data/shaders/shader-fs.glsl"));
    if (!shader.isCompiled())
        throw new GdxRuntimeException(shader.getLog());
    mesh = new Mesh(VertexDataType.VertexBufferObject, true, 6, 0, VertexAttribute.Position(), VertexAttribute.TexCoords(0));
    mesh.setVertices(new float[] { -0.5f, -0.5f, 0, 0, 1, 0.5f, -0.5f, 0, 1, 1, 0.5f, 0.5f, 0, 1, 0, 0.5f, 0.5f, 0, 1, 0, -0.5f, 0.5f, 0, 0, 0, -0.5f, -0.5f, 0, 0, 1 });
    texture = new Texture(new Pixmap(Gdx.files.internal("data/badlogic.jpg")), true);
    texture.setFilter(TextureFilter.MipMap, TextureFilter.Linear);
    String params = Gdx.files.internal("data/gwttestparams.txt").readString();
    numSprites = Integer.parseInt(params);
    batch = new SpriteBatch();
    positions = new ArrayList<Vector2>();
    for (int i = 0; i < numSprites; i++) {
        positions.add(new Vector2(MathUtils.random() * Gdx.graphics.getWidth(), MathUtils.random() * Gdx.graphics.getHeight()));
    }
    sprite = new Sprite(texture);
    sprite.setSize(64, 64);
    sprite.setOrigin(32, 32);
    font = new BitmapFont(Gdx.files.internal("data/arial-15.fnt"), false);
    cache = font.newFontCache();
    cache.setColor(Color.RED);
    cache.setText("This is a Test", 0, 0);
    atlas = new TextureAtlas(Gdx.files.internal("data/pack"));
}
Also used : Sprite(com.badlogic.gdx.graphics.g2d.Sprite) Mesh(com.badlogic.gdx.graphics.Mesh) Texture(com.badlogic.gdx.graphics.Texture) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) GdxRuntimeException(com.badlogic.gdx.utils.GdxRuntimeException) ShaderProgram(com.badlogic.gdx.graphics.glutils.ShaderProgram) Vector2(com.badlogic.gdx.math.Vector2) TextureAtlas(com.badlogic.gdx.graphics.g2d.TextureAtlas) Preferences(com.badlogic.gdx.Preferences) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) Pixmap(com.badlogic.gdx.graphics.Pixmap)

Example 88 with GdxRuntimeException

use of com.badlogic.gdx.utils.GdxRuntimeException in project commons-gdx by gemserk.

the class AnimationFromTextureAtlasResourceBuilder method build.

@Override
public Animation build() {
    TextureAtlas textureAtlas = resourceManager.getResourceValue(textureAtlasId);
    if (sprites == null) {
        try {
            sprites = textureAtlas.createSprites(prefix);
        } catch (GdxRuntimeException e) {
            throw new RuntimeException("Failed to create animation from texture atlas " + textureAtlasId, e);
        }
    }
    if (endFrame == -1)
        endFrame = sprites.size - 1;
    if (startFrame == -1)
        startFrame = 0;
    Sprite[] frames = new Sprite[endFrame - startFrame + 1];
    int frameNumber = startFrame;
    for (int i = 0; i < frames.length; i++) {
        Sprite sprite = sprites.get(frameNumber);
        if (sprite instanceof AtlasSprite)
            frames[i] = new AtlasSprite(((AtlasSprite) sprite).getAtlasRegion());
        else
            frames[i] = new Sprite(sprite);
        frameTransformation.transform(frames[i]);
        frameNumber++;
    }
    int framesCount = frames.length;
    float[] newTimes = new float[framesCount - 1];
    int lastTime = time;
    for (int i = 0; i < framesCount - 1; i++) {
        if (i < times.length) {
            newTimes[i] = ((float) times[i]) * 0.001f;
            lastTime = times[i];
        } else
            newTimes[i] = ((float) lastTime) * 0.001f;
    }
    FrameAnimationImpl frameAnimation = new FrameAnimationImpl(0.001f * (float) time, newTimes);
    frameAnimation.setLoop(loop);
    return new Animation(frames, frameAnimation);
}
Also used : GdxRuntimeException(com.badlogic.gdx.utils.GdxRuntimeException) FrameAnimationImpl(com.gemserk.animation4j.FrameAnimationImpl) GdxRuntimeException(com.badlogic.gdx.utils.GdxRuntimeException) AtlasSprite(com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasSprite) Sprite(com.badlogic.gdx.graphics.g2d.Sprite) TextureAtlas(com.badlogic.gdx.graphics.g2d.TextureAtlas) AtlasSprite(com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasSprite) Animation(com.gemserk.animation4j.gdx.Animation)

Example 89 with GdxRuntimeException

use of com.badlogic.gdx.utils.GdxRuntimeException in project libgdx by libgdx.

the class FileTextureData method consumePixmap.

@Override
public Pixmap consumePixmap() {
    if (!isPrepared)
        throw new GdxRuntimeException("Call prepare() before calling getPixmap()");
    isPrepared = false;
    Pixmap pixmap = this.pixmap;
    this.pixmap = null;
    return pixmap;
}
Also used : GdxRuntimeException(com.badlogic.gdx.utils.GdxRuntimeException) Pixmap(com.badlogic.gdx.graphics.Pixmap)

Example 90 with GdxRuntimeException

use of com.badlogic.gdx.utils.GdxRuntimeException in project libgdx by libgdx.

the class IndexBufferObject method bind.

/** Binds this IndexBufferObject for rendering with glDrawElements. */
public void bind() {
    if (bufferHandle == 0)
        throw new GdxRuntimeException("No buffer allocated!");
    Gdx.gl20.glBindBuffer(GL20.GL_ELEMENT_ARRAY_BUFFER, bufferHandle);
    if (isDirty) {
        byteBuffer.limit(buffer.limit() * 2);
        Gdx.gl20.glBufferData(GL20.GL_ELEMENT_ARRAY_BUFFER, byteBuffer.limit(), byteBuffer, usage);
        isDirty = false;
    }
    isBound = true;
}
Also used : GdxRuntimeException(com.badlogic.gdx.utils.GdxRuntimeException)

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