rpi/westeros-gl/westeros-gl.cpp
/*
 * WstGLCreateNativeWindow
 * Create a native window suitable for use as an EGLNativeWindow
 */
WstGLCreateNativeWindow
Create a native window suitable for use as an EGLNativeWindow
WstGLCreateNativeWindow Create a native window suitable for use as an EGLNativeWindow
void* WstGLCreateNativeWindow( WstGLCtx *ctx, int x, int y, int width, int height )
{
   void *nativeWindow= 0;
   if ( ctx )
   {
      if ( !ctx->dispmanDisplay )
      {
         if ( !wstGLSetupDisplay( ctx ) )
         {
            printf("WstGLCreateNativeWindow: wstGLSetupDisplay failed\n");
            goto exit;
         }
      }
      if ( ctx->displayWidth < width ) width= ctx->displayWidth;
      if ( ctx->displayHeight < height ) height= ctx->displayHeight;
      if ( ctx->dispmanDisplay )
      {
         VC_RECT_T destRect;
         VC_RECT_T srcRect;
         DISPMANX_ELEMENT_HANDLE_T dispmanElement;
         DISPMANX_UPDATE_HANDLE_T dispmanUpdate;
         EGL_DISPMANX_WINDOW_T *nw;
         dispmanUpdate= vc_dispmanx_update_start( 0 );
         if ( dispmanUpdate == DISPMANX_NO_HANDLE )
         {
            printf("WstGLCreateNativeWindow: vc_dispmanx_update_start failed\n" );
            goto exit;
         }
         printf("WstGLCreateNativeWindow: dispmanUpdate %p\n", dispmanUpdate );
         nw= (EGL_DISPMANX_WINDOW_T *)calloc( 1, sizeof(EGL_DISPMANX_WINDOW_T) );
         if ( nw )
         {
            destRect.x= x;
            destRect.y= y;
            destRect.width= width;
            destRect.height= height;
            srcRect.x= 0;
            srcRect.y= 0;
            srcRect.width= (width<<16);
            srcRect.height= (height<<16);
            dispmanElement= vc_dispmanx_element_add( dispmanUpdate,
                                                     ctx->dispmanDisplay,
                                                     110, 
                                                     &destRect,
                                                     0, 
                                                     &srcRect,
                                                     DISPMANX_PROTECTION_NONE,
                                                     0, 
                                                     0, 
                                                     DISPMANX_NO_ROTATE  
                                                   );
             if ( dispmanElement !=  DISPMANX_NO_HANDLE )
             {
                printf("WstGLCreateNativeWindow: dispmanElement %p\n", dispmanElement );
                nw->element= dispmanElement;
                nw->width= width;
                nw->height= height;
                nativeWindow= (void*)nw;
                vc_dispmanx_update_submit_sync( dispmanUpdate );
             }                                                                            
         }
      }
   }
exit:
   return nativeWindow;   
}
void * WstGLCreateNativeWindow ( WstGLCtx * ctx , int x , int y , int width , int height ) { void * nativeWindow = 0 ; if ( ctx ) { if ( ! ctx -> dispmanDisplay ) { if ( ! wstGLSetupDisplay ( ctx ) ) { printf ( " \n " ) ; goto exit ; } } if ( ctx -> displayWidth < width ) width = ctx -> displayWidth ; if ( ctx -> displayHeight < height ) height = ctx -> displayHeight ; if ( ctx -> dispmanDisplay ) { VC_RECT_T destRect ; VC_RECT_T srcRect ; DISPMANX_ELEMENT_HANDLE_T dispmanElement ; DISPMANX_UPDATE_HANDLE_T dispmanUpdate ; EGL_DISPMANX_WINDOW_T * nw ; dispmanUpdate = vc_dispmanx_update_start ( 0 ) ; if ( dispmanUpdate == DISPMANX_NO_HANDLE ) { printf ( " \n " ) ; goto exit ; } printf ( " \n " , dispmanUpdate ) ; nw = ( EGL_DISPMANX_WINDOW_T * ) calloc ( 1 , sizeof ( EGL_DISPMANX_WINDOW_T ) ) ; if ( nw ) { destRect . x = x ; destRect . y = y ; destRect . width = width ; destRect . height = height ; srcRect . x = 0 ; srcRect . y = 0 ; srcRect . width = ( width << 16 ) ; srcRect . height = ( height << 16 ) ; dispmanElement = vc_dispmanx_element_add ( dispmanUpdate , ctx -> dispmanDisplay , 110 , & destRect , 0 , & srcRect , DISPMANX_PROTECTION_NONE , 0 , 0 , DISPMANX_NO_ROTATE ) ; if ( dispmanElement != DISPMANX_NO_HANDLE ) { printf ( " \n " , dispmanElement ) ; nw -> element = dispmanElement ; nw -> width = width ; nw -> height = height ; nativeWindow = ( void * ) nw ; vc_dispmanx_update_submit_sync ( dispmanUpdate ) ; } } } } exit : return nativeWindow ; }
WstGLCreateNativeWindow
 Create a native window suitable for use as an EGLNativeWindow
WstGLCreateNativeWindow Create a native window suitable for use as an EGLNativeWindow
// Dest rect uses 32.0 fixed point // Src rect uses 16.16 fixed point //layer //src //alpha //clamp //transform