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);
}
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"));
}
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);
}
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;
}
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;
}
Aggregations