Search in sources :

Example 1 with GLProfiler

use of com.badlogic.gdx.graphics.profiling.GLProfiler in project OpenCiv by rhin123.

the class Civilization method create.

@Override
public void create() {
    Gdx.app.setLogLevel(Application.LOG_INFO);
    LOGGER.info("Starting Game...");
    if (DEBUG_GL) {
        profiler = new GLProfiler(Gdx.graphics);
    }
    assetHandler = new AssetHandler();
    eventManager = new EventManager();
    screenManager = new ScreenManager();
    networkManager = new NetworkManager();
    fontHandler = new FontHandler();
    gameOptions = new GameOptions();
    instance = this;
    soundHandler = new SoundHandler();
    chatHandler = new ChatHandler();
    screenManager.setScreen(ScreenEnum.LOADING);
}
Also used : GLProfiler(com.badlogic.gdx.graphics.profiling.GLProfiler) ScreenManager(me.rhin.openciv.ui.screen.ScreenManager) EventManager(me.rhin.openciv.shared.listener.EventManager) GameOptions(me.rhin.openciv.options.GameOptions) SoundHandler(me.rhin.openciv.asset.sound.SoundHandler) ChatHandler(me.rhin.openciv.networking.chat.ChatHandler) AssetHandler(me.rhin.openciv.asset.AssetHandler) NetworkManager(me.rhin.openciv.networking.NetworkManager) FontHandler(me.rhin.openciv.ui.font.FontHandler)

Example 2 with GLProfiler

use of com.badlogic.gdx.graphics.profiling.GLProfiler in project gdx-graph by MarcinSc.

the class ReloadableGraphTestApplication method enableProfiler.

private void enableProfiler() {
    profiler = new GLProfiler(Gdx.graphics);
    profiler.enable();
    profileSkin = new Skin(Gdx.files.classpath("skin/default/uiskin.json"));
    profileStage = new Stage();
    profileLabel = new Label("", profileSkin);
    Table tbl = new Table(profileSkin);
    tbl.setFillParent(true);
    tbl.align(Align.topRight);
    tbl.add(profileLabel).pad(10f);
    tbl.row();
    profileStage.addActor(tbl);
    profile = true;
}
Also used : GLProfiler(com.badlogic.gdx.graphics.profiling.GLProfiler) Table(com.badlogic.gdx.scenes.scene2d.ui.Table) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) Stage(com.badlogic.gdx.scenes.scene2d.Stage) Skin(com.badlogic.gdx.scenes.scene2d.ui.Skin)

Example 3 with GLProfiler

use of com.badlogic.gdx.graphics.profiling.GLProfiler in project textratypist by tommyettinger.

the class TypingUITest method create.

