KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have problems with smooth scrolling in OpenGL (testing on SGS2 and ACE) I created simple applications - only fixed speed horizontal scrolling of images, or only one image (player) moving by accelerator, but it's movement is not smooth :-( I tried many various of code but no satisfaction... first I tried work with GLSurfaceView.RENDERMODE_CONTINUOUSLY and I put all code to onDrawFrame: public void onDrawFrame(GL10 gl) { updateGame(gl, 0.017f); drawGame(gl); } this is the simplest and absolute smooth!! - but it's dependent on hardware speed (= useless) public void onDrawFrame(GL10 gl) { frameTime = SystemClock.elapsedRealtime(); elapsedTime = (frameTime - lastTime) / 1000; updateGame(gl, elapsedTime); drawGame(gl); lastTime = frameTime; } this is the best of all but it's not as smooth as the previous, sometimes flick second I tried GLSurfaceView.RENDERMODE_WHEN_DIRTY , in onDrawFrame i have only drawing objects and this code in separate Thread: while (true) { updateGame(renderer, 0.017f); mGLSurfaceView.requestRender(); next_game_tick += SKIP_TICKS; sleep_time = next_game_tick - System.currentTimeMillis(); if (sleep_time >= 0) { try { Thread.sleep(sleep_time); } catch (Exception e) {} } else { Log.d("running behind: ", String.valueOf(sleep_time)); } } this is not smooth and it's not problem with "running behind" My objective is smooth image movement like in first code example above. Possible error is somewhere else then I looking. Please, Can somebody help me with this? Is better use RENDERMODE_WHEN_DIRTY or RENDERMODE_CONTINUOUSLY? Than
Tags (comma-separated)
Save Edits
Cancel