當前位置: 首頁>>代碼示例>>Java>>正文


Java EGL10.eglMakeCurrent方法代碼示例

本文整理匯總了Java中javax.microedition.khronos.egl.EGL10.eglMakeCurrent方法的典型用法代碼示例。如果您正苦於以下問題:Java EGL10.eglMakeCurrent方法的具體用法?Java EGL10.eglMakeCurrent怎麽用?Java EGL10.eglMakeCurrent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.microedition.khronos.egl.EGL10的用法示例。


在下文中一共展示了EGL10.eglMakeCurrent方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: PixelBuffer

import javax.microedition.khronos.egl.EGL10; //導入方法依賴的package包/類
public PixelBuffer(final int width, final int height) {
    mWidth = width;
    mHeight = height;

    int[] version = new int[2];
    int[] attribList = new int[] {
            EGL_WIDTH, mWidth,
            EGL_HEIGHT, mHeight,
            EGL_NONE
    };

    // No error checking performed, minimum required code to elucidate logic
    mEGL = (EGL10) EGLContext.getEGL();
    mEGLDisplay = mEGL.eglGetDisplay(EGL_DEFAULT_DISPLAY);
    mEGL.eglInitialize(mEGLDisplay, version);
    mEGLConfig = chooseConfig(); // Choosing a config is a little more
                                 // complicated

    // mEGLContext = mEGL.eglCreateContext(mEGLDisplay, mEGLConfig,
    // EGL_NO_CONTEXT, null);
    int EGL_CONTEXT_CLIENT_VERSION = 0x3098;
    int[] attrib_list = {
            EGL_CONTEXT_CLIENT_VERSION, 2,
            EGL10.EGL_NONE
    };
    mEGLContext = mEGL.eglCreateContext(mEGLDisplay, mEGLConfig, EGL_NO_CONTEXT, attrib_list);

    mEGLSurface = mEGL.eglCreatePbufferSurface(mEGLDisplay, mEGLConfig, attribList);
    mEGL.eglMakeCurrent(mEGLDisplay, mEGLSurface, mEGLSurface, mEGLContext);

    mGL = (GL10) mEGLContext.getGL();

    // Record thread owner of OpenGL context
    mThreadOwner = Thread.currentThread().getName();
}
 
開發者ID:zhangyaqiang,項目名稱:Fatigue-Detection,代碼行數:36,代碼來源:PixelBuffer.java

示例2: clearSurface

import javax.microedition.khronos.egl.EGL10; //導入方法依賴的package包/類
/**
 * clear data from surface using opengl
 */
private void clearSurface(Object texture) {
  EGL10 egl = (EGL10) EGLContext.getEGL();
  EGLDisplay display = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
  egl.eglInitialize(display, null);

  int[] attribList = {
      EGL10.EGL_RED_SIZE, 8, EGL10.EGL_GREEN_SIZE, 8, EGL10.EGL_BLUE_SIZE, 8,
      EGL10.EGL_ALPHA_SIZE, 8, EGL10.EGL_RENDERABLE_TYPE, EGL10.EGL_WINDOW_BIT, EGL10.EGL_NONE, 0,
      // placeholder for recordable [@-3]
      EGL10.EGL_NONE
  };
  EGLConfig[] configs = new EGLConfig[1];
  int[] numConfigs = new int[1];
  egl.eglChooseConfig(display, attribList, configs, configs.length, numConfigs);
  EGLConfig config = configs[0];
  EGLContext context = egl.eglCreateContext(display, config, EGL10.EGL_NO_CONTEXT, new int[] {
      12440, 2, EGL10.EGL_NONE
  });
  EGLSurface eglSurface = egl.eglCreateWindowSurface(display, config, texture, new int[] {
      EGL10.EGL_NONE
  });

  egl.eglMakeCurrent(display, eglSurface, eglSurface, context);
  GLES20.glClearColor(0, 0, 0, 1);
  GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
  egl.eglSwapBuffers(display, eglSurface);
  egl.eglDestroySurface(display, eglSurface);
  egl.eglMakeCurrent(display, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT);
  egl.eglDestroyContext(display, context);
  egl.eglTerminate(display);
}
 