@Override
public void create() {
    profiler = new GLProfiler(Gdx.graphics);
    profiler.enable();
    skin = new Skin(Gdx.files.internal("uiskin2.json"));
    texture1 = new Texture(Gdx.files.internal("badlogicsmall.jpg"));
    texture2 = new Texture(Gdx.files.internal("badlogic.jpg"));
    TextureRegion image = new TextureRegion(texture1);
    TextureRegion imageFlipped = new TextureRegion(image);
    imageFlipped.flip(true, true);
    TextureRegion image2 = new TextureRegion(texture2);
    // stage = new Stage(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false, new PolygonSpriteBatch());
    stage = new Stage(new ScreenViewport());
    Gdx.input.setInputProcessor(stage);
    // stage.setDebugAll(true);
    ImageButtonStyle style = new ImageButtonStyle(skin.get(ButtonStyle.class));
    style.imageUp = new TextureRegionDrawable(image);
    style.imageDown = new TextureRegionDrawable(imageFlipped);
    ImageButton iconButton = new ImageButton(style);
    Button buttonMulti = new TextButton("Multi\nLine\nToggle", skin, "toggle");
    Button imgButton = new Button(new Image(image), skin);
    Button imgToggleButton = new Button(new Image(image), skin, "toggle");
    TypingLabel myLabel = new TypingLabel("This is some text.", skin);
    Table t = new Table();
    t.row();
    t.add(myLabel);
    t.layout();
    final TextraCheckBox checkBox = new TextraCheckBox(" Continuous rendering", skin);
    checkBox.setChecked(true);
    final Slider slider = new Slider(0, 10, 1, false, skin);
    slider.setAnimateDuration(0.3f);
    TextField textfield = new TextField("", skin);
    textfield.setMessageText("Click here!");
    textfield.setAlignment(Align.center);
    final SelectBox<String> selectBox = new SelectBox<>(skin);
    selectBox.setAlignment(Align.right);
    selectBox.getList().setAlignment(Align.right);
    selectBox.getStyle().listStyle.selection.setRightWidth(10);
    selectBox.getStyle().listStyle.selection.setLeftWidth(20);
    selectBox.addListener(new ChangeListener() {

        public void changed(ChangeEvent event, Actor actor) {
            System.out.println(selectBox.getSelected());
        }
    });
    selectBox.setItems("Android1", "Windows1 long text in item", "Linux1", "OSX1", "Android2", "Windows2", "Linux2", "OSX2", "Android3", "Windows3", "Linux3", "OSX3", "Android4", "Windows4", "Linux4", "OSX4", "Android5", "Windows5", "Linux5", "OSX5", "Android6", "Windows6", "Linux6", "OSX6", "Android7", "Windows7", "Linux7", "OSX7");
    selectBox.setSelected("Linux6");
    Image imageActor = new Image(image2);
    ScrollPane scrollPane = new ScrollPane(imageActor);
    List<String> list = new List<>(skin);
    list.setItems(listEntries);
    list.getSelection().setMultiple(true);
    list.getSelection().setRequired(false);
    // list.getSelection().setToggle(true);
    ScrollPane scrollPane2 = new ScrollPane(list, skin);
    scrollPane2.setFlickScroll(false);
    // demos SplitPane respecting widget's minWidth
    TypingLabel minSizeLabel = new TypingLabel("minWidth cell", skin);
    Table rightSideTable = new Table(skin);
    rightSideTable.add(minSizeLabel).growX().row();
    rightSideTable.add(scrollPane2).grow();
    SplitPane splitPane = new SplitPane(scrollPane, rightSideTable, false, skin, "default-horizontal");
    fpsLabel = new TypingLabel("fps: 0    [^][SKY][[citation needed]", skin);
    fpsLabel.setAlignment(Align.topLeft);
    // configures an example of a TextField in password mode.
    final TypingLabel passwordLabel = new TypingLabel("Textfield in [~]secure[] password mode: ", skin);
    final TextField passwordTextField = new TextField("", skin);
    passwordTextField.setMessageText("password");
    passwordTextField.setPasswordCharacter('*');
    passwordTextField.setPasswordMode(true);
    buttonMulti.addListener(new TextraTooltip("This is a tooltip! This is a tooltip! This is a tooltip! This is a tooltip! This is a tooltip! This is a tooltip!", skin));
    Table tooltipTable = new Table(skin);
    tooltipTable.pad(10).background("default-round");
    tooltipTable.add(new TextButton("Fancy tooltip!", skin));
    imgButton.addListener(new Tooltip<>(tooltipTable));
    // window.debug();
    TextraWindow window = new TextraWindow("TextraDialog", skin);
    window.getTitleTable().add(new TextButton("X", skin)).height(window.getPadTop());
    window.setPosition(0, 0);
    window.defaults().spaceBottom(10);
    window.row().fill().expandX();
    window.add(iconButton);
    window.add(buttonMulti);
    window.add(imgButton);
    window.add(imgToggleButton);
    window.row();
    window.add(checkBox);
    window.add(slider).minWidth(100).fillX().colspan(3);
    window.row();
    window.add(selectBox).maxWidth(100);
    window.add(textfield).minWidth(100).expandX().fillX().colspan(3);
    window.row();
    window.add(splitPane).fill().expand().colspan(4).maxHeight(200);
    window.row();
    window.add(passwordLabel).align(Align.topLeft).colspan(2);
    window.add(passwordTextField).minWidth(100).expandX().fillX().colspan(2);
    window.row();
    window.add(fpsLabel).align(Align.topLeft).colspan(4);
    window.pack();
    // stage.addActor(new Button("Behind Window", skin));
    stage.addActor(window);
    textfield.setTextFieldListener(new TextFieldListener() {

        public void keyTyped(TextField textField, char key) {
            if (key == '\n')
                textField.getOnscreenKeyboard().show(false);
        }
    });
    slider.addListener(new ChangeListener() {

        public void changed(ChangeEvent event, Actor actor) {
            Gdx.app.log("UITest", "slider: " + slider.getValue());
        }
    });
    iconButton.addListener(new ChangeListener() {

        public void changed(ChangeEvent event, Actor actor) {
            new TextraDialog("Some TextraDialog", skin, "dialog") {

                protected void result(Object object) {
                    System.out.println("Chosen: " + object);
                }
            }.text("Are you enjoying this demo?").button("Yes", true).button("No", false).key(Keys.ENTER, true).key(Keys.ESCAPE, false).show(stage);
        }
    });
    checkBox.addListener(new ChangeListener() {

        public void changed(ChangeEvent event, Actor actor) {
            Gdx.graphics.setContinuousRendering(checkBox.isChecked());
        }
    });
}
Also used : TextureRegionDrawable(com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable) Texture(com.badlogic.gdx.graphics.Texture) TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) Actor(com.badlogic.gdx.scenes.scene2d.Actor) Stage(com.badlogic.gdx.scenes.scene2d.Stage) ImageButtonStyle(com.badlogic.gdx.scenes.scene2d.ui.ImageButton.ImageButtonStyle) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) TextFieldListener(com.badlogic.gdx.scenes.scene2d.ui.TextField.TextFieldListener) ButtonStyle(com.badlogic.gdx.scenes.scene2d.ui.Button.ButtonStyle) ImageButtonStyle(com.badlogic.gdx.scenes.scene2d.ui.ImageButton.ImageButtonStyle) GLProfiler(com.badlogic.gdx.graphics.profiling.GLProfiler) ScreenViewport(com.badlogic.gdx.utils.viewport.ScreenViewport)

