Author Topic: Texture wrapping works in emulator but not on device (Galaxy S5)  (Read 4321 times)

Offline spookey

  • byte
  • *
  • Posts: 8
    • View Profile
Texture wrapping works in emulator but not on device (Galaxy S5)
« on: November 22, 2015, 10:44:33 am »
Hi all,

I have a project where the user just flies around a textured .OBJ object, and everything works well in the emulator, but when I run it on the device, all textures behave as if I had set setClamping() to true.  It must be a clamping/wrapping issue because when I use setClamping(true) on all textures, the results are identical on the emulator and the device. But the model needs the wrapped textures and I don't know how to enforce this on the device.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Texture wrapping works in emulator but not on device (Galaxy S5)
« Reply #1 on: November 22, 2015, 11:07:36 am »
Shouldn't happen and I've never heard of anything like it. Have you tried it on another device? Do you have a test case for this?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Texture wrapping works in emulator but not on device (Galaxy S5)
« Reply #2 on: November 22, 2015, 11:17:46 am »
....and which version of jPCT-AE are you using?

Offline spookey

  • byte
  • *
  • Posts: 8
    • View Profile
Re: Texture wrapping works in emulator but not on device (Galaxy S5)
« Reply #3 on: November 22, 2015, 11:42:38 am »
I'll be able to test on another device in a few hours. I use the latest version, I even downloaded it again this morning. There are no other problems with the texturing - they all load fine and if I use calcTextureWrap() or calcTextureSphere() it works. All textures are 256x256.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Texture wrapping works in emulator but not on device (Galaxy S5)
« Reply #4 on: November 22, 2015, 12:36:20 pm »
Really strange. If it doesn't work on the other device as well, I need a test case. If it does, you might want to try to play around with texture settings on the S5 (like enabling/disabling mipmaps, 16bit color, etc compression...).

Offline spookey

  • byte
  • *
  • Posts: 8
    • View Profile
Re: Texture wrapping works in emulator but not on device (Galaxy S5)
« Reply #5 on: November 22, 2015, 04:37:30 pm »
So I tested it on a Galaxy S3 mini and it works. Where are the texture settings in jPCT or do I need to make explicit OpenGL calls?  I tried inserting this before world.renderScene(fb) but it didn't help:

GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_REPEAT);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_REPEAT);


Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Texture wrapping works in emulator but not on device (Galaxy S5)
« Reply #6 on: November 22, 2015, 04:47:14 pm »
No, you are not supposed to make explicit GL calls. What you have there is basically what jPCT-AE does anyway. I've no idea, why it fails on the S5. I've never heard of any problems with the S5, so I'm quite puzzled by this. It uses an Adreno GPU...I've multiple devices with Adreno GPUs and none shows auch a behaviour.
A few more questions: Which Android version are you using? Samsung's or some custom ROM? I've had issues with some of the 'optimizations' in custom ROMs before, hence the question.
And which OpenGL version are you using? If it's 1.x, try 2.0 instead and see if that helps.

Offline spookey

  • byte
  • *
  • Posts: 8
    • View Profile
Re: Texture wrapping works in emulator but not on device (Galaxy S5)
« Reply #7 on: November 22, 2015, 05:01:22 pm »
I use Samsung's Android (5.0) and I have installed every update that came so far. But it does have some strange behavior lately, such as the default keyboard mysteriously resetting to Samsung's keyboard and there's a facebook virus that redirects Chrome. Could this be related? I'll try again after a factory reset.

Offline spookey

  • byte
  • *
  • Posts: 8
    • View Profile
Re: Texture wrapping works in emulator but not on device (Galaxy S5)
« Reply #8 on: November 22, 2015, 05:02:42 pm »
The OpenGL version is 2.0. I actually use jPCT-AE with Google Cardboard's API.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Texture wrapping works in emulator but not on device (Galaxy S5)
« Reply #9 on: November 22, 2015, 05:04:06 pm »
I don't think that it's related, but you never know.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Texture wrapping works in emulator but not on device (Galaxy S5)
« Reply #10 on: November 22, 2015, 05:05:14 pm »
Have you tried how it behaves without cardboard API? Can you create a minimal test case that shows the issue?

Offline spookey

  • byte
  • *
  • Posts: 8
    • View Profile
Re: Texture wrapping works in emulator but not on device (Galaxy S5)
« Reply #11 on: November 22, 2015, 06:18:37 pm »
I made a test case without the Cardboard API, but it worked. So the API must be causing the problem, but it works with Cardboard on the S3.. I'll try a few things and will let you know what happened.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Texture wrapping works in emulator but not on device (Galaxy S5)
« Reply #12 on: November 22, 2015, 06:26:51 pm »
That's strange, because the repeat mode is bound to the texture. Once uploaded, I don't see how it can be changed by some other API. FrameBuffer has a prewarm-method, that uploads all textures know to the TextureManager at once. Maybe it's worth a try to call that in onSurfaceChanged right after the texture loading.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Texture wrapping works in emulator but not on device (Galaxy S5)
« Reply #13 on: November 22, 2015, 06:30:19 pm »
....sorry, TextureManager has that method, or course. Not FrameBuffer...

Offline spookey

  • byte
  • *
  • Posts: 8
    • View Profile
Re: Texture wrapping works in emulator but not on device (Galaxy S5)
« Reply #14 on: November 22, 2015, 06:57:28 pm »
This is the test case that demonstrates the issue. It's a textured castle (it takes a while to load because it's big). This should display correctly in the emulator but not on the S5. But if you change the code to not use Cardboard, the problem disappears. https://dl.dropboxusercontent.com/u/1608884/testcase.zip