当前位置: 首页>>代码示例>>Java>>正文


Java EGL10.eglGetDisplay方法代码示例

本文整理汇总了Java中javax.microedition.khronos.egl.EGL10.eglGetDisplay方法的典型用法代码示例。如果您正苦于以下问题:Java EGL10.eglGetDisplay方法的具体用法?Java EGL10.eglGetDisplay怎么用?Java EGL10.eglGetDisplay使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.microedition.khronos.egl.EGL10的用法示例。


在下文中一共展示了EGL10.eglGetDisplay方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: start

import javax.microedition.khronos.egl.EGL10; //导入方法依赖的package包/类
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;
}
 
开发者ID:coding-dream,项目名称:TPlayer,代码行数:23,代码来源:EGL.java

示例2: getMaxTextureSize

import javax.microedition.khronos.egl.EGL10; //导入方法依赖的package包/类
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);
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:30,代码来源:BitmapUtil.java

示例3: eglSetup

import javax.microedition.khronos.egl.EGL10; //导入方法依赖的package包/类
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");
    }
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:48,代码来源:OutputSurface.java

示例4: 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

示例5: getMaxTextureSize

import javax.microedition.khronos.egl.EGL10; //导入方法依赖的package包/类
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);
}
 
开发者ID:Assassinss,项目名称:Moment,代码行数:40,代码来源:TextureSizeUtils.java

示例6: 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

示例7: 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

示例8: getMaxTextureSize

import javax.microedition.khronos.egl.EGL10; //导入方法依赖的package包/类
/**
 * Get the max size of bitmap allowed to be rendered on the device.<br>
 * http://stackoverflow.com/questions/7428996/hw-accelerated-activity-how-to-get-opengl-texture-size-limit.
 */
private static int getMaxTextureSize() {
    // Safe minimum default size
    final int IMAGE_MAX_BITMAP_DIMENSION = 2048;

    try {
        // 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);
    } catch (Exception e) {
        return IMAGE_MAX_BITMAP_DIMENSION;
    }
}
 
开发者ID:garretyoder,项目名称:Cluttr,代码行数:49,代码来源:BitmapUtils.java

示例9: start

import javax.microedition.khronos.egl.EGL10; //导入方法依赖的package包/类
/**
 * Initialize EGL for a given configuration spec.
 * @param
 */
public void start() {
    if (LOG_EGL) {
        Log.w("EglHelper", "start() tid=" + Thread.currentThread().getId());
    }
    /*
     * Get an EGL instance
     */
    mEgl = (EGL10) EGLContext.getEGL();

    /*
     * Get to the default display.
     */
    mEglDisplay = mEgl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);

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

    /*
     * We can now initialize EGL for that display
     */
    int[] version = new int[2];
    if(!mEgl.eglInitialize(mEglDisplay, version)) {
        throw new RuntimeException("eglInitialize failed");
    }
    GLTextureView view = mGLSurfaceViewWeakRef.get();
    if (view == null) {
        mEglConfig = null;
        mEglContext = null;
    } else {
        mEglConfig = view.mEGLConfigChooser.chooseConfig(mEgl, mEglDisplay);

        /*
        * Create an EGL context. We want to do this as rarely as we can, because an
        * EGL context is a somewhat heavy object.
        */
        mEglContext = view.mEGLContextFactory.createContext(mEgl, mEglDisplay, mEglConfig);
    }
    if (mEglContext == null || mEglContext == EGL10.EGL_NO_CONTEXT) {
        mEglContext = null;
        throwEglException("createContext");
    }
    if (LOG_EGL) {
        Log.w("EglHelper", "createContext " + mEglContext + " tid=" + Thread.currentThread().getId());
    }

    mEglSurface = null;
}
 
开发者ID:pavelsemak,项目名称:alpha-movie,代码行数:53,代码来源:GLTextureView.java

示例10: start

import javax.microedition.khronos.egl.EGL10; //导入方法依赖的package包/类
/**
 * Initialize EGL for a given configuration spec.
 * @param configSpec
 */
