com.android.grafika.gles.FullFrameRect Java Examples

The following examples show how to use com.android.grafika.gles.FullFrameRect. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RecordFBOActivity.java    From pause-resume-video-recording with Apache License 2.0 6 votes vote down vote up
/**
 * Prepares window surface and GL state.
 */
private void prepareGl(Surface surface) {
    Log.d(TAG, "prepareGl");

    mWindowSurface = new WindowSurface(mEglCore, surface, false);
    mWindowSurface.makeCurrent();

    // Used for blitting texture to FBO.
    mFullScreen = new FullFrameRect(
            new Texture2dProgram(Texture2dProgram.ProgramType.TEXTURE_2D));

    // Program used for drawing onto the screen.
    mProgram = new FlatShadedProgram();

    // Set the background color.
    GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);

    // Disable depth testing -- we're 2D only.
    GLES20.glDisable(GLES20.GL_DEPTH_TEST);

    // Don't need backface culling.  (If you're feeling pedantic, you can turn it on to
    // make sure we're defining our shapes correctly.)
    GLES20.glDisable(GLES20.GL_CULL_FACE);

    mActivityHandler.sendGlesVersion(mEglCore.getGlVersion());
}
 
Example #2
Source File: RecordFBOActivity.java    From grafika with Apache License 2.0 6 votes vote down vote up
/**
 * Prepares window surface and GL state.
 */
private void prepareGl(Surface surface) {
    Log.d(TAG, "prepareGl");

    mWindowSurface = new WindowSurface(mEglCore, surface, false);
    mWindowSurface.makeCurrent();

    // Used for blitting texture to FBO.
    mFullScreen = new FullFrameRect(
            new Texture2dProgram(Texture2dProgram.ProgramType.TEXTURE_2D));

    // Program used for drawing onto the screen.
    mProgram = new FlatShadedProgram();

    // Set the background color.
    GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);

    // Disable depth testing -- we're 2D only.
    GLES20.glDisable(GLES20.GL_DEPTH_TEST);

    // Don't need backface culling.  (If you're feeling pedantic, you can turn it on to
    // make sure we're defining our shapes correctly.)
    GLES20.glDisable(GLES20.GL_CULL_FACE);

    mActivityHandler.sendGlesVersion(mEglCore.getGlVersion());
}
 
Example #3
Source File: ContinuousCaptureActivity.java    From grafika with Apache License 2.0 6 votes vote down vote up
@Override   // SurfaceHolder.Callback
public void surfaceCreated(SurfaceHolder holder) {
    Log.d(TAG, "surfaceCreated holder=" + holder);

    // Set up everything that requires an EGL context.
    //
    // We had to wait until we had a surface because you can't make an EGL context current
    // without one, and creating a temporary 1x1 pbuffer is a waste of time.
    //
    // The display surface that we use for the SurfaceView, and the encoder surface we
    // use for video, use the same EGL context.
    mEglCore = new EglCore(null, EglCore.FLAG_RECORDABLE);
    mDisplaySurface = new WindowSurface(mEglCore, holder.getSurface(), false);
    mDisplaySurface.makeCurrent();

    mFullFrameBlit = new FullFrameRect(
            new Texture2dProgram(Texture2dProgram.ProgramType.TEXTURE_EXT));
    mTextureId = mFullFrameBlit.createTextureObject();
    mCameraTexture = new SurfaceTexture(mTextureId);
    mCameraTexture.setOnFrameAvailableListener(this);

    startPreview();
}
 
Example #4
Source File: CameraCaptureActivity.java    From pause-resume-video-recording with Apache License 2.0 5 votes vote down vote up
@Override
public void onSurfaceCreated(GL10 unused, EGLConfig config) {
    Log.d(TAG, "onSurfaceCreated");

    // We're starting up or coming back.  Either way we've got a new EGLContext that will
    // need to be shared with the video encoder, so figure out if a recording is already
    // in progress.
    mRecordingEnabled = mVideoEncoder.isRecording();
    if (mRecordingEnabled) {
        mRecordingStatus = RECORDING_RESUMED;
    } else {
        mRecordingStatus = RECORDING_OFF;
    }

    // Set up the texture blitter that will be used for on-screen display.  This
    // is *not* applied to the recording, because that uses a separate shader.
    mFullScreen = new FullFrameRect(
            new Texture2dProgram(Texture2dProgram.ProgramType.TEXTURE_EXT));

    mTextureId = mFullScreen.createTextureObject();

    // Create a SurfaceTexture, with an external texture, in this EGL context.  We don't
    // have a Looper in this thread -- GLSurfaceView doesn't create one -- so the frame
    // available messages will arrive on the main thread.
    mSurfaceTexture = new SurfaceTexture(mTextureId);

    // Tell the UI thread to enable the camera preview.
    mCameraHandler.sendMessage(mCameraHandler.obtainMessage(
            CameraCaptureActivity.CameraHandler.MSG_SET_SURFACE_TEXTURE, mSurfaceTexture));
}
 
