Java 类javax.microedition.khronos.egl.EGLContext 实例源码

项目:19porn    文件:EGLUtil.java   
@Override
public EGLContext createContext(EGL10 egl, EGLDisplay display, EGLConfig eglConfig){
    final int EGL_CONTEXT_CLIENT_VERSION = 0x3098;

    int[] attrib_list = {
            EGL_CONTEXT_CLIENT_VERSION, 2,
            EGL10.EGL_NONE
    };
    EGLContext mEGLContext = egl.eglCreateContext(display, eglConfig, EGL10.EGL_NO_CONTEXT,
            attrib_list);
    //checkEglError("eglCreateContext");
    if (mEGLContext == null) {
        throw new RuntimeException("null context");
    }
    return mEGLContext;
}
项目:Agora-Video-Source-Android    文件:CustomizedCameraRenderer.java   
public EGLContext createContext(EGL10 egl, EGLDisplay display, EGLConfig eglConfig) {
    Log.d(LOG_TAG, "createContext " + egl + " " + display + " " + eglConfig);
    checkEglError("before createContext", egl);
    int[] attrib_list = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE};

    EGLContext ctx;

    if (mRenderer.mEGLCurrentContext == null) {
        mRenderer.mEGLCurrentContext = egl.eglCreateContext(display, eglConfig,
                EGL10.EGL_NO_CONTEXT, attrib_list);
        ctx = mRenderer.mEGLCurrentContext;
    } else {
        ctx = mRenderer.mEGLCurrentContext;
    }
    checkEglError("after createContext", egl);
    return ctx;
}
项目:android_nextgis_mobile    文件:MapDrawing.java   
public void initDrawContext(
            EGL10 egl,
            EGLDisplay eglDisplay,
            EGLSurface eglSurface,
            EGLContext eglContext)
    {
        mEgl = egl;
        mEglDisplay = eglDisplay;
        mEglSurface = eglSurface;
        mEglContext = eglContext;

        if (0 == mMapId) { return; }

//        makeCurrent();
        Api.ngsMapInit(mMapId);
    }
