com.serenegiant.glutils.GLDrawer2D Java Examples

The following examples show how to use com.serenegiant.glutils.GLDrawer2D. 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: CameraGLView.java    From TimeLapseRecordingSample with Apache License 2.0 6 votes vote down vote up
@Override
		public void onSurfaceCreated(GL10 unused, EGLConfig config) {
			if (DEBUG) Log.v(TAG, "onSurfaceCreated:");
			// This renderer required OES_EGL_image_external extension
			final String extensions = GLES20.glGetString(GLES20.GL_EXTENSIONS);	// API >= 8
//			if (DEBUG) Log.i(TAG, "onSurfaceCreated:Gl extensions: " + extensions);
			if (!extensions.contains("OES_EGL_image_external"))
				throw new RuntimeException("This system does not support OES_EGL_image_external.");
			// create texture ID
			hTex = GLDrawer2D.initTex();
			// create SurfaceTexture using the texture ID.
			mSTexture = new SurfaceTexture(hTex);
			mSTexture.setOnFrameAvailableListener(this);
			// XXX clear screen with yellow color
			// so that let easy to see the actual view rectangle and camera images for testing.
			GLES20.glClearColor(1.0f, 1.0f, 0.0f, 1.0f);
			mHasSurface = true;
			// create object for preview display
			mDrawer = new GLDrawer2D();
			mDrawer.setMatrix(mMvpMatrix, 0);
		}
 
Example #2
Source File: MediaScreenEncoder.java    From ScreenRecordingSample with Apache License 2.0 6 votes vote down vote up
@Override
protected void onStart() {
    if (DEBUG) Log.d(TAG,"mScreenCaptureTask#onStart:");
	mDrawer = new GLDrawer2D(true);
	mTexId = mDrawer.initTex();
	mSourceTexture = new SurfaceTexture(mTexId);
	mSourceTexture.setDefaultBufferSize(mWidth, mHeight);	// これを入れないと映像が取れない
	mSourceSurface = new Surface(mSourceTexture);
	mSourceTexture.setOnFrameAvailableListener(mOnFrameAvailableListener, mHandler);
	mEncoderSurface = getEgl().createFromSurface(mSurface);

   	if (DEBUG) Log.d(TAG,"setup VirtualDisplay");
	intervals = (long)(1000f / fps);
    display = mMediaProjection.createVirtualDisplay(
    	"Capturing Display",
    	mWidth, mHeight, mDensity,
    	DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR,
    	mSourceSurface, mCallback, mHandler);
	if (DEBUG) Log.v(TAG,  "screen capture loop:display=" + display);
	// 録画タスクを起床
	queueEvent(mDrawTask);
}
 
Example #3
Source File: UVCCameraTextureView.java    From AndroidUSBCamera with Apache License 2.0 5 votes vote down vote up
private final void init() {
	if (DEBUG) Log.v(TAG, "RenderThread#init:");
	// create EGLContext for this thread
          mEgl = EGLBase.createFrom(null, false, false);
  		mEglSurface = mEgl.createFromSurface(mSurface);
  		mEglSurface.makeCurrent();
  		// create drawing object
  		mDrawer = new GLDrawer2D(true);
}
 
Example #4
Source File: SurfaceDrawable.java    From libcommon with Apache License 2.0 5 votes vote down vote up
/**
 * ワーカースレッド開始時の処理(ここはワーカースレッド上)
 */
@WorkerThread
protected final void handleOnStart() {
	if (DEBUG) Log.v(TAG, "handleOnStart:");
	// OESテクスチャを直接ハンドリングできないのでオフスクリーンへ描画して読み込む
	mDrawer = GLDrawer2D.create(isOES3(), true);
	mDrawer.setMirror(IRendererCommon.MIRROR_VERTICAL);
}
 
Example #5
Source File: MediaSource.java    From libcommon with Apache License 2.0 5 votes vote down vote up
/**
 * 入力用オフスクリーンに映像をセット
 * @param drawer オフスクリーン描画用GLDrawer2D
 * @param tex_id
 * @param tex_matrix
 * @return
 */
public MediaSource setSource(final GLDrawer2D drawer,
	final int tex_id, final float[] tex_matrix) {

	mSourceScreen.makeCurrent();
	try {
		drawer.draw(tex_id, tex_matrix, 0);
	} catch (RuntimeException e) {
		Log.w(TAG, e);
	} finally {
		mSourceScreen.swap();
	}
	reset();
	return this;
}