@Override public void render () { Gdx.gl.glClearColor(0.2f, 0.2f, 0.2f, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); batch.begin(); if (makeGlError) { makeGlError = false; try { Gdx.gl.glClear(42); // Random invalid value, will raise GL_INVALID_VALUE (0x501, 1281) } catch (GdxRuntimeException glError) { if ("GLProfiler: Got gl error GL_INVALID_VALUE".equals(glError.getMessage())) { message = "Got expected exception."; } else { message = "Got GdxRuntimeException (correct) but with unexpected message: " + glError.getMessage(); } Gdx.app.log("GLProfilerTest", "Caught exception: ", glError); } } int x = 10; int y = Gdx.graphics.getHeight() - 10; y -= font.draw(batch, "e - Enable debugging\n" + "d - Disable debugging\n" + "l - Test log error listener\n" + "t - Test throw error listener\n" + "c - Test custom listener\n\n" + "Expected error: GL_INVALID_VALUE (0x501, 1281)", x, y).height; y -= 10; font.draw(batch, message, x, y); batch.end(); }
@Override public InputStream openFileAsStream(String fileName) { FileHandle file = Gdx.files.internal(pathPrefix + fileName); if (file == null) throw new IllegalArgumentException("missing file " + fileName); try { return file.read(); } catch (GdxRuntimeException e) { log.debug(e.getMessage()); return null; } }
private void loadMusic(Sounds music) { try { Gdx.app.log(TAG, Gdx.files.internal("music/" + music.name + ".ogg").file().getAbsolutePath()); Music file = Gdx.audio.newMusic(Gdx.files.internal("music/" + music.name + ".ogg")); // If background track, add to playlist if (music.name.toLowerCase().startsWith("background")) backgroundMusicList.add(file); musicMap.put(music.name, file); } catch (GdxRuntimeException e) { Gdx.app.log(TAG, "Error loading musicfile: " + music.name + ": " + e.getMessage()); } }
@Override public void run() { try { if (!EngineAssetManager.getInstance().isLoading()) { cancel(); retrieveAssets(); if (voice != null) voice.play(); } } catch (GdxRuntimeException e) { EngineLogger.error(e.getMessage()); voice = null; fileName = null; textManager.next(); } } };
public void drawShape(AssetManager assetManager, Camera camera, GDXShape shape, Body body, Batch batch, float alpha){ if(shape.getResource().isEmpty()){ Log.debug("GDXRenderer.drawShape", "Resource empty string, not drawing"); return; } Texture texture = null; try{ texture = assetManager.get(shape.getResource()); }catch(GdxRuntimeException e){ Log.error("GDXRenderer.drawShape", e.getMessage() + ", loading " + shape.getResource() + " manually"); texture = getTexture(shape.getResource()); } if(!shape.isRepeatable() && texture != null && body != null){ Sprite sprite = new Sprite(texture); sprite.setScale(SHAPE_SCALE); sprite.setRotation((float)Math.toDegrees(body.getAngle())); sprite.setPosition(body.getPosition().x - texture.getWidth()/2f, body.getPosition().y - texture.getHeight()/2f); if(alpha != 1f) sprite.setAlpha(alpha); sprite.draw(batch); } }