開發者ID:pedroSG94,項目名稱:rtmp-rtsp-stream-client-java,代碼行數:35,代碼來源:Camera1ApiManager.java

示例3: ImageEglSurface

import javax.microedition.khronos.egl.EGL10; //導入方法依賴的package包/類
public ImageEglSurface(final int width, final int height) {
    mWidth = width;
    mHeight = height;

    int[] version = new int[2];
    int[] surfaceAttribList = {
            EGL10.EGL_WIDTH, width, EGL10.EGL_HEIGHT, height, EGL10.EGL_NONE
    };

    mEGL = (EGL10) EGLContext.getEGL();
    mEGLDisplay = mEGL.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
    if (mEGLDisplay == EGL10.EGL_NO_DISPLAY) {
        throw new RuntimeException("unable to get EGL10 display");
    }

    if (!mEGL.eglInitialize(mEGLDisplay, version)) {
        mEGLDisplay = null;
        throw new RuntimeException("unable to initialize EGL14");
    }

    mEGLConfig = getConfig();
    if (mEGLConfig == null) {
        throw new RuntimeException("Unable to find a suitable EGLConfig");
    }
    int[] attribList = {
            EGL_CONTEXT_CLIENT_VERSION /*EGL14.EGL_CONTEXT_CLIENT_VERSION*/, 2, EGL14.EGL_NONE
    };
    mEGLContext = mEGL.eglCreateContext(mEGLDisplay, mEGLConfig, EGL_NO_CONTEXT, attribList);
    mEGLSurface = mEGL.eglCreatePbufferSurface(mEGLDisplay, mEGLConfig, surfaceAttribList);
    mEGL.eglMakeCurrent(mEGLDisplay, mEGLSurface, mEGLSurface, mEGLContext);
    mGL = (GL10) mEGLContext.getGL();
}
 
開發者ID:hoanganhtuan95ptit,項目名稱:EditPhoto,代碼行數:33,代碼來源:ImageEglSurface.java

示例4: initEGL

import javax.microedition.khronos.egl.EGL10; //導入方法依賴的package包/類
@WorkerThread
private void initEGL() {
    egl10 = (EGL10) EGLContext.getEGL();
    eglDisplay = egl10.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
    if (eglDisplay == EGL10.EGL_NO_DISPLAY) {
        raiseEGLInitError();
    }

    int[] majorMinorVersions = new int[2];
    if (!egl10.eglInitialize(eglDisplay, majorMinorVersions)) {
        raiseEGLInitError();
    }

    EGLConfig[] eglConfigs = new EGLConfig[1];
    int[] numOfConfigs = new int[1];
    if (!egl10.eglChooseConfig(eglDisplay, EGL_CONFIG_ATTRIBUTE_LIST, eglConfigs, 1, numOfConfigs)) {
        raiseEGLInitError();
    }
    LogUtil.v(TAG, "createWindowSurface by" + mNativeWindow.get());
    eglSurface = egl10.eglCreateWindowSurface(eglDisplay, eglConfigs[0], mNativeWindow.get(), EGL_SURFACE_ATTRIBUTE_LIST);
    if (eglSurface == EGL10.EGL_NO_SURFACE) {
        raiseEGLInitError();
    }

    eglContext = egl10.eglCreateContext(eglDisplay, eglConfigs[0], EGL10.EGL_NO_CONTEXT, EGL_CONTEXT_ATTRIBUTE_LIST);
    if (eglContext == EGL10.EGL_NO_CONTEXT) {
        raiseEGLInitError();
    }

    if (!egl10.eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext)) {
        raiseEGLInitError();
    }

    LogUtil.d(TAG, "initEGL");
}
 
開發者ID:TedaLIEz,項目名稱:ParsingPlayer,代碼行數:36,代碼來源:VideoRenderThread.java

示例5: getMaxTextureEgl10

