4
\$\begingroup\$

i just new to libgdx and trying to understand the example code, the following code sets the bg color

        Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
        Gdx.gl.glClearColor(60,181,00,0f);

my expected color is green, R:60 Green:181 B:0, but the about code show me yellow color in my android app, anything i'm doing wrong?

http://rapid-tools.net/online-color-picker/

\$\endgroup\$

1 Answer 1

7
\$\begingroup\$

glClearColor expects color values to be in 0 .. 1 range, everything outside of this range gets clamped to it. In your case numbers are getting clamped to (1, 1, 0, 0) which is indeed yellow.

Try setting glClearColor(60/255.0, 181/255.0, 0.0, 0.0); instead.

\$\endgroup\$
3
  • 3
    \$\begingroup\$ The lines should also be switched around, otherwise there will be one "wrong" frame. \$\endgroup\$
    – Ben
    Oct 8, 2014 at 9:48
  • \$\begingroup\$ @Ben: Good comment, it should be for the question though, not for the answer ;) \$\endgroup\$
    – Kromster
    Oct 8, 2014 at 9:49
  • \$\begingroup\$ finally, Gdx.gl.glClearColor((float)60/255,(float)181/255,0f,0f); \$\endgroup\$
    – hkguile
    Oct 9, 2014 at 1:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .