Can't open GLES display


sixtyfifthbit

Member
Joined
Aug 24, 2007
Messages
168
I've been trying to make a library to use GLES 1.x but I can't even seem to get act one right - I cannot even open a GL display. Here is the code:

Code:
       static bool InitEGL(bool FSAA)

        {

            nEGL_Display = eglGetDisplay((NativeDisplayType)nX11_Display);

            if (EGL_NO_DISPLAY==nEGL_Display)

            {

                errorf("WARNING: eglGetDisplay((NativeDisplayType)nX11_Display) failed.\n"\

                    "Attempting eglGetDisplay(EGL_DEFAULT_DISPLAY)\n");


                nEGL_Display = eglGetDisplay(EGL_DEFAULT_DISPLAY);

                if (EGL_NO_DISPLAY==nEGL_Display)

                {

                    errorf("Error: eglGetDisplay() failed.\n");

                    Shutdown();

                    return false;

                }

            }


            EGLint iMajorVersion, iMinorVersion;

            if (!eglInitialize(nEGL_Display, &iMajorVersion, &iMinorVersion))

            {

                EGLint iErr = eglGetError();

                errorf("Error: eglInitialize() failed (%s).\n",GetErrorString(iErr));

                Shutdown();

                return false;

            }


            EGLint pi32ConfigAttribs[10];

            int attrib = 0;

            pi32ConfigAttribs[attrib++] = EGL_SURFACE_TYPE;

            pi32ConfigAttribs[attrib++] = EGL_WINDOW_BIT;

            pi32ConfigAttribs[attrib++] = EGL_NONE;

            if ( FSAA )

            {

                pi32ConfigAttribs[attrib++] = EGL_SAMPLE_BUFFERS;

                pi32ConfigAttribs[attrib++] = 1;

                pi32ConfigAttribs[attrib++] = EGL_SAMPLES;

                pi32ConfigAttribs[attrib++] = 4;

            }

            pi32ConfigAttribs[attrib++] = EGL_NONE;


            EGLint iConfigs=0;

            if (!eglChooseConfig(nEGL_Display, pi32ConfigAttribs, &nEGL_Config, 1, &iConfigs) || (iConfigs != 1))

            {

                EGLint iErr = eglGetError();

                errorf("Error: eglChooseConfig() failed(%s).\n",GetErrorString(iErr));


                eglGetConfigs(nEGL_Display,NULL,0,&iConfigs);

                if (iConfigs)

                {

                    EGLConfig *cfgs=new EGLConfig[iConfigs];

                    eglGetConfigs(nEGL_Display,cfgs,iConfigs,&iConfigs);

                    for(int loop=0;loop<iConfigs;loop++)

                    {

                        EGLint scratch[4];

                        eglGetConfigAttrib(nEGL_Display,cfgs[loop],EGL_BUFFER_SIZE,&scratch[0]);

                        eglGetConfigAttrib(nEGL_Display,cfgs[loop],EGL_MAX_PBUFFER_WIDTH,&scratch[1]);

                        eglGetConfigAttrib(nEGL_Display,cfgs[loop],EGL_MAX_PBUFFER_HEIGHT,&scratch[2]);

                        eglGetConfigAttrib(nEGL_Display,cfgs[loop],EGL_SURFACE_TYPE,&scratch[3]);

                        errorf("%d:  %dx%dx%d, %X\n",loop,scratch[1],scratch[2],scratch[0],scratch[3]);

                    }

                    delete cfgs;

                }

                else

                    errorf("There are literally no configurations available.\n");


                Shutdown();

                return false;

            }


            nEGL_Surface = eglCreateWindowSurface(nEGL_Display, nEGL_Config, (NativeWindowType)nX11_Window, NULL);

            if (!TestEGLError("eglCreateWindowSurface"))

            {

                Shutdown();

                return false;

            }


            nEGL_Context = eglCreateContext(nEGL_Display, nEGL_Config, NULL, NULL);

            if (EGL_NO_CONTEXT==nEGL_Context)

            {

                EGLint iErr = eglGetError();

                errorf("Error: eglCreateContext() failed(%s).\n",GetErrorString(iErr));

                Shutdown();

                return false;

            }


            eglMakeCurrent(nEGL_Display, nEGL_Surface, nEGL_Surface, nEGL_Context);

            if (!TestEGLError("eglMakeCurrent"))

            {

                Shutdown();

                return false;

            }


    #ifdef __PLAT_PANDORA__

            nVSync = true;

    #else

            eglSwapInterval( nEGL_Display, 1 );

    #endif

            return true;

        }


        static bool InitX11()

        {

            Window sRootWindow;

            XSetWindowAttributes sWA;

            unsigned int ui32Mask;

            int i32Depth;


            nX11_Display = XOpenDisplay( ":0" );

            if (!nX11_Display)

            {

                errorf("Error: Unable to open X display\n");

                Shutdown();

                return false;

            }


            nX11_Screen = XDefaultScreen( nX11_Display );


            sRootWindow = RootWindow(nX11_Display, nX11_Screen);

            i32Depth    = DefaultDepth(nX11_Display, nX11_Screen);

            nX11_Visual = new XVisualInfo;

            XMatchVisualInfo( nX11_Display, nX11_Screen, i32Depth, TrueColor, nX11_Visual);

            if (!nX11_Visual)

            {

                errorf("Error: Unable to acquire visual\n");

                Shutdown();

                return false;

            }


            // Colormap of the specified visual type for the display.

            nX11_Colormap = XCreateColormap( nX11_Display, sRootWindow, nX11_Visual->visual, AllocNone );

            sWA.colormap = nX11_Colormap;


            // List of events to be handled by the application. Add to these for handling other events.

            sWA.event_mask = StructureNotifyMask | ExposureMask | ButtonPressMask | ButtonReleaseMask | KeyPressMask | KeyReleaseMask;


            // Display capabilities list.

            ui32Mask = CWBackPixel | CWBorderPixel | CWEventMask | CWColormap;


            // Creates the X11 window

            nX11_Window = XCreateWindow( nX11_Display, RootWindow(nX11_Display, nX11_Screen), 0, 0, nWidth, nHeight,

                0, CopyFromParent, InputOutput, CopyFromParent, ui32Mask, &sWA);


            // Make the window viewable and flush the output buffer.

            XMapWindow(nX11_Display, nX11_Window);

            XFlush(nX11_Display);


            return true;

        }


        bool Initialize(bool FSAA)

        {

            if (SDL_Init(SDL_INIT_VIDEO)!=0)

            {

                errorf("Unable to initialize SDL: %s\n", SDL_GetError());

                return false;

            }


            if (!InitX11())

            {

                errorf("Unable to initialize X11\n");

                return false;

            }


            if (!InitEGL(FSAA))

            {

                errorf("Unable to initialize EGL\n");

                return false;

            }


            Enable2D();


            char cmd[512];

            strcpy( cmd, "xset r rate 500 10" );

            system( cmd );


            return true;

        }




On Linux X86, I get:





Code:
Egl scizka: /usr/lib/libEGL.so

Egl scizka2: /usr/lib/libEGL.so

Error: eglChooseConfig() failed(Success!).

There are literally no configurations available.

Unable to initialize EGL



...and on the Pandora:



Code:
WARNING: eglGetDisplay((NativeDisplayType)nX11_Display) failed (Success!).

Attempting eglGetDisplay(EGL_DEFAULT_DISPLAY)

Error: eglInitialize() failed (BAD ALLOC).

server does not have extension for "r rate" option

Unable to initialize EGL


I haven't the faintest idea what is wrong on the Pandora, but I assume the issue on the X86 has to do with the GLES simulation libraries. Any ideas?


EDIT: This appears to be the cause of the OS/Distro I was developing with. This runs okay with the standard on-NAND OS. Thanks anyway.
 
Last edited by a moderator:
nEGL_Display = eglGetDisplay((NativeDisplayType)nX11_Display);

This line looks fishy to me, where is nX11_Display initialised?


I assume you are building this from an example somewhere or a book? If so can you link?


Edit: Also you are using both SDL and X11? What kind of madness is this? SDL is designed so that you don't have to deal with X11.


Choose one and go with it.
 
Last edited by a moderator:
Back
Top