项目:android_nextgis_mobile    文件:MapGlView.java   
@Override
public EGLContext createContext(
        EGL10 egl,
        EGLDisplay display,
        EGLConfig eglConfig)
{
    Log.w(ConstantsUI.TAG, "creating OpenGL ES 2.0 context");
    checkEglError(egl, "Before eglCreateContext");
    int[] attrib_list = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE};
    mEglContext =
            egl.eglCreateContext(display, eglConfig, EGL10.EGL_NO_CONTEXT, attrib_list);
    if (EGL10.EGL_NO_CONTEXT == mEglContext) {
        throwEglException(egl, "eglCreateContext");
    }
    return mEglContext;
}
项目:TPlayer    文件:EGL.java   
public void start() {
  mEgl = (EGL10) EGLContext.getEGL();
  mEglDisplay = mEgl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);

  if (mEglDisplay == EGL10.EGL_NO_DISPLAY) {
    throw new RuntimeException("eglGetDisplay failed");
  }

  int[] version = new int[2];
  if (!mEgl.eglInitialize(mEglDisplay, version)) {
    throw new RuntimeException("eglInitialize failed");
  }
  mEglConfig = mEGLConfigChooser.chooseConfig(mEgl, mEglDisplay);

  mEglContext = mEGLContextFactory.createContext(mEgl, mEglDisplay, mEglConfig);
  if (mEglContext == null || mEglContext == EGL10.EGL_NO_CONTEXT) {
    mEglContext = null;
    throwEglException("createContext");
  }

  mEglSurface = null;
}
项目:QuanMinTV    文件:EGL.java   
public void start() {
  mEgl = (EGL10) EGLContext.getEGL();
  mEglDisplay = mEgl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);

  if (mEglDisplay == EGL10.EGL_NO_DISPLAY) {
    throw new RuntimeException("eglGetDisplay failed");
  }

  int[] version = new int[2];
  if (!mEgl.eglInitialize(mEglDisplay, version)) {
    throw new RuntimeException("eglInitialize failed");
  }
  mEglConfig = mEGLConfigChooser.chooseConfig(mEgl, mEglDisplay);

  mEglContext = mEGLContextFactory.createContext(mEgl, mEglDisplay, mEglConfig);
  if (mEglContext == null || mEglContext == EGL10.EGL_NO_CONTEXT) {
    mEglContext = null;
    throwEglException("createContext");
  }

  mEglSurface = null;
}
项目:YalpStore    文件:EglExtensionRetriever.java   
private static void addExtensionsForConfig(EGL10 egl10, EGLDisplay egldisplay, EGLConfig eglconfig, int ai[], int ai1[], Set<String> set) {
    EGLContext eglContext = egl10.eglCreateContext(egldisplay, eglconfig, EGL10.EGL_NO_CONTEXT, ai1);
    if (eglContext == EGL10.EGL_NO_CONTEXT) {
        return;
    }
    javax.microedition.khronos.egl.EGLSurface eglSurface = egl10.eglCreatePbufferSurface(egldisplay, eglconfig, ai);
    if (eglSurface == EGL10.EGL_NO_SURFACE) {
        egl10.eglDestroyContext(egldisplay, eglContext);
    } else {
        egl10.eglMakeCurrent(egldisplay, eglSurface, eglSurface, eglContext);
        String s = GLES10.glGetString(7939);
        if (!TextUtils.isEmpty(s)) {
            String as[] = s.split(" ");
            int i = as.length;
            for (int j = 0; j < i; j++) {
                set.add(as[j]);
            }
        }
        egl10.eglMakeCurrent(egldisplay, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT);
        egl10.eglDestroySurface(egldisplay, eglSurface);
        egl10.eglDestroyContext(egldisplay, eglContext);
    }
}
项目:react-native-video    文件:EGL.java   
public void start() {
  mEgl = (EGL10) EGLContext.getEGL();
  mEglDisplay = mEgl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);

  if (mEglDisplay == EGL10.EGL_NO_DISPLAY) {
    throw new RuntimeException("eglGetDisplay failed");
  }

  int[] version = new int[2];
  if (!mEgl.eglInitialize(mEglDisplay, version)) {
    throw new RuntimeException("eglInitialize failed");
  }
  mEglConfig = mEGLConfigChooser.chooseConfig(mEgl, mEglDisplay);

  mEglContext = mEGLContextFactory.createContext(mEgl, mEglDisplay, mEglConfig);
  if (mEglContext == null || mEglContext == EGL10.EGL_NO_CONTEXT) {
    mEglContext = null;
    throwEglException("createContext");
  }

  mEglSurface = null;
}
项目:NetEasyNews    文件:EGL.java   
public void start() {
  mEgl = (EGL10) EGLContext.getEGL();
  mEglDisplay = mEgl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);

  if (mEglDisplay == EGL10.EGL_NO_DISPLAY) {
    throw new RuntimeException("eglGetDisplay failed");
  }

  int[] version = new int[2];
  if (!mEgl.eglInitialize(mEglDisplay, version)) {
    throw new RuntimeException("eglInitialize failed");
  }
  mEglConfig = mEGLConfigChooser.chooseConfig(mEgl, mEglDisplay);

  mEglContext = mEGLContextFactory.createContext(mEgl, mEglDisplay, mEglConfig);
  if (mEglContext == null || mEglContext == EGL10.EGL_NO_CONTEXT) {
    mEglContext = null;
    throwEglException("createContext");
  }

  mEglSurface = null;
}
项目:FriendsCameraSDK-android    文件:VrUtils.java   
public static int getMaximumTextureSize() {
    EGL10 egl = (EGL10) EGLContext.getEGL();
    EGLDisplay display = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);

    int[] version = new int[2];
    egl.eglInitialize(display, version);

    int[] totalConfigurations = new int[1];
    egl.eglGetConfigs(display, null, 0, totalConfigurations);

    EGLConfig[] configurationsList = new EGLConfig[totalConfigurations[0]];
    egl.eglGetConfigs(display, configurationsList, totalConfigurations[0], totalConfigurations);

    int[] textureSize = new int[1];
    int maximumTextureSize = 0;

    for (int i = 0; i < totalConfigurations[0]; i++) {
        egl.eglGetConfigAttrib(display, configurationsList[i], EGL10.EGL_MAX_PBUFFER_WIDTH, textureSize);
        if (maximumTextureSize < textureSize[0]) {
            maximumTextureSize = textureSize[0];
        }
    }
    egl.eglTerminate(display);

    return maximumTextureSize;
}
项目:android_gl_viewer    文件:MapDrawing.java   
public void initDrawContext(
            EGL10 egl,
            EGLDisplay eglDisplay,
            EGLSurface eglSurface,
            EGLContext eglContext)
    {
        mEgl = egl;
        mEglDisplay = eglDisplay;
        mEglSurface = eglSurface;
        mEglContext = eglContext;

        if (0 == mMapId) { return; }

//        makeCurrent();
        Api.ngsMapInit(mMapId);
    }
