OpenMW on android flipped textures

Everything about development and the OpenMW source code.
xyzz
Posts: 42
Joined: 14 Jan 2018, 22:25

OpenMW on android flipped textures

Post by xyzz » 15 Jan 2018, 01:43

Hello,

I've been updating the android port and rewriting the build system, it almost works now but there's two problems I'm not sure how to approach:

1) the textures in main menu are flipped: https://i.imgur.com/YcfgX7x.jpg

2) the text looks broken https://i.imgur.com/ggWeHyi.jpg

would appreciate any help
Last edited by xyzz on 15 Jan 2018, 14:19, edited 1 time in total.

User avatar
psi29a
Posts: 4040
Joined: 29 Sep 2011, 10:13
Github profile: https://github.com/psi29a/
Contact:

Re: OpenMW on android flipped textures

Post by psi29a » 15 Jan 2018, 07:34

First things first, OpenMW, agreed not to show any images of Morrowind running on Android. So I'm going to edit your post to remove the image instead of showing it. Please use a 3rd party image hosting service and just place a link instead of showing the image. :)

Where is your branch on github so people can follow along? :)

It's possible that we'll have to do some tests in some areas to see if the system is android or not and load the images accordingly.

I would help test, but I need to setup a android dev environment to investigate further.

xyzz
Posts: 42
Joined: 14 Jan 2018, 22:25

Re: OpenMW on android flipped textures

Post by xyzz » 15 Jan 2018, 14:30

Thanks for your reply psi29a, I've edited the post to fix the images.

All my changes are in these 3 repos: https://github.com/xyzz/android-port, https://github.com/xyzz/openmw/tree/android and https://github.com/xyzz/osg/tree/android-support (I already pull-requested that one here https://github.com/OpenMW/osg/pull/10)

If you want to follow along, you just need to clone my fork of android-port and follow the README, I tried to make it easy to build even for people who have never done Android dev before - the only thing you should need to install is Android Studio (the scripts only work on Linux though).

The paths are hardcoded now, so you need to place all your files to /sdcard/mw/:

Code: Select all

shell@SGP611:/ $ ls -la /sdcard/mw/                                            
drwxrwx--x root     sdcard_rw          2018-01-14 17:51 Data Files # This one can be anywhere, just specify it in config
-rw-rw---- root     sdcard_rw    33842 2018-01-14 18:09 openmw.cfg # Full file from a working installation with fallback lines, edited to specify data= and resources= lines
drwxrwx--x root     sdcard_rw          2018-01-14 00:07 resources # Same as data files can be anywhere
-rw-rw---- root     sdcard_rw    15510 2018-01-14 21:24 settings-default.cfg
(Right now there's no exception support so any exception thrown will crash the program immediately, which is a real pain)

Hope that helps, let me know if that works for you.

User avatar
scrawl
Posts: 2152
Joined: 18 Feb 2012, 11:51
Contact:

Re: OpenMW on android flipped textures

Post by scrawl » 15 Jan 2018, 18:58

Hello and welcome.

I think your problem 2 is the same as the first one - the font gets baked to, then rendered from, a texture; rendering it upside down will garble the text.

It looks like only the GUI textures are upside down, whereas the world is fine. I would suggest looking in 'myguirendermanager.cpp' which is where we tie the GUI to OpenGL (and OSG). In particular this code here is supposed to flip textures to their correct orientation:

Code: Select all

        // need to flip tex coords since MyGUI uses DirectX convention of top left image origin
        osg::Matrix flipMat;
        flipMat.preMultTranslate(osg::Vec3f(0,1,0));
        flipMat.preMultScale(osg::Vec3f(1,-1,1));
        mStateSet->setTextureAttribute(0, new osg::TexMat(flipMat), osg::StateAttribute::ON);
Last I looked at the android port, IIRC it was using a translation layer from OpenGL to OpenGLES to make things work. Possibly that layer has problems handling texture matrices? If that is the case, you should also see issues with e.g. waterfalls in vivec not animating.

Long term, I would think it'd be better to use OpenGLES natively instead of using a wrapper. Now that we support shaders (which wasn't the case last time), part of the work to migrating to GLES2 or GLES3 is already done, too. However, we still use fixed function state inside the shaders so that would still need to be managed, plus there is the sky which doesn't support shaders yet. Interestingly, there is some work in upstream OSG in the 'shader_pipeline' branch that aims to emulate the fixed pipeline in a shader. I'm not sure how finished that is, though.
Or you could try GLES1 as the easier (yet less future-proof) path.

Regarding your issues on github,
1. the char / unsigned char is IIRC already fixed upstream, if this is the case then for a cleaner history we should cherry pick their commit or rebase the fork top of the new version. Can you check?
2. the crash with glGetVersion might be the symptom of another issue, like calling OpenGL from the wrong thread maybe?

xyzz
Posts: 42
Joined: 14 Jan 2018, 22:25

Re: OpenMW on android flipped textures

Post by xyzz » 15 Jan 2018, 20:06

Thanks for the pointer to myguirendermanager, I'll take a look at it.

My port isn't using the opengl translation layer, it's using GLESv1 and that happens to mostly work as you can see.

If osg is committed to supporting glesv2 or glesv3 that's also fine, it should work alright on android devices. (And yeah I noticed some fixed pipeline constants being used somewhere in openmw when I tried to compile OSG with glesv2).

As for the issues:
1 - you're right, I'll update my pull request to cherry pick upstream's commit instead of doing it myself
2 - definitely, that's what Android also barks at in the adb logcat, I could try investigating the issue but it seems fairly minor as it's only getGLVersionNumber thing that's called from a different thread - looked like some feature-detection. When patched with the static thing, there are no longer any warning messages in adb console so I assume there's no any other invalid usages.

User avatar
psi29a
Posts: 4040
Joined: 29 Sep 2011, 10:13
Github profile: https://github.com/psi29a/
Contact:

Re: OpenMW on android flipped textures

Post by psi29a » 15 Jan 2018, 21:55

This has interesting implications for RPi as well and other armel/armhf where we wanted to use -lgl but instead got forced into -lglesv1 because that was what Qt4/5 was compiled against on Debian and Ubuntu.

Is it possible that your fork could be generic enough to work on armel/armhf and not just android?

xyzz
Posts: 42
Joined: 14 Jan 2018, 22:25

Re: OpenMW on android flipped textures

Post by xyzz » 15 Jan 2018, 22:06

I'm not sure I understand, how that would help you to use -lgl if I'm using GLESv1?

xyzz
Posts: 42
Joined: 14 Jan 2018, 22:25

Re: OpenMW on android flipped textures

Post by xyzz » 15 Jan 2018, 22:18

I've tried commenting out that code in myguirendermanager.cpp and this makes videos, loading images flipped vertically but does nothing to text or main menu.

edit: it seems inventory images are flipped regardless of me commenting out this code

edit2: I also confirmed your guess about font being the same issue as flipped texture, flipping the font in software makes it display correctly. not sure what the real problem is though, maybe buggy drivers?

User avatar
sandstranger
Posts: 436
Joined: 19 May 2014, 19:53
Location: Oblivion

Re: OpenMW on android flipped textures

Post by sandstranger » 16 Jan 2018, 07:07

d
Last edited by sandstranger on 18 Jan 2018, 16:33, edited 2 times in total.

User avatar
sandstranger
Posts: 436
Joined: 19 May 2014, 19:53
Location: Oblivion

Re: OpenMW on android flipped textures

Post by sandstranger » 16 Jan 2018, 07:34

d
Last edited by sandstranger on 18 Jan 2018, 16:33, edited 2 times in total.

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests