Pandora EGL library fails in eglCreateWindowSurface() on Pandora on my end


Joined
Sep 12, 2010
Messages
282
for some reason eglCreateWindowSurface() fails now when running on OpenPandora when I build BetaBlockQuest, or anything using EGL.


on the OpenPandora it doesn't matter if I cross-build, if I build natively on OP in my debian chroot, or natively on OP using cdevtools1000,


I get the same result in all cases: "eglCreateWindowSurface() failed"


I've made a tiny EGL initialization test that creates a window then cycle the clear color to try to narrow down the issue.


on OP it just returns an error: EGL_BAD_NATIVE_WINDOW


on the PandaBoard it runs fine.


and from the EGL examples and documentation, it *should* work... and it does, just not on OP :(


so I can't update BetaBlockQuest sad.png


test_egl.cpp:

Code:
/*

example command line to compile


for pandaboard (ubuntu hardfloat):

arm-linux-gnueabihf-g++ test_egl.cpp -o test_egl -I/usr/lib/pvr-omap4-egl/include -L/usr/X11/lib -L/usr/lib/pvr-omap4-egl -lX11 -lEGL -lGLESv1_CM


for pandora:

arm-linux-gnueabi-g++ test_egl.cpp -o test_egl -I$HOME/cross_build/pandora/usr/include/ -L$HOME/cross_build/pandora/usr/lib/ -L$HOME/cross_build/pandora/GFX_Linux_SDK/OGLES/SDKPackage/Builds/OGLES/LinuxOMAP3/lib/ -lX11 -lEGL -lGLES_CM


for pandora using cdevtools1000:

g++ -o test_egl test_egl.cpp -lX11 -lEGL -lGLES_CM


*/


#include <stdio.h>

#include <stdlib.h>

#include <string.h>


#include <X11/Xutil.h>

#include <X11/Xlocale.h>

#include <X11/Xatom.h>

#include <X11/keysym.h>

#include <X11/Xresource.h>

#include <X11/Xos.h>

#include <X11/Xlib.h>

#include <X11/cursorfont.h>

#include <X11/extensions/dpms.h>

#include <X11/extensions/Xrandr.h>

#include <X11/extensions/Xinerama.h>

#include <X11/XKBlib.h>


#include <EGL/egl.h>

#include <GLES/gl.h>


#define WINDOW_EVENT_MASK ( \

    ExposureMask | StructureNotifyMask | PropertyChangeMask | FocusChangeMask | \

    PointerMotionMask | EnterWindowMask | LeaveWindowMask | \

    ButtonPressMask | ButtonReleaseMask | \

    KeyPressMask | KeyReleaseMask | KeymapStateMask \

)


int main(int argc, const char **argv)

{

    setlocale(LC_ALL, "");


    Display *display = 0;


    const char *display_name = 0;


    // open display, with retries

    for(int i=0; !display && (i < 5); i++){

        display = XOpenDisplay(display_name);

        if(!display){

            sleep(1);

        }

    }


    if(!display){

        printf("ERROR: XOpenDisplay()\n");

        return -1;

    }


    Screen *screen = DefaultScreenOfDisplay(display);

    int screen_number = DefaultScreen(display);


    Atom WM_DELETE_WINDOW;

    Atom WM_PROTOCOLS;


    WM_DELETE_WINDOW            = XInternAtom(display, "WM_DELETE_WINDOW", false);

    WM_PROTOCOLS                = XInternAtom(display, "WM_PROTOCOLS", false);


    Window window = XCreateSimpleWindow(

        display, RootWindow(display, screen_number),

        0, 0, 320, 240, 0,

        None, None);


    if(!window){

        printf("XCreateSimpleWindow() failed\n");

        return -1;

    }


    XFlush(display);


    XMapWindow(display, window);


    XFlush(display);


    const EGLint attrs[] = {

        EGL_LEVEL, 0,

        EGL_SURFACE_TYPE, EGL_WINDOW_BIT,

        EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT,

        //EGL_NATIVE_RENDERABLE, EGL_FALSE,

        EGL_DEPTH_SIZE, EGL_DONT_CARE,

        EGL_NONE

    };

    EGLint numConfig =0;



    EGLSurface    egl_surface;

    EGLContext    egl_context;

    EGLDisplay    egl_display;


    if ((egl_display = eglGetDisplay((EGLNativeDisplayType) EGL_DEFAULT_DISPLAY)) == EGL_NO_DISPLAY){

        printf("eglGetDisplay() failed\n");

        return -1;

    }


    // Initialize the display

    EGLint major = 0;

    EGLint minor = 0;

    if (!eglInitialize(egl_display, &major, &minor)){

        printf("eglInitialize() failed\n");

        return -1;

    }


    printf("EGL %d.%d\n", major, minor);


    EGLConfig eglConfig;


    // Obtain the first configuration with a depth buffer

    if (!eglChooseConfig(egl_display, attrs, &eglConfig, 1, &numConfig)){

      printf("eglChooseConfig() failed\n");

        return -1;

  }


    // Create a surface for the main window

    if ((egl_surface = eglCreateWindowSurface(egl_display, eglConfig, (EGLNativeWindowType)window, NULL)) == EGL_NO_SURFACE){

      printf("eglCreateWindowSurface() failed\n");

        return -1;

    }


    // Create an OpenGL ES context

    if ((egl_context = eglCreateContext(egl_display, eglConfig, EGL_NO_CONTEXT, 0)) == EGL_NO_CONTEXT){

      printf("eglCreateContext() failed\n");

        return -1;

    }


    // Make the context and surface current

    if (!eglMakeCurrent(egl_display, egl_surface, egl_surface, egl_context)){

      printf("eglMakeCurrent() failed\n");

        return -1;

    }


    XEvent xevent;


    int anim = 0;    

    bool quit = false;


    while(!quit){


        while(XCheckTypedEvent(display, ClientMessage, &xevent))

        {

            if(xevent.xclient.message_type == WM_PROTOCOLS){

                if(xevent.xclient.data.l[0] == WM_DELETE_WINDOW){

                    quit = true;

                } else {

                }

            } else {

            }

        }


        while(XCheckWindowEvent(display, window, WINDOW_EVENT_MASK, &xevent)){

        }


        ++anim;

        glClearColor(0.5f, (anim & 0xFF) * (1.0f/255.0f), 0.5f, 0.0f);

        glClear(GL_COLOR_BUFFER_BIT);


        eglSwapBuffers(egl_display, egl_surface);

    }


    return 0;

}
 
just guessing:


here



Code:
if ((egl_display = eglGetDisplay((EGLNativeDisplayType) EGL_DEFAULT_DISPLAY)) == EGL_NO_DISPLAY){



shouldn't that be



Code:
if ((egl_display = eglGetDisplay((EGLNativeDisplayType) display)) == EGL_NO_DISPLAY){


?
 
Last edited by a moderator:
just guessing:


here



Code:
if ((egl_display = eglGetDisplay((EGLNativeDisplayType) EGL_DEFAULT_DISPLAY)) == EGL_NO_DISPLAY){



shouldn't that be



Code:
if ((egl_display = eglGetDisplay((EGLNativeDisplayType) display)) == EGL_NO_DISPLAY){



?


SONOVA.... that was it.



Looks like the OMAP3 SGX EGL driver doesn't support EGL_DEFAULT_DISPLAY correctly.



its supposed to work according to: http://www.khronos.o...GetDisplay.html



and it does work on the PandaBoard (OMAP4) drivers.



the worst part is I *did* try that at some point in the last 6 months but something else must have made it fail because my initialization code had those two lines:



Code:
//egl_display = eglGetDisplay((EGLNativeDisplayType)(display));

egl_display = eglGetDisplay(EGL_DEFAULT_DISPLAY);


anyhow...


HURRAY!!!
 
Back
Top