# OSX EGL Initialization Issues

**URL:** <https://forums.imgtec.com/t/osx-egl-initialization-issues/2194>\
**Category:** PowerVR Insider\
**Tags:** pvrvframe\
**Created:** [October 25, 2014, 3:22am UTC](https://forums.imgtec.com/t/osx-egl-initialization-issues/2194 "2014-10-25T03:22:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rom](https://avatars.discourse-cdn.com/v4/letter/r/3e96dc/32.png) [@rom](https://forums.imgtec.com/u/rom)\
**Post date:** [October 25, 2014, 3:22am UTC](https://forums.imgtec.com/t/osx-egl-initialization-issues/2194/1 "2014-10-25T03:22:01Z")

</div>

As the title says, Im having a few issues, the first is that regardless the way Im initializing the EGL context the configuration attributes that Im passing are always ignored… In previous version that was working fine… Im initializing the context like this:

````auto
	EGLDisplay	m_EGLDisplay;<br />
EGLSurface	m_EGLWindow;<br />
EGLContext	m_EGLContext;<br />
<br />
EGLNativeDisplayType m_NDT;<br />
EGLNativePixmapType m_NPT;<br />
EGLNativeWindowType m_NWT;<br />
<br />
m_NDT = (EGLNativeDisplayType)NULL;<br />
m_NPT = (EGLNativePixmapType)NULL;<br />
m_NWT = (EGLNativeWindowType)window->ns.view;<br />
<br />
EGLConfig config[16];<br />
<br />
EGLint attribs[] = { EGL_CONTEXT_CLIENT_VERSION,<br />
3/* or 2 */,<br />
EGL_NONE },<br />
<br />
config_attr[] = { EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,<br />
EGL_RED_SIZE , 5,<br />
EGL_GREEN_SIZE , 6,<br />
EGL_BLUE_SIZE , 5,<br />
EGL_ALPHA_SIZE , 0,<br />
EGL_DEPTH_SIZE , 24,<br />
EGL_STENCIL_SIZE , 8,<br />
EGL_SAMPLE_BUFFERS , 0,<br />
EGL_SAMPLES , 0,<br />
EGL_SURFACE_TYPE , EGL_WINDOW_BIT,<br />
EGL_NONE },<br />
version_major,<br />
version_minor,<br />
num_config;<br />
<br />
m_EGLDisplay = eglGetDisplay( m_NDT );<br />
<br />
eglInitialize( m_EGLDisplay,<br />
&version_major,<br />
&version_minor );<br />
<br />
eglBindAPI( EGL_OPENGL_ES_API );<br />
<br />
fprintf( stderr, "EGL_VENDOR: %sn" , ( char * )eglQueryString( m_EGLDisplay, EGL_VENDOR ) );<br />
fprintf( stderr, "EGL_VERSION: %sn" , ( char * )eglQueryString( m_EGLDisplay, EGL_VERSION ) );<br />
fprintf( stderr, "EGL_CLIENT_APIS: %sn", ( char * )eglQueryString( m_EGLDisplay, EGL_CLIENT_APIS ) );<br />
<br />
EGLint	i = 0,<br />
id,<br />
size,<br />
red,<br />
green,<br />
blue,<br />
alpha,<br />
depth,<br />
stencil,<br />
sample_buffers,<br />
samples;<br />
<br />
eglGetConfigs( m_EGLDisplay,<br />
config,<br />
16,<br />
&num_config );<br />
<br />
while( i != num_config )<br />
{<br />
eglGetConfigAttrib( m_EGLDisplay, config[i], EGL_CONFIG_ID , &id );<br />
eglGetConfigAttrib( m_EGLDisplay, config[i], EGL_BUFFER_SIZE , &size );<br />
eglGetConfigAttrib( m_EGLDisplay, config[i], EGL_RED_SIZE , &red );<br />
eglGetConfigAttrib( m_EGLDisplay, config[i], EGL_GREEN_SIZE , &green );<br />
eglGetConfigAttrib( m_EGLDisplay, config[i], EGL_BLUE_SIZE , &blue );<br />
eglGetConfigAttrib( m_EGLDisplay, config[i], EGL_ALPHA_SIZE , &alpha );<br />
eglGetConfigAttrib( m_EGLDisplay, config[i], EGL_DEPTH_SIZE , &depth );<br />
eglGetConfigAttrib( m_EGLDisplay, config[i], EGL_STENCIL_SIZE , &stencil );<br />
eglGetConfigAttrib( m_EGLDisplay, config[i], EGL_SAMPLE_BUFFERS, &sample_buffers	);<br />
eglGetConfigAttrib( m_EGLDisplay, config[i], EGL_SAMPLES , &samples );<br />
<br />
fprintf( stderr,<br />
"EGL_CONFIG%d: Bits:%d R:%d G:%d B:%d A:%d D:%d St:%d Sb:%d Sa:%dn",<br />
id,<br />
size,<br />
red,<br />
green,<br />
blue,<br />
alpha,<br />
depth,<br />
stencil,<br />
sample_buffers,<br />
samples );<br />
++i;<br />
}<br />
<br />
fprintf( stderr, "EGL_EXTENSIONS: %snn" , ( char * )eglQueryString( m_EGLDisplay, EGL_EXTENSIONS ) );<br />
<br />
<br />
eglChooseConfig( m_EGLDisplay,<br />
config_attr,<br />
&config[0],<br />
1,<br />
&num_config );<br />
<br />
m_EGLWindow = eglCreateWindowSurface( m_EGLDisplay,<br />
config[0],<br />
m_NWT,<br />
NULL );<br />
<br />
m_EGLContext = eglCreateContext( m_EGLDisplay,<br />
config[0],<br />
EGL_NO_CONTEXT,<br />
attribs );<br />
<br />
eglMakeCurrent( m_EGLDisplay,<br />
m_EGLWindow,<br />
m_EGLWindow,<br />
m_EGLContext );
```<br />
<br />
The EGL_CONFIGs that are returned are always the same, which explain why Im always getting a 32bits with multisampling context:<br />
<br />

````

EGL\_CONFIG1: Bits:32 R:8 G:8 B:8 A:8 D:24 St:8 Sb:1 Sa:4  
  
EGL\_CONFIG2: Bits:32 R:8 G:8 B:8 A:8 D:24 St:8 Sb:1 Sa:4  
  
EGL\_CONFIG3: Bits:32 R:8 G:8 B:8 A:8 D:24 St:8 Sb:1 Sa:4  
  
EGL\_CONFIG4: Bits:32 R:8 G:8 B:8 A:8 D:24 St:8 Sb:1 Sa:4  
  
EGL\_CONFIG5: Bits:32 R:8 G:8 B:8 A:8 D:24 St:8 Sb:1 Sa:4  
  
EGL\_CONFIG6: Bits:32 R:8 G:8 B:8 A:8 D:24 St:8 Sb:1 Sa:4

```auto
<br />
1.<br />
Is there at least a workaround to fix this... or at least disable multisampling (slows down a lot in my case)?<br />
<br />
2.<br />
The second problem that Im having is that, on my MBP Im having 2 video cards, 1 Nvidia (which PVRVframe pickup and work fine on it) and an Intel HD... For the Intel card PVRVframe failed to pick it up and Im falling back in software renderer... (plus notice below that in both case the GL_VERSION query fail...)<br />
<br />
When I select the Nvidia card:<br />
<br />

```

GL\_VENDOR: Imagination Technologies (Host: NVIDIA Corporation)  
  
GL\_RENDERER: PVRVFrame 10.0 - None (Host : NVIDIA GeForce GT 330M OpenGL Engine) (SDK Build: 3.4@3186613)  
  
GL\_VERSION: (Host : 3.3 NVIDIA-8.24.16 310.90.9.05f01)  
  
GL\_SHADING\_LANGUAGE\_VERSION: OpenGL ES GLSL ES 1.00 (Host: 3.30)  
  
GL\_EXTENSIONS: GL\_APPLE\_copy\_texture\_levels GL\_APPLE\_sync GL\_APPLE\_texture\_max\_level GL\_EXT\_blend\_minmax GL\_EXT\_color\_buffer\_float GL\_EXT\_debug\_marker GL\_EXT\_discard\_framebuffer GL\_EXT\_draw\_buffers GL\_EXT\_multi\_draw\_arrays GL\_EXT\_multisampled\_render\_to\_texture GL\_EXT\_occlusion\_query\_boolean GL\_EXT\_robustness GL\_EXT\_shader\_texture\_lod GL\_EXT\_sRGB GL\_EXT\_texture\_filter\_anisotropic GL\_EXT\_texture\_rg GL\_EXT\_texture\_storage GL\_EXT\_texture\_sRGB\_decode GL\_EXT\_texture\_type\_2\_10\_10\_10\_REV GL\_IMG\_multisampled\_render\_to\_texture GL\_IMG\_program\_binary GL\_IMG\_read\_format GL\_IMG\_shader\_binary GL\_IMG\_texture\_compression\_pvrtc GL\_IMG\_texture\_compression\_pvrtc2 GL\_IMG\_texture\_npot GL\_IMG\_texture\_stream GL\_IMG\_texture\_stream2 GL\_IMG\_uniform\_buffer\_object GL\_IMG\_vertex\_array\_object GL\_KHR\_debug GL\_KHR\_blend\_equation\_advanced GL\_OES\_compressed\_ETC1\_RGB8\_texture GL\_OES\_depth\_texture GL\_OES\_depth\_texture\_cube\_map GL\_OES\_EGL\_image\_external GL\_OES\_egl\_sync GL\_OES\_element\_index\_uint GL\_OES\_fragment\_precision\_high GL\_OES\_get\_program\_binary GL\_OES\_mapbuffer GL\_OES\_packed\_depth\_stencil GL\_OES\_read\_format GL\_OES\_required\_internalformat GL\_OES\_sample\_shading GL\_OES\_sample\_variables GL\_OES\_shader\_image\_atomic GL\_OES\_shader\_multisample\_interpolation GL\_OES\_standard\_derivatives GL\_OES\_stencil\_wrap GL\_OES\_surfaceless\_context GL\_OES\_texture\_mirrored\_repeat GL\_OES\_texture\_stencil8 GL\_OES\_texture\_storage\_multisample\_2d\_array GL\_OES\_vertex\_array\_object

```auto
<br />
When I select the Intel card using gfxCardStatus:<br />
<br />

```

GL\_VENDOR: Imagination Technologies (Host: Apple Computer, Inc.)  
  
GL\_RENDERER: PVRVFrame 10.0 - None (Host : Apple Software Renderer) (SDK Build: 3.4@3186613)  
  
GL\_VERSION: (Host : 4.1 APPLE-9.6.1)  
  
GL\_SHADING\_LANGUAGE\_VERSION: OpenGL ES GLSL ES 1.00 (Host: 4.10)  
  
GL\_EXTENSIONS: GL\_APPLE\_copy\_texture\_levels GL\_APPLE\_sync GL\_APPLE\_texture\_max\_level GL\_EXT\_blend\_minmax GL\_EXT\_color\_buffer\_float GL\_EXT\_debug\_marker GL\_EXT\_discard\_framebuffer GL\_EXT\_draw\_buffers GL\_EXT\_multi\_draw\_arrays GL\_EXT\_multisampled\_render\_to\_texture GL\_EXT\_occlusion\_query\_boolean GL\_EXT\_robustness GL\_EXT\_shader\_texture\_lod GL\_EXT\_sRGB GL\_EXT\_texture\_filter\_anisotropic GL\_EXT\_texture\_rg GL\_EXT\_texture\_storage GL\_EXT\_texture\_sRGB\_decode GL\_EXT\_texture\_type\_2\_10\_10\_10\_REV GL\_IMG\_multisampled\_render\_to\_texture GL\_IMG\_program\_binary GL\_IMG\_read\_format GL\_IMG\_shader\_binary GL\_IMG\_texture\_compression\_pvrtc GL\_IMG\_texture\_compression\_pvrtc2 GL\_IMG\_texture\_npot GL\_IMG\_texture\_stream GL\_IMG\_texture\_stream2 GL\_IMG\_uniform\_buffer\_object GL\_IMG\_vertex\_array\_object GL\_KHR\_debug GL\_KHR\_blend\_equation\_advanced GL\_OES\_compressed\_ETC1\_RGB8\_texture GL\_OES\_depth\_texture GL\_OES\_depth\_texture\_cube\_map GL\_OES\_EGL\_image\_external GL\_OES\_egl\_sync GL\_OES\_element\_index\_uint GL\_OES\_fragment\_precision\_high GL\_OES\_get\_program\_binary GL\_OES\_mapbuffer GL\_OES\_packed\_depth\_stencil GL\_OES\_read\_format GL\_OES\_required\_internalformat GL\_OES\_sample\_shading GL\_OES\_sample\_variables GL\_OES\_shader\_image\_atomic GL\_OES\_shader\_multisample\_interpolation GL\_OES\_standard\_derivatives GL\_OES\_stencil\_wrap GL\_OES\_surfaceless\_context GL\_OES\_texture\_mirrored\_repeat GL\_OES\_texture\_stencil8 GL\_OES\_texture\_storage\_multisample\_2d\_array GL\_OES\_vertex\_array\_object

```auto
<br />
3.<br />
Im also receiving random crash when building/restarting my App (on both card btw):<br />
<br />

```

/Users/autobuild/buildxl/buildroot/sdk/branch/UtilitiesSrc/Common/PVRPreferences/PVRPreferences.cpp  
  
WARNING: No declaration found at the start. The declaration will be recreated.

```auto
<br />
4.<br />
In addition changing the client version bit have no effect:<br />
<br />

```

```
EGLint attribs[] = { EGL_CONTEXT_CLIENT_VERSION,<br />

```

2,  
  
EGL\_NONE }

```auto
<br />
<br />

```

```
EGLint attribs[] = { EGL_CONTEXT_CLIENT_VERSION,<br />

```

3,  
  
EGL\_NONE }

```auto
<br />
I was hoping that changing 2 to 3 or vice versa would give me a correct GL_VERSION and GL_SHADING_LANGUAGE version... It it crucial in my App as I need to adjust the GLSL code generation, and functionalities / function extensions in my App...<br />
<br />
Tks in advance for your reply... Hope that there's some workaround for theses issues, or they can be fixed soon...
```

---

<div class="post-metadata">

**Author:** ![ChrisPenrose](https://avatars.discourse-cdn.com/v4/letter/c/e36b37/32.png) [@ChrisPenrose](https://forums.imgtec.com/u/ChrisPenrose)\
**Post date:** [October 27, 2014, 10:08am UTC](https://forums.imgtec.com/t/osx-egl-initialization-issues/2194/2 "2014-10-27T10:08:40Z")

</div>

Hi ROm, thanks for reporting these issues

1. As you’ve seen there’s currently a nasty bug in eglChooseConfig where only the first matching config is returned. A temporary workaround would be to use eglGetConfigs to return a list of all available configs and select and appropriate one manually.  
  
  
2. We’re currently working on better support for intel graphics. For the time being you are probably best off sticking with the nvidia card. There’s another bug in glGetString where GL\_VERSION fails for anything above ES 2.0.  
  
  
  
These two bugs will be fixed in the next release, which will be early next year, but we should be releasing beta versions around December.  
  
  
3. I haven’t seen this crash before, but I’ll file a bug and try to reproduce it. I assume you mean this only happens when restarting the app in Xcode?  
  
  
4. The version of context returned by eglCreateContext also depends on the value of EGL\_RENDERABLE\_TYPE in the selected EGL config. In PVRVFrame you’ll always be getting one of a set of hard-coded EGL configs, and all ES2\_BIT configs also support ES3\_BIT\_KHR, meaning you’ll always get an ES 3.0 context. I realise this isn’t really ideal so I’ll file a bug report to add a better selection of configs. This should also allow you to select a non-multisampled config too.  
  
  
  
Again I’ll do my best to push these fixes in for the beta around December time. I hope these issues don’t slow you down too much in the meantime!

---

<div class="post-metadata">

**Author:** ![rom](https://avatars.discourse-cdn.com/v4/letter/r/3e96dc/32.png) [@rom](https://forums.imgtec.com/u/rom)\
**Post date:** [October 28, 2014, 2:13am UTC](https://forums.imgtec.com/t/osx-egl-initialization-issues/2194/3 "2014-10-28T02:13:34Z")

</div>

1. I think about it but… as you can in my code output when I enumerate the configs they are all the same… 😉  
  
  
2. Would be great if we can select to either initialize GLES2 or GLES3, that makes it ALOT easier to test our apps using a specific profile. I personally really need that since Im developing an editor and selecting the profile for the project is crucial 😉 Do not use the EGL\_OPENGL\_ES3\_BIT\_KHR its basically an ext, simply use the standard EGL\_OPENGL\_ES2\_BIT, and toggle GLES2/GLES3 context creation with the EGL\_CONTEXT\_CLIENT\_VERSION. I believe that’s what make more sense… (see answer for #4 for more info…)  
  
  
3. Yes it is using Xcode, it typically append when my app is running then hit build and run. The app close then the new ly compiled version launched and can’t create the context. Another thing that happen is sometimes it gets the context (as I can see on the console its initialized) but the app just hang there (at eglMakeCurrent)… I have to restart again to start it up… not sure its related but…  
  
  
4. Hmmm the way I believe it should be done (my 0.02$) is like this: when EGL\_CONTEXT\_CLIENT\_VERSION is set to 2 a compatible OpenGL 2.1 context basically NSOpenGLProfileVersionLegacy. And when ES3 is selected initialize it internally with NSOpenGLProfileVersion3\_2Core and up… On Linux and Windows its basically the same thing, glXCreateContextAttribsARB with GLX\_CONTEXT\_CORE\_PROFILE\_BIT\_ARB and wglCreateContextAttribsARB WGL\_CONTEXT\_CORE\_PROFILE\_BIT\_ARB or else (the latest version supported by the driver).

---

<div class="post-metadata">

**Author:** ![qiankanglai](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/qiankanglai/32/226_2.png) [@qiankanglai](https://forums.imgtec.com/u/qiankanglai)\
**Post date:** [January 4, 2015, 12:15am UTC](https://forums.imgtec.com/t/osx-egl-initialization-issues/2194/4 "2015-01-04T00:15:52Z")

</div>

I’m experiencing the same issue 3 here. It seems the library cannot find the XML file when initialization and crashed
