0

I have a GLSurfaceView that is rendering an image as a texture. I have attached a GestureDetector to the GLSurfaceView. When the user taps the screen i want to display a linear layout on top of the GLSurfaceView.

Currently when the user taps the GLSurfaceView the linearlayout displays but then disappears on its own in about 2-3 seconds. Every now and then it will flash on the screen for a split second. All this without any interactions from the user.

Any insights to what is happening? Here is what i have tried and some useful info.

  1. My GLSurfaceView is set to Render_When_Dirty mode and i have ensured that after the user taps there are no calls to the onDrawFrame method. I know this by logging a statement in the method.
  2. I have also verified that the setVisibility(boolean) method of the linearlayout is not being maliciously called.

Here is some code of how the GLSurfaceView is being created.

glSurfaceView = new GLSurfaceView(context) {
    public void surfaceDestroyed(SurfaceHolder holder) {
        super.surfaceDestroyed(holder);
        Logger.w("Surface Destroyed");

        if (sprite != null) {
            // readerBitmap =sprite.bitmap;
            time = sprite.time;
        }
        //glSurfaceView.setBackgroundColor(color.black);

        if (myHandler != null) {
            myHandler.sendEmptyMessage(9);
        }

    }
};

gestureDetector = new GestureDetector(context, new MyGestureDetector()); 
glSurfaceView.setOnTouchListener(touchListener);

// set our renderer to be the main renderer with
sprite = new GlRenderer(context,Global.PICTURES.get(Global.currentPictureIndex),myHandler, tempTime);
glSurfaceView.setRenderer(sprite);
glSurfaceView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);

TextView tv = (TextView)findViewById(R.id.customTextView1);
tv.setVisibility(View.GONE);

//add to the view
mainLayout.removeView(glSurfaceView);
mainLayout.addView(glSurfaceView, 0);

P.S. This is on Android 4.0

genpfault
  • 51,148
  • 11
  • 85
  • 139
codeNinja
  • 1,442
  • 3
  • 25
  • 61

1 Answers1

0

When you set the render mode to RENDERMODE_WHEN_DIRTY you need to request or invalidate the GLSurfaceView to tell it to redraw itself. It's usually done with a thread that contains a loop requesting the render. Are you doing that?

Comment out the setRenderMode line and see if you get the desired results since the default continuously draws itself.

Hope that helps.

RorschachDev
  • 354
  • 4
  • 11