2

The game I'm developing renders perfectly on the Java backend and on IE 10. However the rendering on Chrome and Android is weird. I'd assume this was because of WebGL & OpenGL respectively. Here's how it looks on IE. IE

Here's how it looks on Chrome, and it looks exactly same on the Android backend as well. Chrome

The background did not get rendered, and only the first and last text elements got rendered

Are the any restrictions on texture size etc when running in Chrome and Android, anything in particular I have to take care of? All my textures have dimensions the power of 2s. I even tried creating every surface with dimensions the power of 2s, but it doesn't seem to help.

Update: I fixed the following issue. It was due to a bug in the UI toolkit I had written, where a new surface was getting created every time a widget's text was set.

I'm not sure if the following problem is related, but sometimes the game crashes on Android with the following exception:

03-16 14:22:29.010 E/AndroidRuntime(16253): FATAL EXCEPTION: GLThread 10
03-16 14:22:29.010 E/AndroidRuntime(16253): java.lang.StackOverflowError
03-16 14:22:29.010 E/AndroidRuntime(16253):     at playn.android.AndroidPlatform.log(AndroidPlatform.java:28)
03-16 14:22:29.010 E/AndroidRuntime(16253):     at playn.core.PlayN.log(PlayN.java:120)
......
......
......
playn.core.gl.GLContext$Pender.process(GLContext.java:242)
03-16 14:22:29.010 E/AndroidRuntime(16253):     at playn.core.gl.GLContext$Pender.process(GLContext.java:242)
03-16 14:22:29.010 E/AndroidRuntime(16253):     at playn.core.gl.GLContext$Pender.process(GLContext.j

This is because at http://code.google.com/p/playn/source/browse/core/src/playn/core/gl/GLContext.java, GLContext$Pender.process() seems to be called in a never ending cycle. This doesn't happen every time, though.

BlueSilver
  • 1,052
  • 2
  • 10
  • 25
  • 4
    `java.lang.StackOverflowError` ...looks like you came to the right place for help ;) – Jeremy Harris Mar 18 '12 at 02:27
  • Some 512x512, and some 1024x1024. My phone is a Samsung Galaxy R, and I'm pretty sure it's capable of those texture sizes. – BlueSilver Mar 18 '12 at 02:36
  • Can you post the code anywhere? I think your code is probably doing something like creating one or more textures and leaving them for garbage on every frame. The pending processing can't infinite loop, so you must just be queuing up incredibly large numbers of textures to be freed all at once. – samskivert Mar 18 '12 at 18:30
  • @samskivert That is probably the case. I will try to post a concise version of my code. However that occurs only when the actual game is in progress, and it doesn't occur when the UI is displayed. However the UI rendering is still faulty (Missing background, most text not drawn). I noticed that in the samples, textures are not even sized to powers of 2, and they work great on my phone. Any idea why? My game looks perfectly OK on the Java backend as well as on IE 10. – BlueSilver Mar 19 '12 at 14:21
  • 1
    PlayN automatically converts texture sizes to power of two as needed. – samskivert Mar 19 '12 at 17:38
  • I fixed the StackOverflow exception. Multiple textures were getting created every frame due to a UI toolkit bug. The weird rendering problem still remains. – BlueSilver Mar 19 '12 at 22:13
  • @samskivert Please see my answer. One side-effect of my approach - copying over regions of images from a sprite sheet, is that PlayN can't automatically restore my surfaces. I attempted to fix this by invalidating all my surfaces at onResume() so that all widgets redraw themselves at the next paint() call. However this produces weird rendering artifacts. Maybe paint() is called too soon when it's not possible to redraw? How can I work around this? – BlueSilver Mar 20 '12 at 08:34

1 Answers1

0

I was looking at the TriplePlay library's source code when it occurred to me that I can draw images only in paint(). I used to copy portions of images from a spritesheet to different widgets. The copying was done during widget creation which typically occurred in response to a touch event. When I switched the image copying to inside paint(), it started working perfectly.

BlueSilver
  • 1,052
  • 2
  • 10
  • 25