use of com.badlogic.gdx.graphics.FPSLogger in project libgdx by libgdx.
the class EdgeDetectionTest method create.
public void create() {
ShaderProgram.pedantic = false;
/*
* shader = new ShaderProgram(Gdx.files.internal("data/shaders/default.vert").readString(), Gdx.files.internal(
* "data/shaders/depthtocolor.frag").readString()); if (!shader.isCompiled()) { Gdx.app.log("EdgeDetectionTest",
* "couldn't compile scene shader: " + shader.getLog()); }
*/
batchShader = new ShaderProgram(Gdx.files.internal("data/shaders/batch.vert").readString(), Gdx.files.internal("data/shaders/convolution.frag").readString());
if (!batchShader.isCompiled()) {
Gdx.app.log("EdgeDetectionTest", "couldn't compile post-processing shader: " + batchShader.getLog());
}
ObjLoader objLoader = new ObjLoader();
scene = objLoader.loadModel(Gdx.files.internal("data/scene.obj"));
sceneInstance = new ModelInstance(scene);
modelBatch = new ModelBatch();
fbo = new FrameBuffer(Format.RGB565, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), true);
cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
cam.position.set(0, 0, 10);
cam.lookAt(0, 0, 0);
cam.far = 30;
batch = new SpriteBatch();
batch.setShader(batchShader);
fboRegion = new TextureRegion(fbo.getColorBufferTexture());
fboRegion.flip(false, true);
logger = new FPSLogger();
calculateOffsets();
}
use of com.badlogic.gdx.graphics.FPSLogger in project libgdx by libgdx.
the class AnimationTest method create.
@Override
public void create() {
texture = new Texture(Gdx.files.internal("data/walkanim.png"));
TextureRegion[] leftWalkFrames = TextureRegion.split(texture, 64, 64)[0];
TextureRegion[] rightWalkFrames = new TextureRegion[leftWalkFrames.length];
for (int i = 0; i < rightWalkFrames.length; i++) {
TextureRegion frame = new TextureRegion(leftWalkFrames[i]);
frame.flip(true, false);
rightWalkFrames[i] = frame;
}
leftWalk = new Animation<TextureRegion>(0.25f, leftWalkFrames);
rightWalk = new Animation<TextureRegion>(0.25f, rightWalkFrames);
cavemen = new Caveman[100];
for (int i = 0; i < 100; i++) {
cavemen[i] = new Caveman((float) Math.random() * Gdx.graphics.getWidth(), (float) Math.random() * Gdx.graphics.getHeight(), Math.random() > 0.5 ? true : false);
}
batch = new SpriteBatch();
fpsLog = new FPSLogger();
}
use of com.badlogic.gdx.graphics.FPSLogger in project libgdx by libgdx.
the class Lwjgl3DebugStarter method main.
public static void main(String[] argv) throws NoSuchFieldException, SecurityException, ClassNotFoundException {
GdxTest test = new GdxTest() {
float r = 0;
SpriteBatch batch;
BitmapFont font;
FPSLogger fps = new FPSLogger();
Texture texture;
@Override
public void create() {
BufferedImage image = new BufferedImage(10, 10, BufferedImage.TYPE_4BYTE_ABGR);
texture = new Texture("data/badlogic.jpg");
batch = new SpriteBatch();
font = new BitmapFont();
Gdx.input.setInputProcessor(new InputAdapter() {
@Override
public boolean keyDown(int keycode) {
System.out.println("Key down: " + Keys.toString(keycode));
return false;
}
@Override
public boolean keyUp(int keycode) {
System.out.println("Key up: " + Keys.toString(keycode));
return false;
}
@Override
public boolean keyTyped(char character) {
System.out.println("Key typed: '" + character + "', " + (int) character);
if (character == 'f') {
Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode());
// DisplayMode[] modes = Gdx.graphics.getDisplayModes();
// for(DisplayMode mode: modes) {
// if(mode.width == 1920 && mode.height == 1080) {
// Gdx.graphics.setFullscreenMode(mode);
// break;
// }
// }
}
if (character == 'w') {
Gdx.graphics.setWindowedMode(MathUtils.random(400, 800), MathUtils.random(400, 800));
}
if (character == 'e') {
throw new GdxRuntimeException("derp");
}
if (character == 'c') {
Gdx.input.setCursorCatched(!Gdx.input.isCursorCatched());
}
Lwjgl3Window window = ((Lwjgl3Graphics) Gdx.graphics).getWindow();
if (character == 'v') {
window.setVisible(false);
}
if (character == 's') {
window.setVisible(true);
}
if (character == 'q') {
window.closeWindow();
}
if (character == 'i') {
window.iconifyWindow();
}
if (character == 'm') {
window.maximizeWindow();
}
if (character == 'r') {
window.restoreWindow();
}
if (character == 'u') {
Gdx.net.openURI("https://google.com");
}
return false;
}
});
}
long start = System.nanoTime();
@Override
public void render() {
Gdx.gl.glClearColor(1, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
HdpiUtils.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
batch.getProjectionMatrix().setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
batch.begin();
font.draw(batch, Gdx.graphics.getWidth() + "x" + Gdx.graphics.getHeight() + ", " + Gdx.graphics.getBackBufferWidth() + "x" + Gdx.graphics.getBackBufferHeight() + ", " + Gdx.input.getX() + ", " + Gdx.input.getY() + ", " + Gdx.input.getDeltaX() + ", " + Gdx.input.getDeltaY(), 0, 20);
batch.draw(texture, Gdx.input.getX(), Gdx.graphics.getHeight() - Gdx.input.getY());
batch.end();
fps.log();
}
@Override
public void resize(int width, int height) {
Gdx.app.log("Test", "Resized " + width + "x" + height);
}
@Override
public void resume() {
Gdx.app.log("Test", "resuming");
}
@Override
public void pause() {
Gdx.app.log("Test", "pausing");
}
@Override
public void dispose() {
Gdx.app.log("Test", "disposing");
}
};
Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
config.setWindowedMode(640, 480);
config.setWindowListener(new Lwjgl3WindowListener() {
@Override
public void iconified(boolean isIconified) {
Gdx.app.log("Window", "iconified: " + (isIconified ? "true" : "false"));
}
@Override
public void maximized(boolean isMaximized) {
Gdx.app.log("Window", "maximized: " + (isMaximized ? "true" : "false"));
}
@Override
public void focusLost() {
Gdx.app.log("Window", "focus lost");
}
@Override
public void focusGained() {
Gdx.app.log("Window", "focus gained");
}
@Override
public boolean closeRequested() {
Gdx.app.log("Window", "closing");
return false;
}
@Override
public void filesDropped(String[] files) {
for (String file : files) {
Gdx.app.log("Window", "File dropped: " + file);
}
}
@Override
public void refreshRequested() {
Gdx.app.log("Window", "refreshRequested");
}
});
for (DisplayMode mode : Lwjgl3ApplicationConfiguration.getDisplayModes()) {
System.out.println(mode.width + "x" + mode.height);
}
System.setProperty("java.awt.headless", "true");
new Lwjgl3Application(test, config);
}
use of com.badlogic.gdx.graphics.FPSLogger in project nhglib by VoidZombie.
the class Main method engineStarted.
@Override
public void engineStarted() {
super.engineStarted();
Nhg.debugLogs = true;
Gdx.input.setCursorCatched(true);
world = new NhgWorld(nhg.messaging, nhg.entities, nhg.assets, new DefaultWorldStrategy(), new Bounds(2f, 2f, 2f));
fpsLogger = new FPSLogger();
renderer20 = new ImmediateModeRenderer20(false, true, 0);
nhg.input.addListener(this);
nhg.assets.queueAsset(new Asset("scene", "myscene.nhs", Scene.class));
nhg.assets.queueAsset(new Asset("inputMap", "input.nhc", JsonValue.class));
GraphicsSystem graphicsSystem = nhg.entities.getEntitySystem(GraphicsSystem.class);
graphicsSystem.setClearColor(Color.GRAY);
Environment environment = graphicsSystem.getEnvironment();
GammaCorrectionAttribute gammaCorrectionAttribute = new GammaCorrectionAttribute();
gammaCorrectionAttribute.gammaCorrection = true;
environment.set(gammaCorrectionAttribute);
// Subscribe to asset events
nhg.messaging.get(Strings.Events.assetLoaded, Strings.Events.assetLoadingFinished).subscribe(new Consumer<Message>() {
@Override
public void accept(Message message) throws Exception {
if (message.is(Strings.Events.assetLoaded)) {
Asset asset = (Asset) message.data.get(Strings.Defaults.assetKey);
if (asset.is("scene")) {
scene = nhg.assets.get(asset);
world.loadScene(scene);
world.setReferenceEntity("camera");
ModelBuilder mb = new ModelBuilder();
Model planeModel = mb.createBox(2f, 0.01f, 20f, new Material(), VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal | VertexAttributes.Usage.TextureCoordinates);
int plane = scene.sceneGraph.createSceneEntity("plane");
scene.sceneGraph.addSceneEntity(plane);
ModelComponent modelComponent = nhg.entities.createComponent(plane, ModelComponent.class);
modelComponent.initWithModel(planeModel);
NodeComponent nodeComponent = nhg.entities.getComponent(plane, NodeComponent.class);
nodeComponent.setTranslation(0, 0, 0, true);
Integer cameraEntity = scene.sceneGraph.getSceneEntity("camera");
cameraNode = nhg.entities.getComponent(cameraEntity, NodeComponent.class);
} else if (asset.is("inputMap")) {
nhg.input.fromJson((JsonValue) nhg.assets.get(asset));
nhg.input.setActiveContext("game", true);
nhg.input.setActiveContext("global", true);
}
}
}
});
}
Aggregations