Example 4 with GLProfiler

use of com.badlogic.gdx.graphics.profiling.GLProfiler in project textratypist by tommyettinger.

the class RafaTypingUITest method create.

@Override
public void create() {
    profiler = new GLProfiler(Gdx.graphics);
    profiler.enable();
    skin = new Skin(Gdx.files.internal("uiskin2.json"));
    texture1 = new Texture(Gdx.files.internal("badlogicsmall.jpg"));
    texture2 = new Texture(Gdx.files.internal("badlogic.jpg"));
    TextureRegion image = new TextureRegion(texture1);
    TextureRegion imageFlipped = new TextureRegion(image);
    imageFlipped.flip(true, true);
    TextureRegion image2 = new TextureRegion(texture2);
    // stage = new Stage(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false, new PolygonSpriteBatch());
    stage = new Stage(new ScreenViewport());
    Gdx.input.setInputProcessor(stage);
    // stage.setDebugAll(true);
    ImageButtonStyle style = new ImageButtonStyle(skin.get(ButtonStyle.class));
    style.imageUp = new TextureRegionDrawable(image);
    style.imageDown = new TextureRegionDrawable(imageFlipped);
    ImageButton iconButton = new ImageButton(style);
    Button buttonMulti = new TextButton("Multi\nLine\nToggle", skin, "toggle");
    Button imgButton = new Button(new Image(image), skin);
    Button imgToggleButton = new Button(new Image(image), skin, "toggle");
    com.rafaskoberg.gdx.typinglabel.TypingLabel myLabel = new com.rafaskoberg.gdx.typinglabel.TypingLabel("This is some text.", skin);
    Table t = new Table();
    t.row();
    t.add(myLabel);
    t.layout();
    final CheckBox checkBox = new CheckBox(" Continuous rendering", skin);
    checkBox.setChecked(true);
    final Slider slider = new Slider(0, 10, 1, false, skin);
    slider.setAnimateDuration(0.3f);
    TextField textfield = new TextField("", skin);
    textfield.setMessageText("Click here!");
    textfield.setAlignment(Align.center);
    final SelectBox<String> selectBox = new SelectBox<>(skin);
    selectBox.setAlignment(Align.right);
    selectBox.getList().setAlignment(Align.right);
    selectBox.getStyle().listStyle.selection.setRightWidth(10);
    selectBox.getStyle().listStyle.selection.setLeftWidth(20);
    selectBox.addListener(new ChangeListener() {

        public void changed(ChangeEvent event, Actor actor) {
            System.out.println(selectBox.getSelected());
        }
    });
    selectBox.setItems("Android1", "Windows1 long text in item", "Linux1", "OSX1", "Android2", "Windows2", "Linux2", "OSX2", "Android3", "Windows3", "Linux3", "OSX3", "Android4", "Windows4", "Linux4", "OSX4", "Android5", "Windows5", "Linux5", "OSX5", "Android6", "Windows6", "Linux6", "OSX6", "Android7", "Windows7", "Linux7", "OSX7");
    selectBox.setSelected("Linux6");
    Image imageActor = new Image(image2);
    ScrollPane scrollPane = new ScrollPane(imageActor);
    List<String> list = new List<>(skin);
    list.setItems(listEntries);
    list.getSelection().setMultiple(true);
    list.getSelection().setRequired(false);
    // list.getSelection().setToggle(true);
    ScrollPane scrollPane2 = new ScrollPane(list, skin);
    scrollPane2.setFlickScroll(false);
    // demos SplitPane respecting widget's minWidth
    com.rafaskoberg.gdx.typinglabel.TypingLabel minSizeLabel = new com.rafaskoberg.gdx.typinglabel.TypingLabel("minWidth cell", skin);
    Table rightSideTable = new Table(skin);
    rightSideTable.add(minSizeLabel).growX().row();
    rightSideTable.add(scrollPane2).grow();
    SplitPane splitPane = new SplitPane(scrollPane, rightSideTable, false, skin, "default-horizontal");
    fpsLabel = new com.rafaskoberg.gdx.typinglabel.TypingLabel("fps: {VAR=fps}", skin);
    fpsLabel.setAlignment(Align.topLeft);
    // configures an example of a TextField in password mode.
    final com.rafaskoberg.gdx.typinglabel.TypingLabel passwordLabel = new com.rafaskoberg.gdx.typinglabel.TypingLabel("Textfield in [~]secure[] password mode: ", skin);
    final TextField passwordTextField = new TextField("", skin);
    passwordTextField.setMessageText("password");
    passwordTextField.setPasswordCharacter('*');
    passwordTextField.setPasswordMode(true);
    buttonMulti.addListener(new TextTooltip("This is a tooltip! This is a tooltip! This is a tooltip! This is a tooltip! This is a tooltip! This is a tooltip!", skin));
    Table tooltipTable = new Table(skin);
    tooltipTable.pad(10).background("default-round");
    tooltipTable.add(new TextButton("Fancy tooltip!", skin));
    imgButton.addListener(new Tooltip<>(tooltipTable));
    // window.debug();
    Window window = new Window("Dialog", skin);
    window.getTitleTable().add(new TextButton("X", skin)).height(window.getPadTop());
    window.setPosition(0, 0);
    window.defaults().spaceBottom(10);
    window.row().fill().expandX();
    window.add(iconButton);
    window.add(buttonMulti);
    window.add(imgButton);
    window.add(imgToggleButton);
    window.row();
    window.add(checkBox);
    window.add(slider).minWidth(100).fillX().colspan(3);
    window.row();
    window.add(selectBox).maxWidth(100);
    window.add(textfield).minWidth(100).expandX().fillX().colspan(3);
    window.row();
    window.add(splitPane).fill().expand().colspan(4).maxHeight(200);
    window.row();
    window.add(passwordLabel).align(Align.topLeft).colspan(2);
    window.add(passwordTextField).minWidth(100).expandX().fillX().colspan(2);
    window.row();
    window.add(fpsLabel).align(Align.topLeft).colspan(4);
    window.pack();
    // stage.addActor(new Button("Behind Window", skin));
    stage.addActor(window);
    textfield.setTextFieldListener(new TextFieldListener() {

        public void keyTyped(TextField textField, char key) {
            if (key == '\n')
                textField.getOnscreenKeyboard().show(false);
        }
    });
    slider.addListener(new ChangeListener() {

        public void changed(ChangeEvent event, Actor actor) {
            Gdx.app.log("UITest", "slider: " + slider.getValue());
        }
    });
    iconButton.addListener(new ChangeListener() {

        public void changed(ChangeEvent event, Actor actor) {
            new Dialog("Some Dialog", skin, "dialog") {

                protected void result(Object object) {
                    System.out.println("Chosen: " + object);
                }
            }.text("Are you enjoying this demo?").button("Yes", true).button("No", false).key(Keys.ENTER, true).key(Keys.ESCAPE, false).show(stage);
        }
    });
    checkBox.addListener(new ChangeListener() {

        public void changed(ChangeEvent event, Actor actor) {
            Gdx.graphics.setContinuousRendering(checkBox.isChecked());
        }
    });
}
Also used : TextureRegionDrawable(com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable) Texture(com.badlogic.gdx.graphics.Texture) TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) Actor(com.badlogic.gdx.scenes.scene2d.Actor) Stage(com.badlogic.gdx.scenes.scene2d.Stage) ImageButtonStyle(com.badlogic.gdx.scenes.scene2d.ui.ImageButton.ImageButtonStyle) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) TextFieldListener(com.badlogic.gdx.scenes.scene2d.ui.TextField.TextFieldListener) ButtonStyle(com.badlogic.gdx.scenes.scene2d.ui.Button.ButtonStyle) ImageButtonStyle(com.badlogic.gdx.scenes.scene2d.ui.ImageButton.ImageButtonStyle) GLProfiler(com.badlogic.gdx.graphics.profiling.GLProfiler) ScreenViewport(com.badlogic.gdx.utils.viewport.ScreenViewport)

