glClear - Do you need it?

Problems with Canvas, OpenGL, etc...

glClear - Do you need it?

Postby tttcowan » Thu Feb 24, 2011 3:26 pm

I'm optimising my 2d game at the moment and noticed an opengl method taking up 4.6% of a processing for each game loop. The line in question is below,

gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);

I removed it and the game runs fine saving me a bit of processing power... Do I need the line? What's it actually for, sorry for being a pain im still struggling to get to grips with opengl.

Thanks
tttcowan
Developer
Developer
 
Posts: 46
Joined: Mon Jul 19, 2010 11:08 pm

Top

Re: glClear - Do you need it?

Postby MichaelEGR » Thu Feb 24, 2011 10:51 pm

Since you are making a 2D game you could forego using glClear if you are redrawing the full screen every frame and you are not using the depth buffer (likely not). I assume you are setting thing up in ortho mode. You can of course try omitting the "| GL10.GL_DEPTH_BUFFER_BIT" from the glClear call and measure performance again. Also perhaps use glDisable() and disable depth testing. Like I mentioned you can forego the glClear call with the GL_COLOR_BUFFER_BIT in your case if you redraw the full screen each time.
Founder & Principal Architect; EGR Software LLC
http://www.typhonrt.org
http://www.egrsoftware.com
User avatar
MichaelEGR
Senior Developer
Senior Developer
 
Posts: 147
Joined: Thu Jan 21, 2010 5:30 am
Location: San Francisco, CA

Re: glClear - Do you need it?

Postby tttcowan » Fri Feb 25, 2011 11:36 am

Thanks Michael, that makes sense... I definatley need to get to grips with OpenGL ES, I might get a book on it or something. Good luck with your Typhoon stuff, had a flick through your website and it sounds pretty cool... I'm actually doing a point and click adventure game engine at the moment. :)
tttcowan
Developer
Developer
 
Posts: 46
Joined: Mon Jul 19, 2010 11:08 pm

Top

Return to Android 2D/3D Graphics - OpenGL Problems

Who is online

Users browsing this forum: No registered users and 3 guests