FileDocCategorySizeDatePackage
GenImage.javaAPI DocAndroid 5.1 API8722Thu Mar 12 22:22:54 GMT 2015com.android.rs.genimage

GenImage

public 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.BitmaploadBitmap(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 intloadShader(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 voidonDrawFrame(javax.microedition.khronos.opengles.GL10 unused)


        // Draw background color
        GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);

        // Draw triangle
        mTriangle.draw();
    
public voidonSurfaceChanged(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 voidonSurfaceCreated(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);