Java Code Examples for javax.microedition.khronos.egl.EGL10#eglChooseConfig()
The following examples show how to use
javax.microedition.khronos.egl.EGL10#eglChooseConfig() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultConfigChooser.java From GPUVideo-android with MIT License | 6 votes |
@Override public EGLConfig chooseConfig(final EGL10 egl, final EGLDisplay display) { // 要求されている仕様から使用可能な構成の数を抽出します。 final int[] num_config = new int[1]; if (!egl.eglChooseConfig(display, configSpec, null, 0, num_config)) { throw new IllegalArgumentException("eglChooseConfig failed"); } final int config_size = num_config[0]; if (config_size <= 0) { throw new IllegalArgumentException("No configs match configSpec"); } // 実際の構成を抽出します。 final EGLConfig[] configs = new EGLConfig[config_size]; if (!egl.eglChooseConfig(display, configSpec, configs, config_size, num_config)) { throw new IllegalArgumentException("eglChooseConfig#2 failed"); } final EGLConfig config = chooseConfig(egl, display, configs); if (config == null) { throw new IllegalArgumentException("No config chosen"); } return config; }
Example 2
Source File: ViEAndroidGLES20.java From CSipSimple with GNU General Public License v3.0 | 6 votes |
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) { // Get the number of minimally matching EGL configurations int[] num_config = new int[1]; egl.eglChooseConfig(display, s_configAttribs2, null, 0, num_config); int numConfigs = num_config[0]; if (numConfigs <= 0) { throw new IllegalArgumentException("No configs match configSpec"); } // Allocate then read the array of minimally matching EGL configs EGLConfig[] configs = new EGLConfig[numConfigs]; egl.eglChooseConfig(display, s_configAttribs2, configs, numConfigs, num_config); if (DEBUG) { printConfigs(egl, display, configs); } // Now return the "best" one return chooseConfig(egl, display, configs); }
Example 3
Source File: EGL.java From MyHearts with Apache License 2.0 | 6 votes |
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) { int[] num_config = new int[1]; if (!egl.eglChooseConfig(display, mConfigSpec, null, 0, num_config)) { throw new IllegalArgumentException("eglChooseConfig failed"); } int numConfigs = num_config[0]; if (numConfigs <= 0) { throw new IllegalArgumentException("No configs match configSpec"); } EGLConfig[] configs = new EGLConfig[numConfigs]; if (!egl.eglChooseConfig(display, mConfigSpec, configs, numConfigs, num_config)) { throw new IllegalArgumentException("eglChooseConfig#2 failed"); } EGLConfig config = chooseConfig(egl, display, configs); if (config == null) { throw new IllegalArgumentException("No config chosen"); } return config; }
Example 4
Source File: EGL.java From Vitamio with Apache License 2.0 | 6 votes |
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) { int[] num_config = new int[1]; if (!egl.eglChooseConfig(display, mConfigSpec, null, 0, num_config)) { throw new IllegalArgumentException("eglChooseConfig failed"); } int numConfigs = num_config[0]; if (numConfigs <= 0) { throw new IllegalArgumentException("No configs match configSpec"); } EGLConfig[] configs = new EGLConfig[numConfigs]; if (!egl.eglChooseConfig(display, mConfigSpec, configs, numConfigs, num_config)) { throw new IllegalArgumentException("eglChooseConfig#2 failed"); } EGLConfig config = chooseConfig(egl, display, configs); if (config == null) { throw new IllegalArgumentException("No config chosen"); } return config; }
Example 5
Source File: GLSurfaceView.java From NewsMe with Apache License 2.0 | 6 votes |
@Override public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) { int[] num_config = new int[1]; if (!egl.eglChooseConfig(display, mConfigSpec, null, 0, num_config)) { throw new IllegalArgumentException("eglChooseConfig failed"); } int numConfigs = num_config[0]; if (numConfigs <= 0) { throw new IllegalArgumentException( "No configs match configSpec"); } EGLConfig[] configs = new EGLConfig[numConfigs]; if (!egl.eglChooseConfig(display, mConfigSpec, configs, numConfigs, num_config)) { throw new IllegalArgumentException("eglChooseConfig#2 failed"); } EGLConfig config = chooseConfig(egl, display, configs); if (config == null) { throw new IllegalArgumentException("No config chosen"); } return config; }
Example 6
Source File: GLThread.java From android-openGL-canvas with Apache License 2.0 | 6 votes |
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) { int[] num_config = new int[1]; if (!egl.eglChooseConfig(display, mConfigSpec, null, 0, num_config)) { throw new IllegalArgumentException("eglChooseConfig failed"); } int numConfigs = num_config[0]; if (numConfigs <= 0) { throw new IllegalArgumentException( "No configs match configSpec"); } EGLConfig[] configs = new EGLConfig[numConfigs]; if (!egl.eglChooseConfig(display, mConfigSpec, configs, numConfigs, num_config)) { throw new IllegalArgumentException("eglChooseConfig#2 failed"); } EGLConfig config = chooseConfig(egl, display, configs); if (config == null) { throw new IllegalArgumentException("No config chosen"); } return config; }
Example 7
Source File: SurfaceTextureRenderer.java From Camera2 with Apache License 2.0 | 6 votes |
private static EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) { int[] numConfig = new int[1]; if (!egl.eglChooseConfig(display, CONFIG_SPEC, null, 0, numConfig)) { throw new IllegalArgumentException("eglChooseConfig failed"); } int numConfigs = numConfig[0]; if (numConfigs <= 0) { throw new IllegalArgumentException("No configs match configSpec"); } EGLConfig[] configs = new EGLConfig[numConfigs]; if (!egl.eglChooseConfig( display, CONFIG_SPEC, configs, numConfigs, numConfig)) { throw new IllegalArgumentException("eglChooseConfig#2 failed"); } return configs[0]; }
Example 8
Source File: EGL.java From video-player with MIT License | 6 votes |
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) { int[] num_config = new int[1]; if (!egl.eglChooseConfig(display, mConfigSpec, null, 0, num_config)) { throw new IllegalArgumentException("eglChooseConfig failed"); } int numConfigs = num_config[0]; if (numConfigs <= 0) { throw new IllegalArgumentException("No configs match configSpec"); } EGLConfig[] configs = new EGLConfig[numConfigs]; if (!egl.eglChooseConfig(display, mConfigSpec, configs, numConfigs, num_config)) { throw new IllegalArgumentException("eglChooseConfig#2 failed"); } EGLConfig config = chooseConfig(egl, display, configs); if (config == null) { throw new IllegalArgumentException("No config chosen"); } return config; }
Example 9
Source File: BasicGLCube.java From opengl with Apache License 2.0 | 5 votes |
public void initEGL() { mEGL = (EGL10) GLDebugHelper.wrap(EGLContext.getEGL(), GLDebugHelper.CONFIG_CHECK_GL_ERROR | GLDebugHelper.CONFIG_CHECK_THREAD, null); mGLDisplay = mEGL.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); int[] curGLVersion = new int[2]; mEGL.eglInitialize(mGLDisplay, curGLVersion); Log.i("GL", "GL version = " + curGLVersion[0] + "." + curGLVersion[1]); EGLConfig[] configs = new EGLConfig[1]; int[] num_config = new int[1]; mEGL.eglChooseConfig(mGLDisplay, mConfigSpec, configs, 1, num_config); mGLConfig = configs[0]; mGLSurface = mEGL.eglCreateWindowSurface(mGLDisplay, mGLConfig, sv .getHolder(), null); mGLContext = mEGL.eglCreateContext(mGLDisplay, mGLConfig, EGL10.EGL_NO_CONTEXT, null); mEGL.eglMakeCurrent(mGLDisplay, mGLSurface, mGLSurface, mGLContext); mGL = (GL10) GLDebugHelper.wrap(mGLContext.getGL(), GLDebugHelper.CONFIG_CHECK_GL_ERROR | GLDebugHelper.CONFIG_CHECK_THREAD | GLDebugHelper.CONFIG_LOG_ARGUMENT_NAMES, null); }
Example 10
Source File: DefaultEGLConfigChooser.java From ZGDanmaku with Apache License 2.0 | 5 votes |
@Override public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display, GLESVersion version) { //! コンフィグを全て取得する EGLConfig[] configs = new EGLConfig[32]; // コンフィグ数がeglChooseConfigから返される int[] config_num = new int[1]; if (!egl.eglChooseConfig(display, getConfigSpec(version), configs, configs.length, config_num)) { throw new RuntimeException("eglChooseConfig"); } final int CONFIG_NUM = config_num[0]; final int r_bits = mColorSpec.getRedSize(); final int g_bits = mColorSpec.getGreenSize(); final int b_bits = mColorSpec.getBlueSize(); final int a_bits = mColorSpec.getAlphaSize(); final int d_bits = mDepthEnable ? 16 : 0; final int s_bits = mStencilEnable ? 8 : 0; // 指定したちょうどのconfigを探す for (int i = 0; i < CONFIG_NUM; ++i) { final EGLConfig checkConfig = configs[i]; final int config_r = getConfigAttrib(egl, display, checkConfig, EGL10.EGL_RED_SIZE); final int config_g = getConfigAttrib(egl, display, checkConfig, EGL10.EGL_GREEN_SIZE); final int config_b = getConfigAttrib(egl, display, checkConfig, EGL10.EGL_BLUE_SIZE); final int config_a = getConfigAttrib(egl, display, checkConfig, EGL10.EGL_ALPHA_SIZE); final int config_d = getConfigAttrib(egl, display, checkConfig, EGL10.EGL_DEPTH_SIZE); final int config_s = getConfigAttrib(egl, display, checkConfig, EGL10.EGL_STENCIL_SIZE); // RGBが指定サイズジャスト、ADSが指定サイズ以上あれば合格とする if (config_r == r_bits && config_g == g_bits && config_b == b_bits && config_a >= a_bits && config_d >= d_bits && config_s >= s_bits) { return checkConfig; } } // 先頭のコンフィグを返す return configs[0]; }
Example 11
Source File: BasicGLCube.java From opengl with Apache License 2.0 | 5 votes |
public void initEGL() { mEGL = (EGL10) GLDebugHelper.wrap(EGLContext.getEGL(), GLDebugHelper.CONFIG_CHECK_GL_ERROR | GLDebugHelper.CONFIG_CHECK_THREAD, null); mGLDisplay = mEGL.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); int[] curGLVersion = new int[2]; mEGL.eglInitialize(mGLDisplay, curGLVersion); Log.i("GL", "GL version = " + curGLVersion[0] + "." + curGLVersion[1]); EGLConfig[] configs = new EGLConfig[1]; int[] num_config = new int[1]; mEGL.eglChooseConfig(mGLDisplay, mConfigSpec, configs, 1, num_config); mGLConfig = configs[0]; mGLSurface = mEGL.eglCreateWindowSurface(mGLDisplay, mGLConfig, sv .getHolder(), null); mGLContext = mEGL.eglCreateContext(mGLDisplay, mGLConfig, EGL10.EGL_NO_CONTEXT, null); mEGL.eglMakeCurrent(mGLDisplay, mGLSurface, mGLSurface, mGLContext); mGL = (GL10) GLDebugHelper.wrap(mGLContext.getGL(), GLDebugHelper.CONFIG_CHECK_GL_ERROR | GLDebugHelper.CONFIG_CHECK_THREAD | GLDebugHelper.CONFIG_LOG_ARGUMENT_NAMES, null); }
Example 12
Source File: OutputSurface.java From react-native-video-helper with MIT License | 4 votes |
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"); } }
Example 13
Source File: MultiSampleEGLConfigChooser.java From android-RoundedTextureView with Apache License 2.0 | 4 votes |
@Override public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) { // try to find a normal configuration first. int[] configSpec = { EGL10.EGL_RED_SIZE, r, EGL10.EGL_GREEN_SIZE, g, EGL10.EGL_BLUE_SIZE, b, EGL10.EGL_ALPHA_SIZE, a, EGL10.EGL_DEPTH_SIZE, depth, EGL10.EGL_STENCIL_SIZE, stencil, EGL10.EGL_RENDERABLE_TYPE, renderableType, EGL10.EGL_SAMPLE_BUFFERS, 1, EGL10.EGL_SAMPLES, multisample, EGL10.EGL_NONE }; value = new int[1]; if (!egl.eglChooseConfig(display, configSpec, null, 0, value)) { throw new IllegalArgumentException("eglChooseConfig failed"); } int numConfigs = value[0]; // No normal multisampling config was found. Try to create a // converage multisampling configuration, for the nVidia Tegra2. // See the EGL_NV_coverage_sample documentation. if (numConfigs <= 0 && multisample > 1) { final int EGL_COVERAGE_BUFFERS_NV = 0x30E0; final int EGL_COVERAGE_SAMPLES_NV = 0x30E1; configSpec = new int[] { EGL10.EGL_RED_SIZE, r, EGL10.EGL_GREEN_SIZE, g, EGL10.EGL_BLUE_SIZE, b, EGL10.EGL_ALPHA_SIZE, a, EGL10.EGL_DEPTH_SIZE, depth, EGL10.EGL_STENCIL_SIZE, stencil, EGL10.EGL_RENDERABLE_TYPE, renderableType, EGL_COVERAGE_BUFFERS_NV, 1, EGL_COVERAGE_SAMPLES_NV, multisample, EGL10.EGL_NONE }; if (!egl.eglChooseConfig(display, configSpec, null, 0, value)) { throw new IllegalArgumentException("2nd eglChooseConfig failed"); } numConfigs = value[0]; // Give up, try without multisampling. if (numConfigs <= 0) { configSpec = new int[] { EGL10.EGL_RED_SIZE, r, EGL10.EGL_GREEN_SIZE, g, EGL10.EGL_BLUE_SIZE, b, EGL10.EGL_ALPHA_SIZE, a, EGL10.EGL_DEPTH_SIZE, depth, EGL10.EGL_STENCIL_SIZE, stencil, EGL10.EGL_RENDERABLE_TYPE, renderableType, EGL10.EGL_NONE }; if (!egl.eglChooseConfig(display, configSpec, null, 0, value)) { throw new IllegalArgumentException("3rd eglChooseConfig failed"); } numConfigs = value[0]; if (numConfigs <= 0) { throw new IllegalArgumentException("No configs match configSpec"); } } else { usesCoverageAa = true; Log.i(TAG, "usesCoverageAa"); } } // Get all matching configurations. EGLConfig[] configs = new EGLConfig[numConfigs]; if (!egl.eglChooseConfig(display, configSpec, configs, numConfigs, value)) { throw new IllegalArgumentException("data eglChooseConfig failed"); } // CAUTION! eglChooseConfigs returns configs with higher bit depth // first: Even though we asked for rgb565 configurations, rgb888 // configurations are considered to be "better" and returned first. // You need to explicitly filter the data returned by eglChooseConfig! int index = -1; for (int i = 0; i < configs.length; ++i) { if (findConfigAttrib(egl, display, configs[i], EGL10.EGL_RED_SIZE, 0) == r) { index = i; break; } } if (index == -1) { Log.i(TAG, "Did not find sane config, using first"); } EGLConfig config = configs.length > 0 ? configs[index] : null; if (config == null) { throw new IllegalArgumentException("No config chosen"); } return config; }
Example 14
Source File: OutputSurface.java From VideoProcessor with Apache License 2.0 | 4 votes |
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"); } }
Example 15
Source File: ConfigChooser.java From Tanks with MIT License | 4 votes |
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) { int[] value = new int[1]; int[] configSpec = { EGL10.EGL_RED_SIZE, 8, EGL10.EGL_GREEN_SIZE, 8, EGL10.EGL_BLUE_SIZE, 8, EGL10.EGL_ALPHA_SIZE, 8, EGL10.EGL_DEPTH_SIZE, 16, EGL10.EGL_RENDERABLE_TYPE, 4, EGL10.EGL_NONE }; if (!egl.eglChooseConfig(display, configSpec, null, 0, value)) throw new IllegalArgumentException("RGB888 eglChooseConfig failed"); int numConfigs = value[0]; if (numConfigs <= 0) { configSpec = new int[] { EGL10.EGL_RED_SIZE, 5, EGL10.EGL_GREEN_SIZE, 6, EGL10.EGL_BLUE_SIZE, 5, EGL10.EGL_RENDERABLE_TYPE, 4, EGL10.EGL_NONE }; if (!egl.eglChooseConfig(display, configSpec, null, 0, value)) throw new IllegalArgumentException("RGB565 eglChooseConfig failed"); numConfigs = value[0]; if (numConfigs <= 0) throw new IllegalArgumentException("No configs match configSpec RGB565"); } EGLConfig[] configs = new EGLConfig[numConfigs]; egl.eglChooseConfig(display, configSpec, configs, numConfigs, value); return configs[0]; }
Example 16
Source File: GlConfigChooser.java From trekarta with GNU General Public License v3.0 | 4 votes |
@Override public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) { int[] val = new int[1]; // Try to find a normal multisample configuration first. int[] configSpec = { EGL10.EGL_RED_SIZE, 5, EGL10.EGL_GREEN_SIZE, 6, EGL10.EGL_BLUE_SIZE, 5, EGL10.EGL_ALPHA_SIZE, 8, EGL10.EGL_DEPTH_SIZE, 16, // Requires that setEGLContextClientVersion(2) is called on the view. EGL10.EGL_RENDERABLE_TYPE, 4 /*EGL14.EGL_OPENGL_ES2_BIT*/ /*0x40 /*EGLExt.EGL_OPENGL_ES3_BIT_KHR*/, EGL10.EGL_STENCIL_SIZE, 8, EGL10.EGL_NONE}; if (!egl.eglChooseConfig(display, configSpec, null, 0, val)) { throw new IllegalArgumentException("eglChooseConfig failed"); } int numConfigs = val[0]; if (numConfigs <= 0) { configSpec = new int[]{ // EGL10.EGL_RENDERABLE_TYPE, 4, EGL10.EGL_NONE }; EGL10.EGL_RED_SIZE, 8, EGL10.EGL_GREEN_SIZE, 8, EGL10.EGL_BLUE_SIZE, 8, EGL10.EGL_ALPHA_SIZE, 8, EGL10.EGL_DEPTH_SIZE, 16, EGL10.EGL_RENDERABLE_TYPE, 4 /*EGL14.EGL_OPENGL_ES2_BIT*/ /*0x40 /*EGLExt.EGL_OPENGL_ES3_BIT_KHR*/, EGL10.EGL_STENCIL_SIZE, 8, EGL10.EGL_NONE}; if (!egl.eglChooseConfig(display, configSpec, null, 0, val)) { throw new IllegalArgumentException("eglChooseConfig failed"); } numConfigs = val[0]; if (numConfigs <= 0) { throw new IllegalArgumentException("No configs match configSpec"); } } // Get all matching configurations. EGLConfig[] configs = new EGLConfig[numConfigs]; if (!egl.eglChooseConfig(display, configSpec, configs, numConfigs, val)) { throw new IllegalArgumentException("data eglChooseConfig failed"); } // CAUTION! eglChooseConfigs returns configs with higher bit depth // first: Even though we asked for rgb565 configurations, rgb888 // configurations are considered to be "better" and returned first. // You need to explicitly filter the data returned by eglChooseConfig! EGLConfig config = configs.length > 0 ? configs[0] : null; if (config == null) { throw new IllegalArgumentException("No config chosen"); } return config; }
Example 17
Source File: EglUtils.java From Matisse-Kotlin with Apache License 2.0 | 4 votes |
@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]; }
Example 18
Source File: ConfigChooser.java From 30-android-libraries-in-30-days with Apache License 2.0 | 4 votes |
private static int getEGLConfigCount(final EGL10 pEGL, final EGLDisplay pEGLDisplay, final int[] pEGLConfigAttributes) { if(pEGL.eglChooseConfig(pEGLDisplay, pEGLConfigAttributes, null, 0, ConfigChooser.BUFFER) == false) { throw new IllegalArgumentException("EGLCONFIG_FALLBACK failed!"); } return ConfigChooser.BUFFER[0]; }
Example 19
Source File: RenderView.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
private boolean initGL() { egl10 = (EGL10) EGLContext.getEGL(); eglDisplay = egl10.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); if (eglDisplay == EGL10.EGL_NO_DISPLAY) { if (BuildVars.LOGS_ENABLED) { FileLog.e("eglGetDisplay failed " + GLUtils.getEGLErrorString(egl10.eglGetError())); } finish(); return false; } int[] version = new int[2]; if (!egl10.eglInitialize(eglDisplay, version)) { if (BuildVars.LOGS_ENABLED) { FileLog.e("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)) { if (BuildVars.LOGS_ENABLED) { FileLog.e("eglChooseConfig failed " + GLUtils.getEGLErrorString(egl10.eglGetError())); } finish(); return false; } else if (configsCount[0] > 0) { eglConfig = configs[0]; } else { if (BuildVars.LOGS_ENABLED) { FileLog.e("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) { if (BuildVars.LOGS_ENABLED) { FileLog.e("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) { if (BuildVars.LOGS_ENABLED) { FileLog.e("createWindowSurface failed " + GLUtils.getEGLErrorString(egl10.eglGetError())); } finish(); return false; } if (!egl10.eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext)) { if (BuildVars.LOGS_ENABLED) { FileLog.e("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; }
Example 20
Source File: OutputSurface.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
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"); } }