8000 Problems with LibGdxGraphics.drawStage(Stage stage). · Issue #85 · mini2Dx/mini2Dx · GitHub
[go: up one dir, main page]

Skip to content
  • Problems with LibGdxGraphics.drawStage(Stage stage). #85

    Open

    Description

    @jacynkaa

    It renders mirror reflection of stage (comparing to stage.draw()) . I believe it is because Stage has a coordinate system where (0,0) is at the bottom-left while LibGdxGraphics have usual coordinate system (where (0,0) is in the Top Left Corner).

    I have tried this:
    Camera camera= new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    camera.setToOrtho(true, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    stage = gc.createStage(new ScreenViewport(camera));

    But it didn't work out. I guess it is because LibGdxGraphics.drawStage(Stage stage) uses its own camera:

    Camera stageCamera = stage.getViewport().getCamera();
    stageCamera.up.set(0, -1, 0);
    stageCamera.direction.set(0, 0, 1);
    stageCamera.update();

    Any ideas how to solve this?

    imageedit_1_2832504376

    Activity

    1. tomcashman commented on Apr 19, 2019

      @tomcashman
      Contributor

      What version are you using?

    2. jacynkaa commented on Apr 20, 2019

      @jacynkaa
      Author

      mini2DxVersion = '1.8.2'
      gdxVersion = '1.9.6'

      I also tried switching mini2DxVersion to 1.7 but it didn't help.

    3. tomcashman commented on Apr 20, 2019

      @tomcashman
      Contributor

      Unfortunately this is due to how we interact with LibGDX and how LibGDX handles the orthographic view and texture U/V values. I'm hoping to fix this in the 2.0 release in the future when I restructure a lot of the internal code.

      The easiest workaround I can suggest is to create a org.mini2Dx.core.graphics.TextureRegion (which extends the LibGDX TextureRegion) and pass that to your stage actors.

    4. jacynkaa commented on Apr 20, 2019

      @jacynkaa
      Author

      How should I do that if I use skin?

      TextButton button= new TextButton("text",skin,"default");

    5. tomcashman commented on Apr 20, 2019

      @tomcashman
      Contributor

      Looks like this is a lot messier than I thought. LibGDX scene 2D always assumes the bottom left of the screen is 0,0 but mini2Dx assumes it is top-left of the screen (to match Slick2D).

      I can change the code so that mini2Dx doesn't manipulate the scene camera but this means the 0,0 graphics coordinates in the scene will be at the bottom left.

      Another workaround is to flip your image in an image editor.

      Just an FYI that 2.0 will de-couple from LibGDX to allow for consoles support. This means that from 2.0 onwards it'll be recommended to not use LibGDX APIs directly (though it will still be allowed). I'm planning to simplify mini2Dx's UI library to work with a Scene2D-like API. I'm hoping to have a beta of 2.0 by August. More info can be found here

    6. jacynkaa commented on Apr 20, 2019

      @jacynkaa
      Author

      OK I have just commented out these three lines in LibGdxGraphics.drawStage and it seems to work:

      stageCamera.up.set(0, -1, 0);
      stageCamera.direction.set(0, 0, 1);
      stageCamera.update();
      

      Thanks for help!

    7. tomcashman commented on Apr 20, 2019

      @tomcashman
      Contributor

      I'll remove them in next update then XD

    8. added
      mini2Dx-ve
      on Jun 5, 2019
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      mini2Dx-ve

      Type

      No type

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions

      • 0