How to set background colour on Open GL ES Android

user455141 picture user455141 · Sep 27, 2010 · Viewed 11.5k times · Source

I am currently playing about with lesson 08 here

http://insanitydesign.com/wp/projects/nehe-android-ports/

I would like to change the background colour from black to white. In order to do this at the start of onDrawFrame() I have called

gl.glClearColor(1.0f, 0.0f, 0.0f, 0.0f);

This does indeed set a white background screen, but also results in nothing else showing up on the screen! Clearly this is therefore an incorrect method, but why, and how do I fix it?!

Many thanks in advance.

Edit (5 days later): Does nobody know at all?!!

Answer

Debopam Mitra picture Debopam Mitra · Dec 18, 2012

The white screen is because you have set the alpha value to 0.0f.

The parameter signature is:- gl.glClearColor(float red, float green, float blue, float alpha) where floats are any value between 0.0 to 1.0.

More the float value of alpha more opaque the screen is.