import javax.microedition.khronos.egl.EGL10; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private static int getMaxTextureEgl10() {
    EGL10 egl = (EGL10) javax.microedition.khronos.egl.EGLContext.getEGL();

    javax.microedition.khronos.egl.EGLDisplay dpy = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
    int[] vers = new int[2];
    egl.eglInitialize(dpy, vers);

    int[] configAttr = {
            EGL10.EGL_COLOR_BUFFER_TYPE, EGL10.EGL_RGB_BUFFER,
            EGL10.EGL_LEVEL, 0,
            EGL10.EGL_SURFACE_TYPE, EGL10.EGL_PBUFFER_BIT,
            EGL10.EGL_NONE
    };
    javax.microedition.khronos.egl.EGLConfig[] configs = new javax.microedition.khronos.egl.EGLConfig[1];
    int[] numConfig = new int[1];
    egl.eglChooseConfig(dpy, configAttr, configs, 1, numConfig);
    if (numConfig[0] == 0) {
        return 0;
    }
    javax.microedition.khronos.egl.EGLConfig config = configs[0];

    int[] surfAttr = {
            EGL10.EGL_WIDTH, 64,
            EGL10.EGL_HEIGHT, 64,
            EGL10.EGL_NONE
    };
    javax.microedition.khronos.egl.EGLSurface surf = egl.eglCreatePbufferSurface(dpy, config, surfAttr);
    final int EGL_CONTEXT_CLIENT_VERSION = 0x3098;  // missing in EGL10
    int[] ctxAttrib = {
            EGL_CONTEXT_CLIENT_VERSION, 1,
            EGL10.EGL_NONE
    };
    javax.microedition.khronos.egl.EGLContext ctx = egl.eglCreateContext(dpy, config, EGL10.EGL_NO_CONTEXT, ctxAttrib);
    egl.eglMakeCurrent(dpy, surf, surf, ctx);
    int[] maxSize = new int[1];
    GLES10.glGetIntegerv(GLES10.GL_MAX_TEXTURE_SIZE, maxSize, 0);
    egl.eglMakeCurrent(dpy, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE,
            EGL10.EGL_NO_CONTEXT);
    egl.eglDestroySurface(dpy, surf);
    egl.eglDestroyContext(dpy, ctx);
    egl.eglTerminate(dpy);

    return maxSize[0];
}
 
開發者ID:Alcatraz323,項目名稱:MaterialOCR,代碼行數:46,代碼來源:EglUtils.java

示例6: initGL

import javax.microedition.khronos.egl.EGL10; //導入方法依賴的package包/類
private boolean initGL() {
    egl10 = (EGL10) EGLContext.getEGL();

    eglDisplay = egl10.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
    if (eglDisplay == EGL10.EGL_NO_DISPLAY) {
        FileLog.e("tmessages", "eglGetDisplay failed " + GLUtils.getEGLErrorString(egl10.eglGetError()));
        finish();
        return false;
    }

    int[] version = new int[2];
    if (!egl10.eglInitialize(eglDisplay, version)) {
        FileLog.e("tmessages", "eglInitialize failed " + GLUtils.getEGLErrorString(egl10.eglGetError()));
        finish();
        return false;
    }

    int[] configsCount = new int[1];
    EGLConfig[] configs = new EGLConfig[1];
    int[] configSpec = new int[]{
            EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
            EGL10.EGL_RED_SIZE, 8,
            EGL10.EGL_GREEN_SIZE, 8,
            EGL10.EGL_BLUE_SIZE, 8,
            EGL10.EGL_ALPHA_SIZE, 8,
            EGL10.EGL_DEPTH_SIZE, 0,
            EGL10.EGL_STENCIL_SIZE, 0,
            EGL10.EGL_NONE
    };
    if (!egl10.eglChooseConfig(eglDisplay, configSpec, configs, 1, configsCount)) {
        FileLog.e("tmessages", "eglChooseConfig failed " + GLUtils.getEGLErrorString(egl10.eglGetError()));
        finish();
        return false;
    } else if (configsCount[0] > 0) {
        eglConfig = configs[0];
    } else {
        FileLog.e("tmessages", "eglConfig not initialized");
        finish();
        return false;
    }

    int[] attrib_list = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE};
    eglContext = egl10.eglCreateContext(eglDisplay, eglConfig, EGL10.EGL_NO_CONTEXT, attrib_list);
    if (eglContext == null) {
        FileLog.e("tmessages", "eglCreateContext failed " + GLUtils.getEGLErrorString(egl10.eglGetError()));
        finish();
        return false;
    }

    if (surfaceTexture instanceof SurfaceTexture) {
        eglSurface = egl10.eglCreateWindowSurface(eglDisplay, eglConfig, surfaceTexture, null);
    } else {
        finish();
        return false;
    }

    if (eglSurface == null || eglSurface == EGL10.EGL_NO_SURFACE) {
        FileLog.e("tmessages", "createWindowSurface failed " + GLUtils.getEGLErrorString(egl10.eglGetError()));
        finish();
        return false;
    }
    if (!egl10.eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext)) {
        FileLog.e("tmessages", "eglMakeCurrent failed " + GLUtils.getEGLErrorString(egl10.eglGetError()));
        finish();
        return false;
    }

    GLES20.glEnable(GLES20.GL_BLEND);
    GLES20.glDisable(GLES20.GL_DITHER);
    GLES20.glDisable(GLES20.GL_STENCIL_TEST);
    GLES20.glDisable(GLES20.GL_DEPTH_TEST);

    painting.setupShaders();
    checkBitmap();
    painting.setBitmap(bitmap);

    Utils.HasGLError();

    return true;
}
 
