eglGetConfigAttrib returns zero.


3 posts
by RichardUK » Tue Jun 19, 2012 9:47 pm
Code: Select all
const EGLint attrib_list[] =
      {
         EGL_RED_SIZE,         8,
         EGL_GREEN_SIZE,         8,
         EGL_BLUE_SIZE,         8,
         EGL_ALPHA_SIZE,         8,
         EGL_DEPTH_SIZE,         24,
         EGL_RENDERABLE_TYPE,   EGL_OPENGL_ES2_BIT,
         EGL_NONE,            EGL_NONE
      };

      EGLint numConfigs;
      if( !eglChooseConfig(m_display,attrib_list,&m_config,1, &numConfigs) )
      {
         printf("Error: eglGetConfigs() failed\n");
         return false;
      }

      if( numConfigs > 0 )
      {
         EGLint bufSize,r,g,b,a,z,s = 0;

         eglGetConfigAttrib(m_display,&m_config,EGL_BUFFER_SIZE,&bufSize);

         eglGetConfigAttrib(m_display,&m_config,EGL_RED_SIZE,&r);
         eglGetConfigAttrib(m_display,&m_config,EGL_GREEN_SIZE,&g);
         eglGetConfigAttrib(m_display,&m_config,EGL_BLUE_SIZE,&b);
         eglGetConfigAttrib(m_display,&m_config,EGL_ALPHA_SIZE,&a);

         eglGetConfigAttrib(m_display,&m_config,EGL_DEPTH_SIZE,&z);
         eglGetConfigAttrib(m_display,&m_config,EGL_STENCIL_SIZE,&s);

         printf("%d Configs found:\n\tFrame buffer(%d) RGBA(%d %d %d %d)\n\tZBuffer(%d) Z(%d) S(%d)\n\n",numConfigs,bufSize,r,g,b,a,z+s,z,s);
         return true;
      }


The code gets a good config but the printf prints the following


1 Configs found:
Frame buffer(0) RGBA(1073909760 0 0 0)
ZBuffer(0) Z(0) S(0)

Now that can't be correct??? What am I doing wrong?

Ta. :)
User avatar
Posts: 130
Joined: Fri Jun 01, 2012 5:12 pm
by dattrax » Wed Jun 20, 2012 4:33 pm
code is wrong.

you need to
Code: Select all
eglGetConfigAttrib(m_display,m_config,EGL_BUFFER_SIZE,&bufSize);

eglGetConfigAttrib(m_display,m_config,EGL_RED_SIZE,&r);
eglGetConfigAttrib(m_display,m_config,EGL_GREEN_SIZE,&g);
eglGetConfigAttrib(m_display,m_config,EGL_BLUE_SIZE,&b);
eglGetConfigAttrib(m_display,m_config,EGL_ALPHA_SIZE,&a);

eglGetConfigAttrib(m_display,m_config,EGL_DEPTH_SIZE,&z);
eglGetConfigAttrib(m_display,m_config,EGL_STENCIL_SIZE,&s);


without the '&' in front of m_config

Jim
Posts: 50
Joined: Sat Dec 24, 2011 5:09 pm
by RichardUK » Sat Jun 23, 2012 4:26 pm
Doh! LoL. Thanks. :) School boy error......
User avatar
Posts: 130
Joined: Fri Jun 01, 2012 5:12 pm