本文整理匯總了Java中android.opengl.EGLContext類的典型用法代碼示例。如果您正苦於以下問題:Java EGLContext類的具體用法?Java EGLContext怎麽用?Java EGLContext使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
EGLContext類屬於android.opengl包,在下文中一共展示了EGLContext類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createGLESWithPBuffer
import android.opengl.EGLContext; //導入依賴的package包/類
public EGLSurface createGLESWithPBuffer(EGLConfigAttrs attrs,EGLContextAttrs ctxAttrs,int width,int height){
EGLConfig config=getConfig(attrs.surfaceType(EGL14.EGL_PBUFFER_BIT));
if(config==null){
log("getConfig failed : "+EGL14.eglGetError());
return null;
}
EGLContext eglContext=createContext(config,EGL14.EGL_NO_CONTEXT,ctxAttrs);
if(eglContext==EGL14.EGL_NO_CONTEXT){
log("createContext failed : "+EGL14.eglGetError());
return null;
}
EGLSurface eglSurface=createPBufferSurface(config,width,height);
if(eglSurface==EGL14.EGL_NO_SURFACE){
log("createWindowSurface failed : "+EGL14.eglGetError());
return null;
}
if(!EGL14.eglMakeCurrent(mEGLDisplay,eglSurface,eglSurface,eglContext)){
log("eglMakeCurrent failed : "+EGL14.eglGetError());
return null;
}
return eglSurface;
}
示例2: setEglContext
import android.opengl.EGLContext; //導入依賴的package包/類
public final void setEglContext(final EGLContext shared_context, final int tex_id, final Object surface, final boolean isRecordable) {
if (DEBUG) Log.i(TAG, "setEglContext:");
if (!(surface instanceof Surface) && !(surface instanceof SurfaceTexture) && !(surface instanceof SurfaceHolder))
throw new RuntimeException("unsupported window type:" + surface);
synchronized (mSync) {
if (mRequestRelease) return;
mShard_context = shared_context;
mTexId = tex_id;
mSurface = surface;
mIsRecordable = isRecordable;
mRequestSetEglContext = true;
mSync.notifyAll();
try {
mSync.wait();
} catch (final InterruptedException e) {
}
}
}
示例3: handleUpdateSharedContext
import android.opengl.EGLContext; //導入依賴的package包/類
/**
* Tears down the EGL surface and context we've been using to feed the MediaCodec input
* surface, and replaces it with a new one that shares with the new context.
* <p>
* This is useful if the old context we were sharing with went away (maybe a GLSurfaceView
* that got torn down) and we need to hook up with the new one.
*/
private void handleUpdateSharedContext(EGLContext newSharedContext) {
Log.d(TAG, "handleUpdatedSharedContext " + newSharedContext);
// Release the EGLSurface and EGLContext.
mInputWindowSurface.releaseEglSurface();
eglDrawer.deInit();
mEglCore.release();
// Create a new EGLContext and recreate the window surface.
mEglCore = new EglCore(newSharedContext, EglCore.FLAG_RECORDABLE);
mInputWindowSurface.recreate(mEglCore);
mInputWindowSurface.makeCurrent();
eglDrawer.init();
eglDrawer.setViewportSize(encoderConfig.mWidth,encoderConfig.mHeight);
}
示例4: prepareEncoder
import android.opengl.EGLContext; //導入依賴的package包/類
private void prepareEncoder(EGLContext sharedContext, int width, int height, int bitRate,
File outputFile) {
try {
MMediaMuxer =new MMediaMuxer(outputFile);
mVideoEncoder = new VideoEncoderCore(width, height, bitRate, MMediaMuxer);
// mAudioEncoder = new AudioEncoderCore(MMediaMuxer);
} catch (IOException ioe) {
throw new RuntimeException(ioe);
}
mEglCore = new EglCore(sharedContext, EglCore.FLAG_RECORDABLE);
mInputWindowSurface = new WindowSurface(mEglCore, mVideoEncoder.getInputSurface(), true);
mInputWindowSurface.makeCurrent();
eglDrawer.init();
eglDrawer.setViewportSize(encoderConfig.mWidth,encoderConfig.mHeight);
}
示例5: testSetPresentationTime
import android.opengl.EGLContext; //導入依賴的package包/類
/**
* Test for {@link GLTools#setPresentationTime(EGLDisplay, EGLSurface, long)} .
* @throws Exception by some fails
*/
@Test
public final void testSetPresentationTime() throws Exception {
final EGLDisplay eglDisplay = GLTools.newDisplay();
final EGLConfig eglConfig = GLTools.newConfig(eglDisplay, true);
final EGLContext eglContext = GLTools.newContext(eglDisplay, eglConfig);
final EGLSurface eglSurface =
GLTools.newSurface(eglDisplay, eglConfig, FRAME_SIZE, FRAME_SIZE);
GLTools.makeCurrent(eglDisplay, eglSurface, eglContext);
final int txt = GLTools.newTexture(TEXTURE_LEVEL);
final SurfaceTexture surfaceTexture = new SurfaceTexture(txt, true);
final Surface surface = new Surface(surfaceTexture);
final EGLSurface window = GLTools.newSurface(eglDisplay, eglConfig, surface);
GLTools.setPresentationTime(eglDisplay, window, PRESENTATION_TIME);
GLTools.closeSurface(eglDisplay, window);
surface.release();
surfaceTexture.release();
GLTools.closeTexture(txt, TEXTURE_LEVEL);
GLTools.closeSurface(eglDisplay, eglSurface);
GLTools.closeContext(eglDisplay, eglContext);
GLTools.closeDisplay(eglDisplay);
}
示例6: testTexture
import android.opengl.EGLContext; //導入依賴的package包/類
/**
* Test for {@link GLTools#newTexture(int)} and {@link GLTools#closeTexture(int, int)}.
* @throws Exception by some fails
*/
@Test
public final void testTexture() throws Exception {
final EGLDisplay eglDisplay = GLTools.newDisplay();
final EGLConfig eglConfig = GLTools.newConfig(eglDisplay, true);
final EGLContext eglContext = GLTools.newContext(eglDisplay, eglConfig);
final EGLSurface eglSurface =
GLTools.newSurface(eglDisplay, eglConfig, FRAME_SIZE, FRAME_SIZE);
GLTools.makeCurrent(eglDisplay, eglSurface, eglContext);
GLTools.closeTexture(GLTools.newTexture(TEXTURE_LEVEL), TEXTURE_LEVEL);
GLTools.closeSurface(eglDisplay, eglSurface);
GLTools.closeContext(eglDisplay, eglContext);
GLTools.closeDisplay(eglDisplay);
}
示例7: testShader
import android.opengl.EGLContext; //導入依賴的package包/類
/**
* Test for {@link GLTools#newShader(int[])} and {@link GLTools#closeShader(int[])}.
* @throws Exception by some fails
*/
@Test
public final void testShader() throws Exception {
final EGLDisplay eglDisplay = GLTools.newDisplay();
final EGLConfig eglConfig = GLTools.newConfig(eglDisplay, true);
final EGLContext eglContext = GLTools.newContext(eglDisplay, eglConfig);
final EGLSurface eglSurface =
GLTools.newSurface(eglDisplay, eglConfig, FRAME_SIZE, FRAME_SIZE);
GLTools.makeCurrent(eglDisplay, eglSurface, eglContext);
final int[] attrs = new int[5];
GLTools.newShader(attrs);
GLTools.closeShader(attrs);
GLTools.closeSurface(eglDisplay, eglSurface);
GLTools.closeContext(eglDisplay, eglContext);
GLTools.closeDisplay(eglDisplay);
}
示例8: createEglContext
import android.opengl.EGLContext; //導入依賴的package包/類
private static EGLContext createEglContext(
EglBase14.Context sharedContext, EGLDisplay eglDisplay, EGLConfig eglConfig) {
if (sharedContext != null && sharedContext.egl14Context == EGL14.EGL_NO_CONTEXT) {
throw new RuntimeException("Invalid sharedContext");
}
int[] contextAttributes = {EGL14.EGL_CONTEXT_CLIENT_VERSION, 2, EGL14.EGL_NONE};
EGLContext rootContext =
sharedContext == null ? EGL14.EGL_NO_CONTEXT : sharedContext.egl14Context;
final EGLContext eglContext;
synchronized (EglBase.lock) {
eglContext = EGL14.eglCreateContext(eglDisplay, eglConfig, rootContext, contextAttributes, 0);
}
if (eglContext == EGL14.EGL_NO_CONTEXT) {
throw new RuntimeException(
"Failed to create EGL context: 0x" + Integer.toHexString(EGL14.eglGetError()));
}
return eglContext;
}
示例9: handleUpdateSharedContext
import android.opengl.EGLContext; //導入依賴的package包/類
/**
* Tears down the EGL surface and context we've been using to feed the MediaCodec input
* surface, and replaces it with a new one that shares with the new context.
* <p>
* This is useful if the old context we were sharing with went away (maybe a GLSurfaceView
* that got torn down) and we need to hook up with the new one.
*/
private void handleUpdateSharedContext(EGLContext newSharedContext) {
Log.d(TAG, "handleUpdatedSharedContext " + newSharedContext);
// Release the EGLSurface and EGLContext.
mInputWindowSurface.releaseEglSurface();
mFullScreen.release(false);
mEglCore.release();
// Create a new EGLContext and recreate the window surface.
mEglCore = new EglCore(newSharedContext, EglCore.FLAG_RECORDABLE);
mInputWindowSurface.recreate(mEglCore);
mInputWindowSurface.makeCurrent();
// Create new programs and such for the new context.
mFullScreen = new FullFrameRect(FilterManager.getCameraFilter(mCurrentFilterType, mContext));
}
示例10: setEglContext
import android.opengl.EGLContext; //導入依賴的package包/類
public final void setEglContext(final EGLContext shared_context, final int tex_id, final Object surface, final boolean isRecordable) {
if (DEBUG) Log.i(TAG, "setEglContext:");
if (!(surface instanceof Surface) && !(surface instanceof SurfaceTexture) && !(surface instanceof SurfaceHolder))
throw new RuntimeException("unsupported window type:" + surface);
synchronized (mSync) {
if (mRequestRelease) return;
mShard_context = shared_context;
mTexId = tex_id;
mSurface = surface;
mIsRecordable = isRecordable;
mRequestSetEglContext = true;
Matrix.setIdentityM(mMatrix, 0);
Matrix.setIdentityM(mMatrix, 16);
mSync.notifyAll();
try {
mSync.wait();
} catch (final InterruptedException e) {
}
}
}
示例11: handleUpdateSharedContext
import android.opengl.EGLContext; //導入依賴的package包/類
/**
* Tears down the EGL surface and context we've been using to feed the MediaCodec input
* surface, and replaces it with a new one that shares with the new context.
* <p>
* This is useful if the old context we were sharing with went away (maybe a GLSurfaceView
* that got torn down) and we need to hook up with the new one.
*/
private void handleUpdateSharedContext(EGLContext newSharedContext) {
Log.d(TAG, "handleUpdatedSharedContext " + newSharedContext);
// Release the EGLSurface and EGLContext.
mInputWindowSurface.releaseEglSurface();
mInput.destroy();
mEglCore.release();
// Create a new EGLContext and recreate the window surface.
mEglCore = new EglCore(newSharedContext, EglCore.FLAG_RECORDABLE);
mInputWindowSurface.recreate(mEglCore);
mInputWindowSurface.makeCurrent();
// Create new programs and such for the new context.
mInput = new MagicCameraInputFilter();
mInput.init();
filter = MagicFilterFactory.initFilters(type);
if(filter != null){
filter.init();
filter.onInputSizeChanged(mPreviewWidth, mPreviewHeight);
filter.onDisplaySizeChanged(mVideoWidth, mVideoHeight);
}
}
示例12: prepareEncoder
import android.opengl.EGLContext; //導入依賴的package包/類
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);
}
mVideoWidth = width;
mVideoHeight = height;
mEglCore = new EglCore(sharedContext, EglCore.FLAG_RECORDABLE);
mInputWindowSurface = new WindowSurface(mEglCore, mVideoEncoder.getInputSurface(), true);
mInputWindowSurface.makeCurrent();
mInput = new MagicCameraInputFilter();
mInput.init();
filter = MagicFilterFactory.initFilters(type);
if(filter != null){
filter.init();
filter.onInputSizeChanged(mPreviewWidth, mPreviewHeight);
filter.onDisplaySizeChanged(mVideoWidth, mVideoHeight);
}
}
示例13: WebRtcClient
import android.opengl.EGLContext; //導入依賴的package包/類
public WebRtcClient(RtcListener listener, String host, PeerConnectionParameters params, EGLContext mEGLcontext) {
mListener = listener;
pcParams = params;
// initializeAndroidGlobals的第一個參數需要是activity或者application
PeerConnectionFactory.initializeAndroidGlobals(App.getInstance(), true, true,
params.videoCodecHwAcceleration, mEGLcontext);
factory = new PeerConnectionFactory();
MessageHandler messageHandler = new MessageHandler();
try {
client = IO.socket(host);
} catch (URISyntaxException e) {
e.printStackTrace();
}
client.on("id", messageHandler.onId);
client.on("message", messageHandler.onMessage);
client.connect(); // connect後,服務端會emit一個id信息,返回該客戶端的id
iceServers.add(new PeerConnection.IceServer("stun:23.21.150.121"));
iceServers.add(new PeerConnection.IceServer("stun:stun.l.google.com:19302"));
pcConstraints.mandatory.add(new MediaConstraints.KeyValuePair("OfferToReceiveAudio", "true"));
pcConstraints.mandatory.add(new MediaConstraints.KeyValuePair("OfferToReceiveVideo", "true"));
pcConstraints.optional.add(new MediaConstraints.KeyValuePair("DtlsSrtpKeyAgreement", "true"));
}
示例14: setEglContext
import android.opengl.EGLContext; //導入依賴的package包/類
public final void setEglContext(EGLContext shared_context, int tex_id, Object surface, boolean isRecordable) {
if (DEBUG) Log.i(TAG, "setEglContext:");
if (!(surface instanceof Surface) && !(surface instanceof SurfaceTexture) && !(surface instanceof SurfaceHolder))
throw new RuntimeException("unsupported window type:" + surface);
synchronized (mSync) {
if (mRequestRelease) return;
mShard_context = shared_context;
mTexId = tex_id;
mSurface = surface;
mIsRecordable = isRecordable;
mRequestSetEglContext = true;
mSync.notifyAll();
try {
mSync.wait();
} catch (InterruptedException e) {
}
}
}
示例15: handleUpdateSharedContext
import android.opengl.EGLContext; //導入依賴的package包/類
/**
* Tears down the EGL surface and context we've been using to feed the MediaCodec input
* surface, and replaces it with a new one that shares with the new context.
* <p>
* This is useful if the old context we were sharing with went away (maybe a GLSurfaceView
* that got torn down) and we need to hook up with the new one.
*/
private void handleUpdateSharedContext(EGLContext newSharedContext) {
Log.d(TAG, "handleUpdatedSharedContext " + newSharedContext);
// Release the EGLSurface and EGLContext.
mInputWindowSurface.releaseEglSurface();
mFullScreen.release(false);
mEglCore.release();
// Create a new EGLContext and recreate the window surface.
mEglCore = new EglCore(newSharedContext, EglCore.FLAG_RECORDABLE);
mInputWindowSurface.recreate(mEglCore);
mInputWindowSurface.makeCurrent();
// Create new programs and such for the new context.
mFullScreen = new FullFrameRect(
new Texture2dProgram(Texture2dProgram.ProgramType.TEXTURE_EXT));
}