0

I have this one square and when I click on it it stretches so it takes all the screen like shown in these pictures

Before stretching my color picker shows the values real nice

enter image description here

After the stretching when I click just a little below robots legs it gives me value (0,0,255) which is my background color, not the white color I clicked on (255,255,255).

enter image description here

I draw this animation very fast (100 ms) using GLSurfaceView's setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY). The whole animation consists of only 6 frames.

The drawing itself happens from

...
ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
scheduler.scheduleAtFixedRate(new Runnable() {
        @Override
        public void run() {
            do_stretching();
        }
}, 0, stretching_frame_delay, TimeUnit.MILLISECONDS);
...

void do_stretching()
{
    //change coordinates of white squares vertices kind of "stretching" it
    surface_view.requestRenderer();
}

Animation is looking really good and fills all of GLSurfaceView's area but color picker kind of acts like the last frame wouldn't be drawn and reads the background color which indeed was there before the animation completed. I noticed that if I draw this animation slower thus using more frames I can click a little closer to edges of this image and get the right results but still very close to edges there is this bug that GLES20.glReadPixels reads the background color even though its actually not visible after the animation completes. What might be the problem here?

etrusks
  • 363
  • 3
  • 12
  • Solved the issue by calling requestRenderer() 2 more times after the animation was actually drawn. But still I dont really know why this might be happening. Maybe something with double buffering? – etrusks Jun 27 '17 at 20:20
  • actually calling requestRenderer() 2 more times doesn't remove the issue it just makes it smaller % of chance that this incorrect reading will happen – etrusks Jun 28 '17 at 10:53
  • I think I solved the issue by counting the times extra frames were rendered. If frame is not finished rendering and another requestRenderer() is called it wont have any effect so I counted that exactly 3 extra frames were rendered after my animation and that did the trick – etrusks Jun 28 '17 at 20:46

0 Answers0