You're only measuring the time it took to do the rendering, but you
should probably look at the total elapsed time between calls to your
update() method, rather than timing only a specific part of the
process.


On Sun, Jul 5, 2009 at 12:21 PM, teo2k<[email protected]> wrote:
>
> Hi All,
>
> I'm doing some experiments with OpenGL using the GLSurfaceView
> introduced in 1.5
>
> In my Renderer I keep track of the time spent to render the last frame
> and pass this value to the method that update my model. The goal is to
> keep objects movements on the screen independent from the rendering
> time.
>
> Now... this seems to work perfectly in the emulator, but on the real
> device is at least 4/5 times slower!!!
>
> Has anyone experienced the same problem? Or, anyone has a clue of what
> I'm doing wrong?
>
> Here's pieces of the code I'm using:
>
> /* Renderer */
> public void onDrawFrame(GL10 gl) {
>    mRefTime = System.currentTimeMillis();
>
>    // Update the game state after rendering
>    if(mLastFrameTime > 0) {
>        mGameEngine.update(mLastFrameTime);
>    }
>
>    gl.glMatrixMode(GL10.GL_MODELVIEW);
>    gl.glLoadIdentity();
>
>    for (int i = 0; i < mRenderables.length; i++) {
>        mRenderables[i].draw(gl);
>    }
>
>    mLastFrameTime = System.currentTimeMillis() - mRefTime;
> }
>
> /* Update method */
> public void update(long lastFrameTime) {
>    int i, j;
>    float moveOffset = mGameVelocity * UNIT_VELOCITY_MS *
> lastFrameTime;
>
>    for(i=0; i<ROW_COUNT; i++) {
>        for(j=0; j<ROW_SIZE; j++) {
>            mObj[i][j].x += moveOffset;
>        }
>    }
> }
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to