Changeset 1671


Ignore:
Timestamp:
Jul 26, 2012, 6:17:59 PM (8 years ago)
Author:
sam
Message:

core: on the Raspberry Pi, use the proprietary graphics library instead of
X11 to create the EGL-capable display.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/eglapp.cpp

    r1106 r1671  
    1313#endif
    1414
    15 #if defined USE_EGL
    16 #   include <X11/Xlib.h>
    17 #   include <X11/Xatom.h>
    18 #   include <X11/Xutil.h>
     15#define HAVE_BCM_HOST_H 1
     16#if defined USE_EGL
     17#   if defined HAVE_BCM_HOST_H
     18#       include <bcm_host.h>
     19#   else
     20#       include <X11/Xlib.h>
     21#       include <X11/Xatom.h>
     22#       include <X11/Xutil.h>
     23#   endif
    1924#   include <EGL/egl.h>
     25#   include <EGL/eglext.h>
    2026#endif
    2127
     
    3743private:
    3844#if defined USE_EGL
    39     Display *dpy;
    40     Window win;
    4145    EGLDisplay egl_dpy;
    4246    EGLContext egl_ctx;
    4347    EGLSurface egl_surf;
     48    uvec2 screen_size;
     49#   if defined HAVE_BCM_HOST_H
     50    EGL_DISPMANX_WINDOW_T nativewindow;
     51#   else
     52    Display *dpy;
     53    Window win;
     54#   endif
    4455#endif
    4556};
     
    5364{
    5465#if defined USE_EGL
     66#   if defined HAVE_BCM_HOST_H
     67    bcm_host_init();
     68
     69    data->egl_dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
     70#   else
    5571    data->dpy = XOpenDisplay(NULL);
    5672    if (data->dpy == NULL)
     
    8399
    84100    data->egl_dpy = eglGetDisplay((EGLNativeDisplayType)data->dpy);
     101#   endif
    85102    if (data->egl_dpy == EGL_NO_DISPLAY)
    86103    {
     
    119136    }
    120137
     138    if (!eglBindAPI(EGL_OPENGL_ES_API))
     139    {
     140        Log::Error("cannot bind OpenGL ES API (%i)\n", eglGetError());
     141        exit(EXIT_FAILURE);
     142    }
     143
     144#   if defined HAVE_BCM_HOST_H
     145    DISPMANX_ELEMENT_HANDLE_T dispman_element;
     146    DISPMANX_DISPLAY_HANDLE_T dispman_display;
     147    DISPMANX_UPDATE_HANDLE_T dispman_update;
     148    VC_RECT_T dst_rect;
     149    VC_RECT_T src_rect;
     150
     151    graphics_get_display_size(0 /* LCD */, &data->screen_size.x, &data->screen_size.y);
     152
     153    dst_rect.x = 0;
     154    dst_rect.y = 0;
     155    dst_rect.width = data->screen_size.x;
     156    dst_rect.height = data->screen_size.y;
     157
     158    src_rect.x = 0;
     159    src_rect.y = 0;
     160    src_rect.width = data->screen_size.x << 16;
     161    src_rect.height = data->screen_size.y << 16;
     162
     163    dispman_display = vc_dispmanx_display_open(0 /* LCD */);
     164    dispman_update = vc_dispmanx_update_start(0);
     165
     166    dispman_element = vc_dispmanx_element_add(dispman_update, dispman_display,
     167        0/*layer*/, &dst_rect, 0/*src*/, &src_rect, DISPMANX_PROTECTION_NONE,
     168        0 /*alpha*/, 0/*clamp*/, (DISPMANX_TRANSFORM_T)0/*transform*/);
     169
     170    data->nativewindow.element = dispman_element;
     171    data->nativewindow.width = data->screen_size.x;
     172    data->nativewindow.height = data->screen_size.y;
     173    vc_dispmanx_update_submit_sync(dispman_update);
     174
    121175    data->egl_surf = eglCreateWindowSurface(data->egl_dpy, ecfg,
    122                                             data->win, NULL);
     176                                            &data->nativewindow, NULL);
     177#   else
     178    data->egl_surf = eglCreateWindowSurface(data->egl_dpy, ecfg,
     179                                            (EGLNativeWindowType)data->win,
     180                                            NULL);
     181#   endif
    123182    if (data->egl_surf == EGL_NO_SURFACE)
    124183    {
     
    145204                   data->egl_surf, data->egl_ctx);
    146205
     206#   if !defined HAVE_BCM_HOST_H
    147207    XWindowAttributes gwa;
    148208    XGetWindowAttributes(data->dpy, data->win, &gwa);
     209    data->screen_size = ivec2(gwa.width, gwa.height);
     210#   endif
    149211
    150212    /* Initialise everything */
    151213    Ticker::Setup(fps);
    152     Video::Setup(ivec2(gwa.width, gwa.height));
     214    Video::Setup((ivec2)data->screen_size);
    153215    Audio::Setup(2);
    154216#endif
     217}
     218
     219void EglApp::ShowPointer(bool show)
     220{
     221    ;
    155222}
    156223
     
    173240    eglDestroySurface(data->egl_dpy, data->egl_surf);
    174241    eglTerminate(data->egl_dpy);
     242#   if defined HAVE_BCM_HOST_H
     243    /* FIXME */
     244#   else
    175245    XDestroyWindow(data->dpy, data->win);
    176246    XCloseDisplay(data->dpy);
     247#   endif
    177248#endif
    178249
  • trunk/src/eglapp.h

    r1139 r1671  
    3030    virtual ~EglApp();
    3131
     32    void ShowPointer(bool show);
    3233    void Run();
    3334
Note: See TracChangeset for help on using the changeset viewer.