Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with LibGdxGraphics.drawStage(Stage stage). #85

Open
jacynkaa opened this issue Apr 19, 2019 · 7 comments
Open

Problems with LibGdxGraphics.drawStage(Stage stage). #85

jacynkaa opened this issue Apr 19, 2019 · 7 comments
Labels
mini2Dx-ve Issues related to mini2Dx-ve

Comments

@jacynkaa
Copy link

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

@tomcashman
Copy link
Contributor

What version are you using?

@jacynkaa
Copy link
Author

mini2DxVersion = '1.8.2'
gdxVersion = '1.9.6'

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

@tomcashman
Copy link
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.

@jacynkaa
Copy link
Author

jacynkaa commented Apr 20, 2019

How should I do that if I use skin?

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

@tomcashman
Copy link
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

@jacynkaa
Copy link
Author

jacynkaa commented Apr 20, 2019

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!

@tomcashman
Copy link
Contributor

I'll remove them in next update then XD

@tomcashman tomcashman added the mini2Dx-ve Issues related to mini2Dx-ve label Jun 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mini2Dx-ve Issues related to mini2Dx-ve
Projects
None yet
Development

No branches or pull requests

2 participants