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

Screen is reversed by 180 degree on old Android devices [GLES3] #17083

Closed
Solvero opened this issue Feb 27, 2018 · 14 comments
Closed

Screen is reversed by 180 degree on old Android devices [GLES3] #17083

Solvero opened this issue Feb 27, 2018 · 14 comments

Comments

@Solvero
Copy link

Solvero commented Feb 27, 2018

Godot version:
3.0.0 and 3.0.1

OS/device including version:
Manjaro Linux
Xperia T3 (D5103), Android 4.4.4

Issue description:
When game is exported to Android, displayed screen is rotated by 180 deg.
This affects only image. Touch screen seems to work correctly.
For example:
When I put a button at top-left corner of the screen it is visible at bottom-right corner.
To press the button I still have to touch top-left corner.

Steps to reproduce:
The following problem appeared to me when stable 3.0 was released.
It worked fine on alpha versions.

Minimal reproduction project:
test.zip

@Solvero Solvero changed the title Screen is reversed by 180 deegre Screen is reversed by 180 degree Feb 27, 2018
@Solvero Solvero changed the title Screen is reversed by 180 degree Screen is reversed by 180 degree on android Feb 27, 2018
@Solvero
Copy link
Author

Solvero commented Mar 7, 2018

The following problem still exists on version 3.0.2 on Xperia T3.
I have performed test on different phone (Moto G5S Android 7.1.1) and it works fine there.

@ChrisWhatever1980
Copy link

I encountered the same problem with Godot 3.0.2 on a Samsung S4 with Android 4.4.2.
Tried setting handheld orientation to reverse_landscape, which just rotated the problem 180 degrees.
Maybe caused by older android versions?
TouchButtonTest.zip

@ChrisWhatever1980
Copy link

I have helped myself with a workaround (see attached sample as well):

  1. set orientation in project settings to reverse_landscape
  2. Put TouchScreenButton into new scene and invert touch position in _input:
    if event is InputEventScreenTouch:
        var resolution = Vector2(
            ProjectSettings.get_setting("display/window/size/width"),
            ProjectSettings.get_setting("display/window/size/height"))
        #switch the following two lines to test on PC
        #var pos = event.get_position()
        var pos = Vector2(resolution.x - event.get_position().x, resolution.y - event.get_position().y)
        var ori = get_global_transform().get_origin()
        var dim = normal.get_size() * get_global_transform().get_scale()
        var rect = Rect2(ori, dim)
        if rect.has_point(pos):
            if event.pressed:
                emit_signal("ButtonPressed", self)
            else:
                emit_signal("ButtonReleased", self)

TouchButtonWorkaround.zip

@Solvero
Copy link
Author

Solvero commented Apr 20, 2018

Yes... I'm afraid that old Android causes problem.
Nice workaround 😃. it solves button touchScreenButton.
However reverse_landscape screen causes that Android bar is at the bottom of the screen instead of top.

@MednauN
Copy link
Contributor

MednauN commented May 28, 2018

Confirmed this problem on
Redmi Note 3 (Android 5.0.2)
Asus ZenPad 10 P01T (Android 5.0.1)

I tried to do some research on the problem, here is what I found out:

  1. The problem appears only on some devices.
  2. Actually, the screen rotation here should be handled by the OS. And it's being handled, but somehow fails.
  3. The layout and native controls are rotated just fine, the problem lies within GLSurfaceView.
  4. When I tried to render something inside GodotView "by hand" using GLES 2.0 API, the rotation started to work for the entire scene. I assume, it may be related to poor GLES 3.0 support by these devices. Maybe, something is not refreshed correctly and draw call from GLES 2.0 API forces the refresh.

So I added the rendering of an invisible triangle inside Renderer class in GodotView.java and it did the trick for me. Another weird bug and even more weird fix. ¯\(ツ)

Here is my code, if someone wants to use it:

//GodotView.java:663
private static class Renderer implements GLSurfaceView.Renderer {

	float[] verticesData = { 2.0f, 0.5f, 0.0f, -0.5f, 1.5f, 0.0f, 2.5f, -0.5f, 0.0f };
	FloatBuffer vertices = ByteBuffer.allocateDirect(verticesData.length * 4)
			.order(ByteOrder.nativeOrder()).asFloatBuffer().put(verticesData);

	public void onDrawFrame(GL10 gl) {
		vertices.position(0);
		GLES20.glVertexAttribPointer(0, 3, GLES20.GL_FLOAT, false, 0, vertices);
		GLES20.glEnableVertexAttribArray(0);
		GLES20.glDrawArrays(GLES20.GL_TRIANGLES, 0, 3);
		// The rest of onDrawFrame

UPD:

GLES20.glClear(GLES20.GL_DEPTH_BUFFER_BIT);

Instead of drawing triangle seems to work too

@wrbeck
Copy link

wrbeck commented Jun 5, 2018

I can confirm the issue: screen renders 180 degrees oposite to the touch controls on HTC M8, running android 5
Upshot is that performance is way smoother than on my 6 year old iMac. And export worked so easy and fast. Kudos to Godot; just need to fix this layout issue.

@robertiancu
Copy link

will be fixed this bug in next release?

@akien-mga akien-mga added this to the 3.1 milestone Aug 15, 2018
@reduz
Copy link
Member

reduz commented Sep 6, 2018

Can you try using the GLES2 renderer?

@ghost
Copy link

ghost commented Sep 7, 2018

Using the GLES2 renderer option in the latest build solved the problem for me, tested on a LG G2.

@Solvero
Copy link
Author

Solvero commented Sep 8, 2018

Yes, GLES2 works fine

@DDru
Copy link

DDru commented Nov 6, 2018

Hello. I has same problem in Godot 3.0.6 / 3.1 alpha_2 and Samsung s3

@akien-mga akien-mga changed the title Screen is reversed by 180 degree on android Screen is reversed by 180 degree on old Android devices [GLES3] Jan 20, 2019
@akien-mga
Copy link
Member

It appears to be fixed with GLES2, so it's not critical for Godot 3.1. If someone can find a fix for those devices on GLES3 that would be great, but low priority given that the GLES3 renderer is going to be replaced by the Vulkan renderer.

@akien-mga akien-mga modified the milestones: 3.1, 3.2 Jan 20, 2019
@akien-mga
Copy link
Member

As per the above, the recommended workaround for such devices would be to use the GLES2 renderer. As such I'll close this issue as the GLES3 renderer will be replaced in 4.0, so this issue is unlikely to be fixed (a PR is still welcome if anyone wants to fix it in GLES3 for a 3.2.x release).

@joined72
Copy link
Contributor

@MednauN I need to fix this issue on 4.2.1 compatibility render (take a look here), can you help me explaining how you fixed it, please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests