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:
Using java Syntax Highlighting
- /* Renderer */
- public void onDrawFrame(GL10 gl) {
- mRefTime = System.currentTimeMillis();
- // Update the game state before 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 lastFrameTimeMS) {
- int i, j;
- float moveOffset = mGameVelocity * UNIT_VELOCITY_MS * lastFrameTimeMS;
- for(i=0; i<ROW_COUNT; i++) {
- for(j=0; j<ROW_SIZE; j++) {
- mObj[i][j].x += moveOffset;
- }
- }
- }
Parsed in 0.032 seconds, using GeSHi 1.0.8.4

