,Yeah, guess what, I'm stuck again. I'll just skip the introduction, because I think you all know that by now..
My openGL renderer usually runs at approx 60FPS, while the logic thread runs at about 200FPS. When I move away from my application by opening another application and go back to my app the drawing slows down, jumping between 52/56 when idle and occasionally as low as 40FPS. The logic thread continues to run at 200FPS, so that isn't the problem.
Even though 40FPS seems high enough, the drawing looks choppy. I can "restore" the framerate by killing my app and restarting it, so I assume it's a pause/resume thing.
I really hope you guys have seen it before, because I have no idea where to start looking. Even when I remove the drawing functions from onDraw the framedrop seems to occur, although I obviously can't see whether it's choppy or not.
My code is a bit messy, but I'll post it anyway:
RENDERER:
Using java Syntax Highlighting
- @Override
- public void onDrawFrame(GL10 gl)
- {
- if(System.currentTimeMillis() - start > 250)
- {
- Log.i("LauncherGL", "RENDERER FPS: " + frames*4);
- frames = 0;
- start = System.currentTimeMillis();
- }
- gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
- if(!updateScreen.isAlive())
- {
- Log.i("LauncherGL", "Start Thread");
- updateScreen.start();
- }
- //drawHome(gl);
- drawAppDrawer(gl);
- frames++;
- }
- @Override
- public void onSurfaceChanged(GL10 gl, int w, int h)
- {
- if(!appInfos.get(0).loaded)
- {
- for (int i = 0; i < appInfos.size() && i < 150; i++)
- {
- appInfos.get(i).texID = loadTexture(gl, appInfos.get(i).icon, 64, 64);
- shortcut[i] = new shortcutTile();
- }
- view = LauncherGL.getView();
- drawerTexID = loadTexture(gl, view.getDrawable(R.drawable.drawer), 512, 64);
- appDrawer = new drawerTile(drawerWidth, drawerHeight);
- appInfos.get(0).loaded = true;
- gl.glMatrixMode(GL10.GL_PROJECTION);
- float ratio = (float) w / (float) h;
- screenSize[0] = w;
- screenSize[1] = h;
- virtualSize[0] = 500;
- virtualSize[1] = (float) 500.0f / (float) ratio;
- gl.glFrustumf(-virtualSize[0]/2, virtualSize[0]/2, virtualSize[1]/2, -virtualSize[1]/2, 0.1f, 1);
- gl.glViewport(0, 0, screenSize[0], screenSize[1]);
- tileSpacingX = (virtualSize[0]/nAppsX);
- tileSpacingY = (virtualSize[1]/nAppsY);
- xPadding = (tileSpacingX-70)/2;
- yPadding = (tileSpacingY-70)/2;
- drawerX = 0-(drawerWidth/2);
- gl.glMatrixMode(GL10.GL_MODELVIEW);
- gl.glEnable(GL10.GL_DEPTH_TEST);
- dynamics.setVars(this, LauncherGL.getView());
- start = System.currentTimeMillis();
- Process.setThreadPriority(Process.THREAD_PRIORITY_URGENT_DISPLAY);
- }
- }
- @Override
- public void onSurfaceCreated(GL10 gl, EGLConfig config)
- {
- _gl = gl;
- dynamics = LauncherGL.getDynamics();
- flags = LauncherGL.getFlags();
- gl.glClearColor(0f, 0f, 0f, 0.0f);
- gl.glEnable(GL10.GL_CULL_FACE);
- gl.glFrontFace(GL10.GL_CCW);
- gl.glCullFace(GL10.GL_BACK);
- gl.glEnable(GL10.GL_TEXTURE_2D);
- gl.glShadeModel(GL10.GL_SMOOTH);
- gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
- gl.glEnable(GL10.GL_BLEND);
- }
- public void deleteTextures()
- {
- int texArray[] = new int[150];
- int i = 0;
- for (i=0; i < appInfos.size(); i++)
- texArray[i] = appInfos.get(i).texID;
- texArray[i+1] = drawerTexID;
- _gl.glDeleteTextures(texArray.length, texArray, 0);
- appInfos.get(0).loaded = false;
- }
- public void drawHome(GL10 gl)
- {
- gl.glLoadIdentity();
- homeY = dynamics.getHomeYCoord();
- gl.glTranslatef(homeX, homeY, 0);
- }
- public void drawAppDrawer(GL10 gl)
- {
- gl.glLoadIdentity();
- drawerY = dynamics.getDrawerYCoord();
- appsY = dynamics.getAppsYCoord();
- gl.glTranslatef(drawerX, drawerY, -0.10001f);
- gl.glBindTexture(GL10.GL_TEXTURE_2D, drawerTexID);
- appDrawer.draw(gl);
- gl.glTranslatef(-((virtualSize[0]/2)-(drawerWidth/2))+xPadding, tileSpacingY/2 + appsY, 0);
- int x = 0;
- int y = 0;
- for (int i = 0; i < appInfos.size(); i++)
- {
- if (x == nAppsX)
- {
- gl.glTranslatef(-tileSpacingX*nAppsX, tileSpacingY , 0);
- x = 0;
- y++;
- }
- gl.glBindTexture(GL10.GL_TEXTURE_2D, appInfos.get(i).texID);
- shortcut[i].draw(gl);
- gl.glTranslatef(tileSpacingX, 0, 0);
- x += 1;
- }
- }
Parsed in 0.044 seconds, using GeSHi 1.0.8.4
ACTIVITY:
Using java Syntax Highlighting
- @Override
- public void onCreate(Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
- view = new LauncherView(this);
- renderer = view.getRenderer();
- flags = new Flags();
- dynamics = new ScreenDynamics();
- /*mSensorManager = (SensorManager)getSystemService(Context.SENSOR_SERVICE);
- List<Sensor> mySensors = mSensorManager.getSensorList(Sensor.TYPE_ORIENTATION);
- if(mySensors.size() > 0)
- {
- mSensorManager.registerListener(this, mySensors.get(0), SensorManager.SENSOR_DELAY_NORMAL);
- Toast.makeText(this, "Start ORIENTATION Sensor", Toast.LENGTH_LONG).show();
- }*/
- getAllPackages();
- setContentView(view);
- }
- @Override
- protected void onPause()
- {
- super.onPause();
- flags.setUpdateScreenRunning(false);
- renderer.deleteTextures();
- view.onPause();
- }
- @Override
- protected void onResume()
- {
- super.onResume();
- flags.setUpdateScreenRunning(true);
- view.onResume();
- view.requestRender();
- }
- @Override
- protected void onDestroy()
- {
- super.onDestroy();
- flags.setKillUpdateScreen(true);
- }
- @Override
- public boolean onKeyDown(int keyCode, KeyEvent event) {
- if (keyCode == KeyEvent.KEYCODE_BACK)
- {
- if(flags.getDrawerOpen())
- dynamics.setDrawerYVelocity(5);
- else
- dynamics.setDrawerYVelocity(-5);
- return true;
- }
- return super.onKeyDown(keyCode, event);
- }
Parsed in 0.035 seconds, using GeSHi 1.0.8.4

