Author Topic: problem regarding Texture blitting  (Read 453 times)

Offline MichaelJPCT

  • long
  • ***
  • Posts: 140
    • View Profile
problem regarding Texture blitting
« on: June 12, 2016, 08:34:34 am »
i tried to make a small 2D app on Android with JPCT, mainly using Texture blitting to show a background and text font. (i know this is not a normal way to make 2D app, but my java code can be reused)

i made a desktop version of the app with JPCT without problem, but on Android the text doesn't show. the only difference (in my codes) between desktop version and Android version is BitmapFactory is used to load texture on Android.

my texture for font is sized 2048x32.  the JPCT doc says "If a texture with a different width/height is used, it will be scaled to a width/height of 256 automatically" for desktop version, and "If a texture with a different width/height is used, an error will be raised Textures are managed by the TextureManager." for Android version.
but in my desktop app the fonts show clearly, no evidence of the texture being scaled. in my Android app i don't use TextureManager.
strangely, my app uses a 512x1024 texture for background and it shows clearly on both desktop and Android.

i don't know what makes the Android version fail. the test device has 1GB of ram so ram size shouldn't be the cause.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Re: problem regarding Texture blitting
« Reply #1 on: June 12, 2016, 04:54:56 pm »
That scaling/errors mentioned in the docs refer to textures that are not power of 2 in height and/or width. Not to textures with different values for height and width. However, behaviour for these textures isn't properly defined for OpenGL ES, which is why some devices tend to have problems with them. Especially 2048*32 is a strange case. Try to split your texture into smaller ones and see if that helps.

Offline MichaelJPCT

  • long
  • ***
  • Posts: 140
    • View Profile
Re: problem regarding Texture blitting
« Reply #2 on: June 14, 2016, 04:18:43 pm »
i found the cause:
my text class was created in method onCreate() of the main activity. if i put it in method onSurfaceChanged() of MyRenderer class, the text shows. maybe because when onCreate() is called, the viewport size is zero, so my text has zero size.
thanks anyway.