If you think the Android project rgb-tool listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package com.fastebro.androidrgbtool.render;
//www.java2s.comimport javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
import android.opengl.GLSurfaceView.Renderer;
importstatic android.opengl.GLES20.*;
publicclass GLRender implements Renderer {
publicfloat R_COLOR = 0.0f;
publicfloat G_COLOR = 0.0f;
publicfloat B_COLOR = 0.0f;
publicfloat COLOR_OPACITY = 0.0f;
@Override
publicvoid onSurfaceCreated(GL10 glUnused, EGLConfig config) {
// Set the background clear color to red. The first component is
// red, the second is green, the third is blue, and the last
// component is alpha.
glClearColor(R_COLOR, G_COLOR, B_COLOR, COLOR_OPACITY);
}
/**
* onSurfaceChanged is called whenever the surface has changed. This is
* called at least once when the surface is initialized. Keep in mind that
* Android normally restarts an Activity on rotation, and in that case, the
* renderer will be destroyed and a new one created.
*
* @param width The new width, in pixels.
* @param height The new height, in pixels.
*/
@Override
publicvoid onSurfaceChanged(GL10 glUnused, int width, int height) {
// Set the OpenGL viewport to fill the entire surface.
glViewport(0, 0, width, height);
}
/**
* OnDrawFrame is called whenever a new frame needs to be drawn. Normally,
* this is done at the refresh rate of the screen.
*/
@Override
publicvoid onDrawFrame(GL10 glUnused) {
// Clear the rendering surface.
glColorMask(true, true, true, true);
glClearColor(R_COLOR, G_COLOR, B_COLOR, COLOR_OPACITY);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
}