本文整理汇总了Java中android.opengl.EGL14类的典型用法代码示例。如果您正苦于以下问题:Java EGL14类的具体用法?Java EGL14怎么用?Java EGL14使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EGL14类属于android.opengl包,在下文中一共展示了EGL14类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: release
import android.opengl.EGL14; //导入依赖的package包/类
/**
* Discard all resources held by this class, notably the EGL context. Also releases the
* Surface that was passed to our constructor.
*/
public void release() {
if (EGL14.eglGetCurrentContext().equals(mEGLContext)) {
// Clear the current context and surface to ensure they are discarded immediately.
EGL14.eglMakeCurrent(mEGLDisplay, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_SURFACE,
EGL14.EGL_NO_CONTEXT);
}
EGL14.eglDestroySurface(mEGLDisplay, mEGLSurface);
EGL14.eglDestroyContext(mEGLDisplay, mEGLContext);
//EGL14.eglTerminate(mEGLDisplay);
mSurface.release();
// null everything out so future attempts to use this object will cause an NPE
mEGLDisplay = null;
mEGLContext = null;
mEGLSurface = null;
mSurface = null;
}
示例2: createGLESWithPBuffer
import android.opengl.EGL14; //导入依赖的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;
}
示例3: filterConfigSpec
import android.opengl.EGL14; //导入依赖的package包/类
private int[] filterConfigSpec(int[] configSpec) {
if (mEGLContextClientVersion != 2 && mEGLContextClientVersion != 3) {
return configSpec;
}
/* We know none of the subclasses define EGL_RENDERABLE_TYPE.
* And we know the configSpec is well formed.
*/
int len = configSpec.length;
int[] newConfigSpec = new int[len + 2];
System.arraycopy(configSpec, 0, newConfigSpec, 0, len - 1);
newConfigSpec[len - 1] = EGL10.EGL_RENDERABLE_TYPE;
if (mEGLContextClientVersion == 2) {
newConfigSpec[len] = EGL14.EGL_OPENGL_ES2_BIT; /* EGL_OPENGL_ES2_BIT */
} else {
newConfigSpec[len] = EGLExt.EGL_OPENGL_ES3_BIT_KHR; /* EGL_OPENGL_ES3_BIT_KHR */
}
newConfigSpec[len + 1] = EGL10.EGL_NONE;
return newConfigSpec;
}
示例4: createWindowSurface
import android.opengl.EGL14; //导入依赖的package包/类
/**
* Creates an EGL surface associated with a Surface.
* <p>
* If this is destined for MediaCodec, the EGLConfig should have the "recordable" attribute.
*/
public EGLSurface createWindowSurface(Object surface) {
if (!(surface instanceof Surface) && !(surface instanceof SurfaceTexture)) {
throw new RuntimeException("invalid surface: " + surface);
}
// Create a window surface, and attach it to the Surface we received.
int[] surfaceAttribs = {
EGL14.EGL_NONE
};
EGLSurface eglSurface = EGL14.eglCreateWindowSurface(mEGLDisplay, mEGLConfig, surface,
surfaceAttribs, 0);
checkEglError("eglCreateWindowSurface");
if (eglSurface == null) {
throw new RuntimeException("surface was null");
}
return eglSurface;
}
示例5: release
import android.opengl.EGL14; //导入依赖的package包/类
/**
* Discard all resources held by this class, notably the EGL context.
*/
public void release() {
if (mEGLDisplay != EGL14.EGL_NO_DISPLAY) {
EGL14.eglDestroySurface(mEGLDisplay, mEGLSurface);
EGL14.eglDestroyContext(mEGLDisplay, mEGLContext);
EGL14.eglReleaseThread();
EGL14.eglTerminate(mEGLDisplay);
}
mSurface.release();
// this causes a bunch of warnings that appear harmless but might confuse someone:
// W BufferQueue: [unnamed-3997-2] cancelBuffer: BufferQueue has been abandoned!
//mSurfaceTexture.release();
mEGLDisplay = EGL14.EGL_NO_DISPLAY;
mEGLContext = EGL14.EGL_NO_CONTEXT;
mEGLSurface = EGL14.EGL_NO_SURFACE;
mTextureRender = null;
mSurface = null;
mSurfaceTexture = null;
}
示例6: getEglConfig
import android.opengl.EGL14; //导入依赖的package包/类
private static EGLConfig getEglConfig(EGLDisplay eglDisplay, int[] configAttributes) {
EGLConfig[] configs = new EGLConfig[1];
int[] numConfigs = new int[1];
if (!EGL14.eglChooseConfig(
eglDisplay, configAttributes, 0, configs, 0, configs.length, numConfigs, 0)) {
throw new RuntimeException(
"eglChooseConfig failed: 0x" + Integer.toHexString(EGL14.eglGetError()));
}
if (numConfigs[0] <= 0) {
throw new RuntimeException("Unable to find any matching EGL config");
}
final EGLConfig eglConfig = configs[0];
if (eglConfig == null) {
throw new RuntimeException("eglChooseConfig returned null");
}
return eglConfig;
}
示例7: createEglContext
import android.opengl.EGL14; //导入依赖的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;
}
示例8: onCameraSurfaceCreate
import android.opengl.EGL14; //导入依赖的package包/类
@Override
public void onCameraSurfaceCreate(SurfaceTexture surfaceTexture) {
Log.d(TAG, "onCameraSurfaceCreate");
mCamera = Camera.open();
Camera.Parameters parameters = mCamera.getParameters();
parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);
mVideoRecorder.createInputSurfaceWindow(EGL14.eglGetCurrentContext());
try {
parameters.setPreviewSize(PREVIEW_WIDTH, PREVIEW_HEIGHT);
mCameraView.setPreviewSize(PREVIEW_HEIGHT, PREVIEW_WIDTH);
mVideoRecorder.setPreviewSize(PREVIEW_HEIGHT, PREVIEW_WIDTH);
mCamera.setParameters(parameters);
mCamera.setPreviewTexture(surfaceTexture);
mCamera.setDisplayOrientation(Profile.ORIENTATION_90);
mCamera.startPreview();
} catch (IOException e) {
e.printStackTrace();
}
isSurfaceReady = true;
}
示例9: release
import android.opengl.EGL14; //导入依赖的package包/类
/**
* Discards all resources held by this class, notably the EGL context. This must be
* called from the thread where the context was created.
* <p>
* On completion, no context will be current.
*/
public void release() {
if (mEGLDisplay != EGL14.EGL_NO_DISPLAY) {
// Android is unusual in that it uses a reference-counted EGLDisplay. So for
// every eglInitialize() we need an eglTerminate().
EGL14.eglMakeCurrent(mEGLDisplay, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_SURFACE,
EGL14.EGL_NO_CONTEXT);
EGL14.eglDestroyContext(mEGLDisplay, mEGLContext);
EGL14.eglReleaseThread();
EGL14.eglTerminate(mEGLDisplay);
}
mEGLDisplay = EGL14.EGL_NO_DISPLAY;
mEGLContext = EGL14.EGL_NO_CONTEXT;
mEGLConfig = null;
}
示例10: OffscreenImage
import android.opengl.EGL14; //导入依赖的package包/类
public OffscreenImage(Bitmap bitmap) {
mWidth = bitmap.getWidth();
mHeight = bitmap.getHeight();
// 初始化EGL环境
mEgl = new EGLEnvironment(EGL14.eglGetCurrentContext(), false);
// 创建离屏缓冲
mInputSurface = mEgl.createOffscreen(mWidth, mHeight);
// 设置渲染环境可用
mInputSurface.makeCurrent();
BitmapInput bitmapInput = new BitmapInput(bitmap);
mPipeline = new RenderPipeline();
mPipeline.onSurfaceCreated(null, null);
mPipeline.setStartPointRender(bitmapInput);
}
示例11: newDisplay
import android.opengl.EGL14; //导入依赖的package包/类
/** @return from a new EGL display connection */
@NonNull
public static EGLDisplay newDisplay() {
final EGLDisplay result = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY);
if (result == EGL14.EGL_NO_DISPLAY) {
logError();
throw new RuntimeException("Unable to get EGL14 display");
} else {
final int[] v = new int[2];
if (!EGL14.eglInitialize(result, v, 0, v, 1)) {
try {
logError();
throw new RuntimeException("Unable to initialize EGL14 display");
} finally {
closeDisplay(result);
}
} else {
logDebug(getDisplayString(result) + " created (EGL" + v[0] + "" + v[1] + ")");
return result;
}
}
}
示例12: onDraw
import android.opengl.EGL14; //导入依赖的package包/类
@Override
public void onDraw(int textureId, FloatBuffer cubeBuffer, FloatBuffer textureBuffer) {
// Draw on screen surface
super.onDraw(textureId, cubeBuffer, textureBuffer);
if (mIsRecording) {
// create encoder surface
if (mCodecInput == null) {
mEGLCore = new EglCore(EGL14.eglGetCurrentContext(), EglCore.FLAG_RECORDABLE);
mCodecInput = new WindowSurface(mEGLCore, mVideoEncoder.getSurface(), false);
}
// Draw on encoder surface
mCodecInput.makeCurrent();
super.onDraw(textureId, cubeBuffer, textureBuffer);
if (mIsRecording) {//super.onDraw maybe executed stopRecording
mCodecInput.swapBuffers();
mVideoEncoder.frameAvailableSoon();
}
}
// Make screen surface be current surface
mEGL.eglMakeCurrent(mEGLDisplay, mEGLScreenSurface, mEGLScreenSurface, mEGLContext);
}
示例13: createEGLSurface
import android.opengl.EGL14; //导入依赖的package包/类
public EGLSurface createEGLSurface(Object surface) {
if (!(surface instanceof Surface) && !(surface instanceof SurfaceTexture)) {
throw new RuntimeException("invalid surface: " + surface);
}
// Create a window surface, and attach it to the Surface we received.
int[] surfaceAttributes = {
EGL14.EGL_NONE
};
EGLSurface eglSurface = EGL14.eglCreateWindowSurface(mEGLDisplay, mEGLConfig, surface,
surfaceAttributes, 0);
if (eglSurface == null) {
throw new RuntimeException("surface was null");
}
return eglSurface;
}
示例14: makeCurrent
import android.opengl.EGL14; //导入依赖的package包/类
/**
* Makes our EGL context current, using the supplied "draw" and "read" surfaces.
*/
public void makeCurrent(EGLSurface drawSurface, EGLSurface readSurface) {
if (mEGLDisplay == EGL14.EGL_NO_DISPLAY) {
// called makeCurrent() before create?
Log.d(TAG, "NOTE: makeCurrent w/o display");
}
if (!EGL14.eglMakeCurrent(mEGLDisplay, drawSurface, readSurface, mEGLContext)) {
throw new RuntimeException("eglMakeCurrent(draw,read) failed");
}
}
示例15: changeDisplay
import android.opengl.EGL14; //导入依赖的package包/类
public void changeDisplay(int key){
mEGLDisplay=EGL14.eglGetDisplay(key);
//获取版本号,[0]为版本号,[1]为子版本号
int[] versions=new int[2];
EGL14.eglInitialize(mEGLDisplay,versions,0,versions,1);
log(EGL14.eglQueryString(mEGLDisplay, EGL14.EGL_VENDOR));
log(EGL14.eglQueryString(mEGLDisplay, EGL14.EGL_VERSION));
log(EGL14.eglQueryString(mEGLDisplay, EGL14.EGL_EXTENSIONS));
}