public void start(){

	Log.v("SDL", "GLSurfaceView_SDL::EglHelper::start(): creating GL context");
	/*
	 * Get an EGL instance
	 */
	mEgl = (EGL10) EGLContext.getEGL();

	/*
	 * Get to the default display.
	 */
	mEglDisplay = mEgl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);

	/*
	 * We can now initialize EGL for that display
	 */
	int[] version = new int[2];
	mEgl.eglInitialize(mEglDisplay, version);
	mEglConfig = mEGLConfigChooser.chooseConfig(mEgl, mEglDisplay);
	if( mEglConfig == null )
		Log.e("SDL", "GLSurfaceView_SDL::EglHelper::start(): mEglConfig is NULL");

	/*
	* Create an OpenGL ES context. This must be done only once, an
	* OpenGL context is a somewhat heavy object.
	*/
	final int EGL_CONTEXT_CLIENT_VERSION = 0x3098;
	final int[] gles2_attrib_list = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE };
	final int[] gles3_attrib_list = {EGL_CONTEXT_CLIENT_VERSION, 3, EGL10.EGL_NONE };

	mEglContext = mEgl.eglCreateContext(mEglDisplay, mEglConfig,
			EGL10.EGL_NO_CONTEXT,
			mEGLConfigChooser.isGles3Required() ? gles3_attrib_list :
			mEGLConfigChooser.isGles2Required() ? gles2_attrib_list : null );

	if( mEglContext == null || mEglContext == EGL10.EGL_NO_CONTEXT )
		Log.e("SDL", "GLSurfaceView_SDL::EglHelper::start(): mEglContext is EGL_NO_CONTEXT, error: " + mEgl.eglGetError());

	mEglSurface = null;
}
 
开发者ID:NeoTerm,项目名称:NeoTerm,代码行数:45,代码来源:GLSurfaceView_SDL.java

示例11: 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

示例12: start

import javax.microedition.khronos.egl.EGL10; //导入方法依赖的package包/类
/**
 * Initialize EGL for a given configuration spec.
 */
public void start() {
    if (LOG_EGL) {
        Log.w("EglHelper", "start() tid=" + Thread.currentThread().getId());
    }
    /*
     * Get an EGL instance
     */
    mEgl = (EGL10) EGLContext.getEGL();

    /*
     * Get to the default display.
     */
    mEglDisplay = mEgl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);

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

    /*
     * We can now initialize EGL for that display
     */
    int[] version = new int[2];
    if (!mEgl.eglInitialize(mEglDisplay, version)) {
        throw new RuntimeException("eglInitialize failed");
    }
    GLSurfaceView view = mGLSurfaceViewWeakRef.get();
    if (view == null) {
        mEglConfig = null;
        mEglContext = null;
    } else {
        mEglConfig = view.mEGLConfigChooser.chooseConfig(mEgl, mEglDisplay);

        /*
        * Create an EGL context. We want to do this as rarely as we can, because an
        * EGL context is a somewhat heavy object.
        */
        mEglContext = view.mEGLContextFactory.createContext(mEgl, mEglDisplay, mEglConfig);
    }
    if (mEglContext == null || mEglContext == EGL10.EGL_NO_CONTEXT) {
        mEglContext = null;
        throwEglException("createContext");
    }
    if (LOG_EGL) {
        Log.w("EglHelper", "createContext " + mEglContext + " tid=" + Thread.currentThread().getId());
    }

    mEglSurface = null;
}
 
开发者ID:uestccokey,项目名称:EZFilter,代码行数:52,代码来源:GLSurfaceView.java

示例13: 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

示例14: getMaxTextureSize

import javax.microedition.khronos.egl.EGL10; //导入方法依赖的package包/类
/**
 * Get the max size of bitmap allowed to be rendered on the device.<br>
 * http://stackoverflow.com/questions/7428996/hw-accelerated-activity-how-to-get-opengl-texture-size-limit.
 */
private static int getMaxTextureSize() {
  // Safe minimum default size
  final int IMAGE_MAX_BITMAP_DIMENSION = 2048;

  try {
    // 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);
  } catch (Exception e) {
    return IMAGE_MAX_BITMAP_DIMENSION;
  }
}
 
开发者ID:prashantsaini1,项目名称:android-titanium-imagecropper,代码行数:50,代码来源:BitmapUtils.java


注:本文中的javax.microedition.khronos.egl.EGL10.eglGetDisplay方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。