Example 5 with GLProfiler

use of com.badlogic.gdx.graphics.profiling.GLProfiler in project gdx-gltf by mgsx-dev.

the class GLTFDemo method create.

@Override
public void create() {
    GLProfiler profiler = new GLProfiler(Gdx.graphics);
    profiler.setListener(new GLErrorListener() {

        @Override
        public void onError(int error) {
            Gdx.app.error("OpenGL", String.valueOf(error));
        }
    });
    profiler.enable();
    assetManager = new AssetManager();
    Texture.setAssetManager(assetManager);
    assetManager.setLoader(SceneAsset.class, ".gltf", new GLTFAssetLoader());
    assetManager.setLoader(SceneAsset.class, ".glb", new GLBAssetLoader());
    shapeRenderer = new ShapeRenderer();
    spriteBatch = new SpriteBatch();
    createSceneManager();
    // boot from a model index file or an empty scene.
    if (samplesPath != null) {
        rootFolder = Gdx.files.internal(samplesPath);
        createUI();
        loadModelIndex();
    } else {
        createUI();
        loadEmptyScene();
    }
}
Also used : GLBAssetLoader(net.mgsx.gltf.loaders.glb.GLBAssetLoader) GLProfiler(com.badlogic.gdx.graphics.profiling.GLProfiler) AssetManager(com.badlogic.gdx.assets.AssetManager) GLTFAssetLoader(net.mgsx.gltf.loaders.gltf.GLTFAssetLoader) GLErrorListener(com.badlogic.gdx.graphics.profiling.GLErrorListener) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) ShapeRenderer(com.badlogic.gdx.graphics.glutils.ShapeRenderer)