開發者ID:pooyafaroka,項目名稱:PlusGram,代碼行數:81,代碼來源:RenderView.java

示例7: initGL

import javax.microedition.khronos.egl.EGL10; //導入方法依賴的package包/類
private void initGL(SurfaceTexture texture) {
    egl10 = (EGL10) EGLContext.getEGL();

    eglDisplay = egl10.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
    if (eglDisplay == EGL10.EGL_NO_DISPLAY) {
        throw new RuntimeException("eglGetDisplay failed " +
                android.opengl.GLUtils.getEGLErrorString(egl10.eglGetError()));
    }

    int[] version = new int[2];
    if (!egl10.eglInitialize(eglDisplay, version)) {
        throw new RuntimeException("eglInitialize failed " +
                android.opengl.GLUtils.getEGLErrorString(egl10.eglGetError()));
    }

    int[] configsCount = new int[1];
    EGLConfig[] configs = new EGLConfig[1];
    int[] configSpec = {
            EGL10.EGL_RENDERABLE_TYPE,
            EGL_OPENGL_ES2_BIT,
            EGL10.EGL_RED_SIZE, 8,
            EGL10.EGL_GREEN_SIZE, 8,
            EGL10.EGL_BLUE_SIZE, 8,
            EGL10.EGL_ALPHA_SIZE, 8,
            EGL10.EGL_DEPTH_SIZE, 0,
            EGL10.EGL_STENCIL_SIZE, 0,
            EGL10.EGL_NONE
    };

    EGLConfig eglConfig = null;
    if (!egl10.eglChooseConfig(eglDisplay, configSpec, configs, 1, configsCount)) {
        throw new IllegalArgumentException("eglChooseConfig failed " +
                android.opengl.GLUtils.getEGLErrorString(egl10.eglGetError()));
    } else if (configsCount[0] > 0) {
        eglConfig = configs[0];
    }
    if (eglConfig == null) {
        throw new RuntimeException("eglConfig not initialized");
    }

    int[] attrib_list = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE};
    eglContext = egl10.eglCreateContext(eglDisplay, eglConfig, EGL10.EGL_NO_CONTEXT, attrib_list);
    eglSurface = egl10.eglCreateWindowSurface(eglDisplay, eglConfig, texture, null);

    if (eglSurface == null || eglSurface == EGL10.EGL_NO_SURFACE) {
        int error = egl10.eglGetError();
        if (error == EGL10.EGL_BAD_NATIVE_WINDOW) {
            Log.e(TAG, "eglCreateWindowSurface returned EGL10.EGL_BAD_NATIVE_WINDOW");
            return;
        }
        throw new RuntimeException("eglCreateWindowSurface failed " +
                android.opengl.GLUtils.getEGLErrorString(error));
    }

    if (!egl10.eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext)) {
        throw new RuntimeException("eglMakeCurrent failed " +
                android.opengl.GLUtils.getEGLErrorString(egl10.eglGetError()));
    }
}
 
開發者ID:SimonCherryGZ,項目名稱:face-landmark-android,代碼行數:60,代碼來源:MyCameraRenderer.java


注:本文中的javax.microedition.khronos.egl.EGL10.eglMakeCurrent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。