项目:meishiDemo    文件:EGL.java   
public void start() {
  mEgl = (EGL10) EGLContext.getEGL();
  mEglDisplay = mEgl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);

  if (mEglDisplay == EGL10.EGL_NO_DISPLAY) {
    throw new RuntimeException("eglGetDisplay failed");
  }

  int[] version = new int[2];
  if (!mEgl.eglInitialize(mEglDisplay, version)) {
    throw new RuntimeException("eglInitialize failed");
  }
  mEglConfig = mEGLConfigChooser.chooseConfig(mEgl, mEglDisplay);

  mEglContext = mEGLContextFactory.createContext(mEgl, mEglDisplay, mEglConfig);
  if (mEglContext == null || mEglContext == EGL10.EGL_NO_CONTEXT) {
    mEglContext = null;
    throwEglException("createContext");
  }

  mEglSurface = null;
}
项目:ZombieInvadersVR    文件:CardBoardGraphics.java   
protected boolean checkGL20 () {
   EGL10 egl = (EGL10)EGLContext.getEGL();
   EGLDisplay display = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);

   int[] version = new int[2];
   egl.eglInitialize(display, version);

   int EGL_OPENGL_ES2_BIT = 4;
   int[] configAttribs = {EGL10.EGL_RED_SIZE, 4, EGL10.EGL_GREEN_SIZE, 4, EGL10.EGL_BLUE_SIZE, 4, EGL10.EGL_RENDERABLE_TYPE,
      EGL_OPENGL_ES2_BIT, EGL10.EGL_NONE};

   EGLConfig[] configs = new EGLConfig[10];
   int[] num_config = new int[1];
   egl.eglChooseConfig(display, configAttribs, configs, 10, num_config);
   egl.eglTerminate(display);
   return num_config[0] > 0;
}
项目:ZombieInvadersVR    文件:CardBoardGraphics.java   
private void logConfig (EGLConfig config) {
   EGL10 egl = (EGL10)EGLContext.getEGL();
   EGLDisplay display = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
   int r = getAttrib(egl, display, config, EGL10.EGL_RED_SIZE, 0);
   int g = getAttrib(egl, display, config, EGL10.EGL_GREEN_SIZE, 0);
   int b = getAttrib(egl, display, config, EGL10.EGL_BLUE_SIZE, 0);
   int a = getAttrib(egl, display, config, EGL10.EGL_ALPHA_SIZE, 0);
   int d = getAttrib(egl, display, config, EGL10.EGL_DEPTH_SIZE, 0);
   int s = getAttrib(egl, display, config, EGL10.EGL_STENCIL_SIZE, 0);
   int samples = Math.max(getAttrib(egl, display, config, EGL10.EGL_SAMPLES, 0),
      getAttrib(egl, display, config, GdxEglConfigChooser.EGL_COVERAGE_SAMPLES_NV, 0));
   boolean coverageSample = getAttrib(egl, display, config, GdxEglConfigChooser.EGL_COVERAGE_SAMPLES_NV, 0) != 0;

   Gdx.app.log(LOG_TAG, "framebuffer: (" + r + ", " + g + ", " + b + ", " + a + ")");
   Gdx.app.log(LOG_TAG, "depthbuffer: (" + d + ")");
   Gdx.app.log(LOG_TAG, "stencilbuffer: (" + s + ")");
   Gdx.app.log(LOG_TAG, "samples: (" + samples + ")");
   Gdx.app.log(LOG_TAG, "coverage sampling: (" + coverageSample + ")");

   bufferFormat = new BufferFormat(r, g, b, a, d, s, samples, coverageSample);
}
项目:android_nextgis_mobile    文件:MapGlView.java   
@Override
public EGLContext createContext(
        EGL10 egl,
        EGLDisplay display,
        EGLConfig eglConfig)
{
    Log.w(ConstantsUI.TAG, "creating OpenGL ES 2.0 context");
    checkEglError(egl, "Before eglCreateContext");
    int[] attrib_list = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE};
    mEglContext =
            egl.eglCreateContext(display, eglConfig, EGL10.EGL_NO_CONTEXT, attrib_list);
    if (EGL10.EGL_NO_CONTEXT == mEglContext) {
        throwEglException(egl, "eglCreateContext");
    }
    return mEglContext;
}
项目:MyHearts    文件:EGL.java   
public void start() {
  mEgl = (EGL10) EGLContext.getEGL();
  mEglDisplay = mEgl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);

  if (mEglDisplay == EGL10.EGL_NO_DISPLAY) {
    throw new RuntimeException("eglGetDisplay failed");
  }

  int[] version = new int[2];
  if (!mEgl.eglInitialize(mEglDisplay, version)) {
    throw new RuntimeException("eglInitialize failed");
  }
  mEglConfig = mEGLConfigChooser.chooseConfig(mEgl, mEglDisplay);

  mEglContext = mEGLContextFactory.createContext(mEgl, mEglDisplay, mEglConfig);
  if (mEglContext == null || mEglContext == EGL10.EGL_NO_CONTEXT) {
    mEglContext = null;
    throwEglException("createContext");
  }

  mEglSurface = null;
}
项目:HPlayer    文件:EGL.java   
public void start() {
  mEgl = (EGL10) EGLContext.getEGL();
  mEglDisplay = mEgl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);

  if (mEglDisplay == EGL10.EGL_NO_DISPLAY) {
    throw new RuntimeException("eglGetDisplay failed");
  }

  int[] version = new int[2];
  if (!mEgl.eglInitialize(mEglDisplay, version)) {
    throw new RuntimeException("eglInitialize failed");
  }
  mEglConfig = mEGLConfigChooser.chooseConfig(mEgl, mEglDisplay);

  mEglContext = mEGLContextFactory.createContext(mEgl, mEglDisplay, mEglConfig);
  if (mEglContext == null || mEglContext == EGL10.EGL_NO_CONTEXT) {
    mEglContext = null;
    throwEglException("createContext");
  }

  mEglSurface = null;
}
项目:PeSanKita-android    文件:BitmapUtil.java   
public static int getMaxTextureSize() {
  final int IMAGE_MAX_BITMAP_DIMENSION = 2048;

  EGL10 egl = (EGL10) EGLContext.getEGL();
  EGLDisplay display = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);

  int[] version = new int[2];
  egl.eglInitialize(display, version);

  int[] totalConfigurations = new int[1];
  egl.eglGetConfigs(display, null, 0, totalConfigurations);

  EGLConfig[] configurationsList = new EGLConfig[totalConfigurations[0]];
  egl.eglGetConfigs(display, configurationsList, totalConfigurations[0], totalConfigurations);

  int[] textureSize = new int[1];
  int maximumTextureSize = 0;

  for (int i = 0; i < totalConfigurations[0]; i++) {
    egl.eglGetConfigAttrib(display, configurationsList[i], EGL10.EGL_MAX_PBUFFER_WIDTH, textureSize);

    if (maximumTextureSize < textureSize[0])
      maximumTextureSize = textureSize[0];
  }

  egl.eglTerminate(display);

  return Math.max(maximumTextureSize, IMAGE_MAX_BITMAP_DIMENSION);
}
项目:airgram    文件:OutputSurface.java   
private void eglSetup(int width, int height) {
    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, null)) {
        mEGLDisplay = null;
        throw new RuntimeException("unable to initialize EGL10");
    }

    int[] attribList = {
            EGL10.EGL_RED_SIZE, 8,
            EGL10.EGL_GREEN_SIZE, 8,
            EGL10.EGL_BLUE_SIZE, 8,
            EGL10.EGL_ALPHA_SIZE, 8,
            EGL10.EGL_SURFACE_TYPE, EGL10.EGL_PBUFFER_BIT,
            EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
            EGL10.EGL_NONE
    };
    EGLConfig[] configs = new EGLConfig[1];
    int[] numConfigs = new int[1];
    if (!mEGL.eglChooseConfig(mEGLDisplay, attribList, configs, configs.length, numConfigs)) {
        throw new RuntimeException("unable to find RGB888+pbuffer EGL config");
    }
    int[] attrib_list = {
            EGL_CONTEXT_CLIENT_VERSION, 2,
            EGL10.EGL_NONE
    };
    mEGLContext = mEGL.eglCreateContext(mEGLDisplay, configs[0], EGL10.EGL_NO_CONTEXT, attrib_list);
    checkEglError("eglCreateContext");
    if (mEGLContext == null) {
        throw new RuntimeException("null context");
    }
    int[] surfaceAttribs = {
            EGL10.EGL_WIDTH, width,
            EGL10.EGL_HEIGHT, height,
            EGL10.EGL_NONE
    };
    mEGLSurface = mEGL.eglCreatePbufferSurface(mEGLDisplay, configs[0], surfaceAttribs);
    checkEglError("eglCreatePbufferSurface");
    if (mEGLSurface == null) {
        throw new RuntimeException("surface was null");
    }
}
项目:CSipSimple    文件:ViEAndroidGLES20.java   
public EGLContext createContext(EGL10 egl, EGLDisplay display, EGLConfig eglConfig) {
    Log.w(TAG, "creating OpenGL ES 2.0 context");
    checkEglError("Before eglCreateContext", egl);
    int[] attrib_list = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE };
    EGLContext context = egl.eglCreateContext(display, eglConfig,
            EGL10.EGL_NO_CONTEXT, attrib_list);
    checkEglError("After eglCreateContext", egl);
    return context;
}
项目:alpha-movie    文件:GLTextureView.java   
public EGLContext createContext(EGL10 egl, EGLDisplay display, EGLConfig config) {
    int[] attrib_list = {EGL_CONTEXT_CLIENT_VERSION, mEGLContextClientVersion,
            EGL10.EGL_NONE };

    return egl.eglCreateContext(display, config, EGL10.EGL_NO_CONTEXT,
            mEGLContextClientVersion != 0 ? attrib_list : null);
}
项目:alpha-movie    文件:GLTextureView.java   
public void destroyContext(EGL10 egl, EGLDisplay display,
                           EGLContext context) {
    if (!egl.eglDestroyContext(display, context)) {
        Log.e("DefaultContextFactory", "display:" + display + " context: " + context);
        if (LOG_THREADS) {
            Log.i("DefaultContextFactory", "tid=" + Thread.currentThread().getId());
        }
        EglHelper.throwEglException("eglDestroyContex", egl.eglGetError());
    }
}
项目:Fatigue-Detection    文件:PixelBuffer.java   
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();
}
项目:android_nextgis_mobile    文件:MapGlView.java   
@Override
public void destroyContext(
        EGL10 egl,
        EGLDisplay display,
        EGLContext context)
{
    if (!egl.eglDestroyContext(display, context)) {
        throwEglException(egl, "eglDestroyContex");
    }
    mEglContext = null;
}
项目:Moment    文件:TextureSizeUtils.java   
public static int getMaxTextureSize() {
    // Safe minimum default size
    final int IMAGE_MAX_BITMAP_DIMENSION = 2048;

    // Get EGL Display
    EGL10 egl = (EGL10) EGLContext.getEGL();
    EGLDisplay display = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);

    // Initialise
    int[] version = new int[2];
    egl.eglInitialize(display, version);

    // Query total number of configurations
    int[] totalConfigurations = new int[1];
    egl.eglGetConfigs(display, null, 0, totalConfigurations);

    // Query actual list configurations
    EGLConfig[] configurationsList = new EGLConfig[totalConfigurations[0]];
    egl.eglGetConfigs(display, configurationsList, totalConfigurations[0], totalConfigurations);

    int[] textureSize = new int[1];
    int maximumTextureSize = 0;

    // Iterate through all the configurations to located the maximum texture size
    for (int i = 0; i < totalConfigurations[0]; i++) {
        // Only need to check for width since opengl textures are always squared
        egl.eglGetConfigAttrib(display, configurationsList[i], EGL10.EGL_MAX_PBUFFER_WIDTH, textureSize);

        // Keep track of the maximum texture size
        if (maximumTextureSize < textureSize[0])
            maximumTextureSize = textureSize[0];
    }

    // Release
    egl.eglTerminate(display);

    // Return largest texture size found, or default
    return Math.max(maximumTextureSize, IMAGE_MAX_BITMAP_DIMENSION);
}
项目:rtmp-rtsp-stream-client-java    文件:Camera1ApiManager.java   
/**
 * 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);
}
项目:EditPhoto    文件:ImageEglSurface.java   
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();
}
项目:Android_OpenGL_Demo    文件:GLWallpaperService.java   
public EGLContext createContext(EGL10 egl, EGLDisplay display,
        EGLConfig config, int eglContextClientVersion) {
    int[] attrib_list = { EGL_CONTEXT_CLIENT_VERSION,
            eglContextClientVersion, EGL10.EGL_NONE };

    return egl.eglCreateContext(display, config, EGL10.EGL_NO_CONTEXT,
            eglContextClientVersion != 0 ? attrib_list : null);
}
项目:Android_OpenGL_Demo    文件:GLWallpaperService.java   
public EGLContext createContext(EGL10 egl, EGLDisplay display,
        EGLConfig config, int eglContextClientVersion) {
    int[] attrib_list = { EGL_CONTEXT_CLIENT_VERSION,
            eglContextClientVersion, EGL10.EGL_NONE };

    return egl.eglCreateContext(display, config, EGL10.EGL_NO_CONTEXT,
            eglContextClientVersion != 0 ? attrib_list : null);
}
项目:EZFilter    文件:GLSurfaceView.java   
public EGLContext createContext(EGL10 egl, EGLDisplay display, EGLConfig config) {
    int[] attrib_list = {EGL_CONTEXT_CLIENT_VERSION, mEGLContextClientVersion,
            EGL10.EGL_NONE};

    return egl.eglCreateContext(display, config, EGL10.EGL_NO_CONTEXT,
            mEGLContextClientVersion != 0 ? attrib_list : null);
}
项目:EZFilter    文件:GLSurfaceView.java   
public void destroyContext(EGL10 egl, EGLDisplay display,
                           EGLContext context) {
    if (!egl.eglDestroyContext(display, context)) {
        Log.e("DefaultContextFactory", "display:" + display + " context: " + context);
        if (LOG_THREADS) {
            Log.i("DefaultContextFactory", "tid=" + Thread.currentThread().getId());
        }
        EglHelper.throwEglException("eglDestroyContex", egl.eglGetError());
    }
}
项目:EZFilter    文件:GLTextureView.java   
public EGLContext createContext(EGL10 egl, EGLDisplay display, EGLConfig config) {
    int[] attrib_list = {EGL_CONTEXT_CLIENT_VERSION, mEGLContextClientVersion,
            EGL10.EGL_NONE};

    return egl.eglCreateContext(display, config, EGL10.EGL_NO_CONTEXT,
            mEGLContextClientVersion != 0 ? attrib_list : null);
}
项目:EZFilter    文件:GLTextureView.java   
public void destroyContext(EGL10 egl, EGLDisplay display,
                           EGLContext context) {
    if (!egl.eglDestroyContext(display, context)) {
        Log.e("DefaultContextFactory", "display:" + display + " context: " + context);
        if (LOG_THREADS) {
            Log.i("DefaultContextFactory", "tid=" + Thread.currentThread().getId());
        }
        EglHelper.throwEglException("eglDestroyContex", egl.eglGetError());
    }
}
项目:mao-android    文件:MovieWriter.java   
@Override
public void onInit() {
    super.onInit();
    mEGL = (EGL10) EGLContext.getEGL();
    mEGLDisplay = mEGL.eglGetCurrentDisplay();
    mEGLContext = mEGL.eglGetCurrentContext();
    mEGLScreenSurface = mEGL.eglGetCurrentSurface(EGL10.EGL_DRAW);
}
项目:Cable-Android    文件:BitmapUtil.java   
public static int getMaxTextureSize() {
  final int IMAGE_MAX_BITMAP_DIMENSION = 2048;

  EGL10 egl = (EGL10) EGLContext.getEGL();
  EGLDisplay display = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);

  int[] version = new int[2];
  egl.eglInitialize(display, version);

  int[] totalConfigurations = new int[1];
  egl.eglGetConfigs(display, null, 0, totalConfigurations);

  EGLConfig[] configurationsList = new EGLConfig[totalConfigurations[0]];
  egl.eglGetConfigs(display, configurationsList, totalConfigurations[0], totalConfigurations);

  int[] textureSize = new int[1];
  int maximumTextureSize = 0;

  for (int i = 0; i < totalConfigurations[0]; i++) {
    egl.eglGetConfigAttrib(display, configurationsList[i], EGL10.EGL_MAX_PBUFFER_WIDTH, textureSize);

    if (maximumTextureSize < textureSize[0])
      maximumTextureSize = textureSize[0];
  }

  egl.eglTerminate(display);

  return Math.max(maximumTextureSize, IMAGE_MAX_BITMAP_DIMENSION);
}
项目:ParsingPlayer    文件:VideoRenderThread.java   
@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");
}
项目:VideoCompressor    文件:OutputSurface.java   
private void eglSetup(int width, int height) {
    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, null)) {
        mEGLDisplay = null;
        throw new RuntimeException("unable to initialize EGL10");
    }

    int[] attribList = {
            EGL10.EGL_RED_SIZE, 8,
            EGL10.EGL_GREEN_SIZE, 8,
            EGL10.EGL_BLUE_SIZE, 8,
            EGL10.EGL_ALPHA_SIZE, 8,
            EGL10.EGL_SURFACE_TYPE, EGL10.EGL_PBUFFER_BIT,
            EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
            EGL10.EGL_NONE
    };
    EGLConfig[] configs = new EGLConfig[1];
    int[] numConfigs = new int[1];
    if (!mEGL.eglChooseConfig(mEGLDisplay, attribList, configs, configs.length, numConfigs)) {
        throw new RuntimeException("unable to find RGB888+pbuffer EGL config");
    }
    int[] attrib_list = {
            EGL_CONTEXT_CLIENT_VERSION, 2,
            EGL10.EGL_NONE
    };
    mEGLContext = mEGL.eglCreateContext(mEGLDisplay, configs[0], EGL10.EGL_NO_CONTEXT, attrib_list);
    checkEglError("eglCreateContext");
    if (mEGLContext == null) {
        throw new RuntimeException("null context");
    }
    int[] surfaceAttribs = {
            EGL10.EGL_WIDTH, width,
            EGL10.EGL_HEIGHT, height,
            EGL10.EGL_NONE
    };
    mEGLSurface = mEGL.eglCreatePbufferSurface(mEGLDisplay, configs[0], surfaceAttribs);
    checkEglError("eglCreatePbufferSurface");
    if (mEGLSurface == null) {
        throw new RuntimeException("surface was null");
    }
}
项目:android-openGL-canvas    文件:EGLLogWrapper.java   
public EGLContext eglCreateContext(EGLDisplay display, EGLConfig config,
                                   EGLContext share_context, int[] attrib_list) {
    begin("eglCreateContext");
    arg("display", display);
    arg("config", config);
    arg("share_context", share_context);
    arg("attrib_list", attrib_list);
    end();

    EGLContext result = mEgl10.eglCreateContext(display, config,
            share_context, attrib_list);
    returns(result);
    checkError();
    return result;
}
项目:android-openGL-canvas    文件:EGLLogWrapper.java   
public boolean eglDestroyContext(EGLDisplay display, EGLContext context) {
    begin("eglDestroyContext");
    arg("display", display);
    arg("context", context);
    end();

    boolean result = mEgl10.eglDestroyContext(display, context);
    returns(result);
    checkError();
    return result;
}
项目:VR-Defense-Game    文件:TextureView.java   
public void destroyContext(EGL10 egl, EGLDisplay display, EGLContext context) {
    if (!egl.eglDestroyContext(display, context)) {
        Log.e("DefaultContextFactory", "display:" + display + " context: " + context);
        if (LOG_THREADS) {
            Log.i("DefaultContextFactory", "tid=" + Thread.currentThread().getId());
        }
        EglHelper.throwEglException("eglDestroyContex", egl.eglGetError());
    }
}