Aggregations

GLProfiler (com.badlogic.gdx.graphics.profiling.GLProfiler)11 Stage (com.badlogic.gdx.scenes.scene2d.Stage)5 ScreenViewport (com.badlogic.gdx.utils.viewport.ScreenViewport)5 Texture (com.badlogic.gdx.graphics.Texture)4 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)4 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)4 Actor (com.badlogic.gdx.scenes.scene2d.Actor)4 TextFieldListener (com.badlogic.gdx.scenes.scene2d.ui.TextField.TextFieldListener)4 ChangeListener (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)4 TextureRegionDrawable (com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable)4 ButtonStyle (com.badlogic.gdx.scenes.scene2d.ui.Button.ButtonStyle)3 ImageButtonStyle (com.badlogic.gdx.scenes.scene2d.ui.ImageButton.ImageButtonStyle)3 FitViewport (com.badlogic.gdx.utils.viewport.FitViewport)3 TinyVGShapeDrawer (dev.lyze.gdxtinyvg.drawers.TinyVGShapeDrawer)3 AssetManager (com.badlogic.gdx.assets.AssetManager)1 Camera (com.badlogic.gdx.graphics.Camera)1 OrthographicCamera (com.badlogic.gdx.graphics.OrthographicCamera)1 PerspectiveCamera (com.badlogic.gdx.graphics.PerspectiveCamera)1 ShapeRenderer (com.badlogic.gdx.graphics.glutils.ShapeRenderer)1 GLErrorListener (com.badlogic.gdx.graphics.profiling.GLErrorListener)1