Example #5
Source File: TextureMovieEncoder.java    From pause-resume-video-recording with Apache License 2.0 5 votes vote down vote up
private void prepareEncoder(EGLContext sharedContext, int width, int height, int bitRate,
        File outputFile) {
    try {
        mVideoEncoder = new VideoEncoderCore(width, height, bitRate, outputFile);
    } catch (IOException ioe) {
        throw new RuntimeException(ioe);
    }
    mEglCore = new EglCore(sharedContext, EglCore.FLAG_RECORDABLE);
    mInputWindowSurface = new WindowSurface(mEglCore, mVideoEncoder.getInputSurface(), true);
    mInputWindowSurface.makeCurrent();

    mFullScreen = new FullFrameRect(
            new Texture2dProgram(Texture2dProgram.ProgramType.TEXTURE_EXT));
}
 
Example #6
Source File: CameraCaptureActivity.java    From grafika with Apache License 2.0 5 votes vote down vote up
@Override
public void onSurfaceCreated(GL10 unused, EGLConfig config) {
    Log.d(TAG, "onSurfaceCreated");

    // We're starting up or coming back.  Either way we've got a new EGLContext that will
    // need to be shared with the video encoder, so figure out if a recording is already
    // in progress.
    mRecordingEnabled = mVideoEncoder.isRecording();
    if (mRecordingEnabled) {
        mRecordingStatus = RECORDING_RESUMED;
    } else {
        mRecordingStatus = RECORDING_OFF;
    }

    // Set up the texture blitter that will be used for on-screen display.  This
    // is *not* applied to the recording, because that uses a separate shader.
    mFullScreen = new FullFrameRect(
            new Texture2dProgram(Texture2dProgram.ProgramType.TEXTURE_EXT));

    mTextureId = mFullScreen.createTextureObject();

    // Create a SurfaceTexture, with an external texture, in this EGL context.  We don't
    // have a Looper in this thread -- GLSurfaceView doesn't create one -- so the frame
    // available messages will arrive on the main thread.
    mSurfaceTexture = new SurfaceTexture(mTextureId);

    // Tell the UI thread to enable the camera preview.
    mCameraHandler.sendMessage(mCameraHandler.obtainMessage(
            CameraCaptureActivity.CameraHandler.MSG_SET_SURFACE_TEXTURE, mSurfaceTexture));
}
 
Example #7
Source File: TextureMovieEncoder.java    From grafika with Apache License 2.0 5 votes vote down vote up
private void prepareEncoder(EGLContext sharedContext, int width, int height, int bitRate,
        File outputFile) {
    try {
        mVideoEncoder = new VideoEncoderCore(width, height, bitRate, outputFile);
    } catch (IOException ioe) {
        throw new RuntimeException(ioe);
    }
    mEglCore = new EglCore(sharedContext, EglCore.FLAG_RECORDABLE);
    mInputWindowSurface = new WindowSurface(mEglCore, mVideoEncoder.getInputSurface(), true);
    mInputWindowSurface.makeCurrent();

    mFullScreen = new FullFrameRect(
            new Texture2dProgram(Texture2dProgram.ProgramType.TEXTURE_EXT));
}
 
Example #8
Source File: GLTextureRender.java    From IjkVRPlayer with Apache License 2.0 4 votes vote down vote up
protected FullFrameRect onCreateFrameRect() {
    return new FullFrameRect(new Texture2dProgram(Texture2dProgram.ProgramType.TEXTURE_EXT));
}
 
Example #9
Source File: IjkVRRender.java    From IjkVRPlayer with Apache License 2.0 4 votes vote down vote up
@Override
protected FullFrameRect onCreateFrameRect() {
    return new SideBySideFrameRect(new Texture2dProgram(Texture2dProgram.ProgramType.TEXTURE_EXT));
}