use of com.badlogic.gdx.utils.GdxRuntimeException in project libgdx by libgdx.
the class AndroidLiveWallpaper method initialize.
public void initialize(ApplicationListener listener, AndroidApplicationConfiguration config) {
if (this.getVersion() < MINIMUM_SDK) {
throw new GdxRuntimeException("LibGDX requires Android API Level " + MINIMUM_SDK + " or later.");
}
setApplicationLogger(new AndroidApplicationLogger());
graphics = new AndroidGraphicsLiveWallpaper(this, config, config.resolutionStrategy == null ? new FillResolutionStrategy() : config.resolutionStrategy);
// factory in use, but note: AndroidInputFactory causes exceptions when obfuscated: java.lang.RuntimeException: Couldn't
// construct AndroidInput, this should never happen, proguard deletes constructor used only by reflection
input = AndroidInputFactory.newAndroidInput(this, this.getService(), graphics.view, config);
// input = new AndroidInput(this, this.getService(), null, config);
audio = new AndroidAudio(this.getService(), config);
// added initialization of android local storage: /data/data/<app package>/files/
// workaround for Android bug #10515463
this.getService().getFilesDir();
files = new AndroidFiles(this.getService().getAssets(), this.getService().getFilesDir().getAbsolutePath());
net = new AndroidNet(this);
this.listener = listener;
clipboard = new AndroidClipboard(this.getService());
// Unlike activity, fragment and daydream applications there's no need for a specialized audio listener.
// See description in onPause method.
Gdx.app = this;
Gdx.input = input;
Gdx.audio = audio;
Gdx.files = files;
Gdx.graphics = graphics;
Gdx.net = net;
}
use of com.badlogic.gdx.utils.GdxRuntimeException in project libgdx by libgdx.
the class Lwjgl3Cursor method setSystemCursor.
static void setSystemCursor(long windowHandle, SystemCursor systemCursor) {
Long glfwCursor = systemCursors.get(systemCursor);
if (glfwCursor == null) {
long handle = 0;
if (systemCursor == SystemCursor.Arrow) {
handle = GLFW.glfwCreateStandardCursor(GLFW.GLFW_ARROW_CURSOR);
} else if (systemCursor == SystemCursor.Crosshair) {
handle = GLFW.glfwCreateStandardCursor(GLFW.GLFW_CROSSHAIR_CURSOR);
} else if (systemCursor == SystemCursor.Hand) {
handle = GLFW.glfwCreateStandardCursor(GLFW.GLFW_HAND_CURSOR);
} else if (systemCursor == SystemCursor.HorizontalResize) {
handle = GLFW.glfwCreateStandardCursor(GLFW.GLFW_HRESIZE_CURSOR);
} else if (systemCursor == SystemCursor.VerticalResize) {
handle = GLFW.glfwCreateStandardCursor(GLFW.GLFW_VRESIZE_CURSOR);
} else if (systemCursor == SystemCursor.Ibeam) {
handle = GLFW.glfwCreateStandardCursor(GLFW.GLFW_IBEAM_CURSOR);
} else {
throw new GdxRuntimeException("Unknown system cursor " + systemCursor);
}
if (handle == 0) {
return;
}
glfwCursor = handle;
systemCursors.put(systemCursor, glfwCursor);
}
GLFW.glfwSetCursor(windowHandle, glfwCursor);
}
use of com.badlogic.gdx.utils.GdxRuntimeException in project libgdx by libgdx.
the class OpenALAudioDevice method writeSamples.
public void writeSamples(byte[] data, int offset, int length) {
if (length < 0)
throw new IllegalArgumentException("length cannot be < 0.");
if (sourceID == -1) {
sourceID = audio.obtainSource(true);
if (sourceID == -1)
return;
if (buffers == null) {
buffers = BufferUtils.createIntBuffer(bufferCount);
alGenBuffers(buffers);
if (alGetError() != AL_NO_ERROR)
throw new GdxRuntimeException("Unabe to allocate audio buffers.");
}
alSourcei(sourceID, AL_LOOPING, AL_FALSE);
alSourcef(sourceID, AL_GAIN, volume);
// Fill initial buffers.
int queuedBuffers = 0;
for (int i = 0; i < bufferCount; i++) {
int bufferID = buffers.get(i);
int written = Math.min(bufferSize, length);
tempBuffer.clear();
tempBuffer.put(data, offset, written).flip();
alBufferData(bufferID, format, tempBuffer, sampleRate);
alSourceQueueBuffers(sourceID, bufferID);
length -= written;
offset += written;
queuedBuffers++;
}
// Queue rest of buffers, empty.
tempBuffer.clear().flip();
for (int i = queuedBuffers; i < bufferCount; i++) {
int bufferID = buffers.get(i);
alBufferData(bufferID, format, tempBuffer, sampleRate);
alSourceQueueBuffers(sourceID, bufferID);
}
alSourcePlay(sourceID);
isPlaying = true;
}
while (length > 0) {
int written = fillBuffer(data, offset, length);
length -= written;
offset += written;
}
}
use of com.badlogic.gdx.utils.GdxRuntimeException in project libgdx by libgdx.
the class GwtGL20 method glReadPixels.
@Override
public void glReadPixels(int x, int y, int width, int height, int format, int type, Buffer pixels) {
// verify request
if ((format != WebGLRenderingContext.RGBA) || (type != WebGLRenderingContext.UNSIGNED_BYTE)) {
throw new GdxRuntimeException("Only format RGBA and type UNSIGNED_BYTE are currently supported for glReadPixels(...). Create an issue when you need other formats.");
}
if (!(pixels instanceof ByteBuffer)) {
throw new GdxRuntimeException("Inputed pixels buffer needs to be of type ByteBuffer for glReadPixels(...).");
}
// create new ArrayBufferView (4 bytes per pixel)
int size = 4 * width * height;
Uint8Array buffer = TypedArrays.createUint8Array(((HasArrayBufferView) pixels).getTypedArray().buffer(), 0, size);
// read bytes to ArrayBufferView
gl.readPixels(x, y, width, height, format, type, buffer);
}
use of com.badlogic.gdx.utils.GdxRuntimeException in project libgdx by libgdx.
the class IOSAudio method newMusic.
@Override
public Music newMusic(FileHandle fileHandle) {
String path = fileHandle.file().getPath().replace('\\', '/');
OALAudioTrack track = OALAudioTrack.create();
if (track != null) {
if (track.preloadFile(path)) {
return new IOSMusic(track);
}
}
throw new GdxRuntimeException("Error opening music file at " + path);
}
Aggregations