GenImagepublic class GenImage extends Object implements GLSurfaceView.Renderer
Fields Summary |
---|
private android.graphics.Bitmap | mTestImage | private Triangle | mTriangle |
Constructors Summary |
---|
GenImage(android.content.Context context)
mTestImage = loadBitmap(context, R.drawable.test_pattern);
|
Methods Summary |
---|
private android.graphics.Bitmap | loadBitmap(android.content.Context context, int resource)
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
return BitmapFactory.decodeResource(context.getResources(), resource, options);
| public static int | loadShader(int type, java.lang.String shaderCode)
// create a vertex shader type (GLES20.GL_VERTEX_SHADER)
// or a fragment shader type (GLES20.GL_FRAGMENT_SHADER)
int shader = GLES20.glCreateShader(type);
// add the source code to the shader and compile it
GLES20.glShaderSource(shader, shaderCode);
GLES20.glCompileShader(shader);
return shader;
| public void | onDrawFrame(javax.microedition.khronos.opengles.GL10 unused)
// Draw background color
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
// Draw triangle
mTriangle.draw();
| public void | onSurfaceChanged(javax.microedition.khronos.opengles.GL10 unused, int width, int height)
// Adjust the viewport based on geometry changes,
// such as screen rotation
GLES20.glViewport(0, 0, 512, 512);
| public void | onSurfaceCreated(javax.microedition.khronos.opengles.GL10 unused, javax.microedition.khronos.egl.EGLConfig config)
// Set the background frame color
GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
mTriangle = new Triangle(mTestImage);
|
|