Strange Rendering behavior for GlSurfaceView

Tutorials concerning the OpenGL® ES cross-platform API for full-function 2D and 3D graphics on the Google-Android platform.

Strange Rendering behavior for GlSurfaceView

Postby Clankrieger » Thu Feb 11, 2010 11:24 pm

Hi,

I have a very strange issue where I don't know what else I could take into account.

My (Game)-Activity running on an Android 1.6 API generates a GlSurfaceView-inherated simple class that does nothing more than creating a renderer and handling touch events. It looks like this:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. public class AndroidGameSurface extends GLSurfaceView {
  3.  
  4.  
  5.  
  6.         public AndroidGameSurface(Context context) {
  7.  
  8.         super(context);
  9.  
  10.         //setDebugFlags(DEBUG_CHECK_GL_ERROR | DEBUG_LOG_GL_CALLS);
  11.  
  12.         mRenderer = new AndroidGameRenderer();
  13.  
  14.         setRenderer(mRenderer);
  15.  
  16.     }
  17.  
  18.  
  19.  
  20.         @Override
  21.  
  22.     public boolean onTouchEvent(final MotionEvent event) {
  23.  
  24.                 queueEvent(new Runnable(){
  25.  
  26.                     public void run() {
  27.  
  28.                         ActualGame.onMotionEvent(event);
  29.  
  30.                     }
  31.  
  32.                 }
  33.  
  34.                 );
  35.  
  36.             return true;
  37.  
  38.         }
  39.  
  40.      
  41.  
  42.         AndroidGameRenderer mRenderer;
  43.  
  44. }
  45.  
  46.  
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


The renderer itself is like hits:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. class AndroidGameRenderer implements GLSurfaceView.Renderer {
  3.  
  4.     public AndroidGameRenderer() {
  5.  
  6.        
  7.  
  8.     }
  9.  
  10.  
  11.  
  12.     public void onDrawFrame(GL10 gl) {
  13.  
  14.         ActualGame.update();
  15.  
  16.         ActualGame.render();
  17.  
  18.     }
  19.  
  20.  
  21.  
  22.     public int[] getConfigSpec() {
  23.  
  24.         // We don't need a depth buffer, and don't care about our
  25.  
  26.         // color depth.
  27.  
  28.         int[] configSpec = {
  29.  
  30.                 EGL10.EGL_DEPTH_SIZE, 0,
  31.  
  32.                 EGL10.EGL_NONE
  33.  
  34.         };
  35.  
  36.         return configSpec;
  37.  
  38.     }
  39.  
  40.  
  41.  
  42.     public void onSurfaceChanged(GL10 gl, int width, int height) {
  43.  
  44.         PlatformGLInterface.sGlInterface = gl;
  45.  
  46.                 try {
  47.  
  48.                         ActualGame.create(true, width, height);
  49.  
  50.                 } catch (Exception e) {
  51.  
  52.                         e.printStackTrace();
  53.  
  54.                 }
  55.  
  56.     }
  57.  
  58.  
  59.  
  60.     public void onSurfaceCreated(GL10 gl, EGLConfig config) {
  61.  
  62.          gl.glDisable(GL10.GL_DITHER);
  63.  
  64.          gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT,
  65.  
  66.                  GL10.GL_FASTEST);
  67.  
  68.     }
  69.  
  70. }
  71.  
  72.  
Parsed in 0.034 seconds, using GeSHi 1.0.8.4


So.. this _really_ is nothing special. As you see in OnDraw, I do all updating and drawing single threaded. While I have already begun creating a simple task queue, I still stick to single threaded operation, currently. For rendering, I use fixed point pointer methods, as example:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. sGlInterface.glVertexPointer(3, GL10.GL_FIXED, 0, (IntBuffer)_pMesh.getBufferVtx());
  3.  
  4.  
Parsed in 0.033 seconds, using GeSHi 1.0.8.4


for testing, I use most of the classes for a PC implementation as well and it is running absolutely fine there. Now my problem:

The actual on-screen events are not synchronous displayed. As instance, several meshes are broken, some are rendered once but not updated even if a new frame got rendered with updated positions. If I run the package as "Debug" using eclipse, most of my meshes are not even showing up at all!

Does anybody have a glue what I might have done wrong? I took the CubeRenderer example from the ApiDemos as reference and did mostly copy and paste (instead of my rather lengthy game code that does updating and rendering).

Every hint is helpful - I feel totally helpless and dumb because of the time already spent. :(

Thank you!
Clankrieger
Freshman
Freshman
 
Posts: 3
Joined: Thu Feb 11, 2010 11:00 pm

Top

Return to Android 2D/3D Graphics - OpenGL Tutorials

Who is online

Users browsing this forum: No registered users and 4 guests