src/video/pandora/SDL_pandora.c
changeset 7037 3fedf1f25b94
parent 6885 700f1b25f77f
child 7191 75360622e65f
equal deleted inserted replaced
7036:8c891504e325 7037:3fedf1f25b94
   209 
   209 
   210 
   210 
   211     /* Allocate window internal data */
   211     /* Allocate window internal data */
   212     wdata = (SDL_WindowData *) SDL_calloc(1, sizeof(SDL_WindowData));
   212     wdata = (SDL_WindowData *) SDL_calloc(1, sizeof(SDL_WindowData));
   213     if (wdata == NULL) {
   213     if (wdata == NULL) {
   214         SDL_OutOfMemory();
   214         return SDL_OutOfMemory();
   215         return -1;
       
   216     }
   215     }
   217 
   216 
   218     /* Setup driver data for this window */
   217     /* Setup driver data for this window */
   219     window->driverdata = wdata;
   218     window->driverdata = wdata;
   220 
   219 
   228 
   227 
   229         /* Create connection to OpenGL ES */
   228         /* Create connection to OpenGL ES */
   230         if (phdata->egl_display == EGL_NO_DISPLAY) {
   229         if (phdata->egl_display == EGL_NO_DISPLAY) {
   231             phdata->egl_display = eglGetDisplay((NativeDisplayType) 0);
   230             phdata->egl_display = eglGetDisplay((NativeDisplayType) 0);
   232             if (phdata->egl_display == EGL_NO_DISPLAY) {
   231             if (phdata->egl_display == EGL_NO_DISPLAY) {
   233                 SDL_SetError("PND: Can't get connection to OpenGL ES");
   232                 return SDL_SetError("PND: Can't get connection to OpenGL ES");
   234                 return -1;
       
   235             }
   233             }
   236 
   234 
   237             initstatus = eglInitialize(phdata->egl_display, NULL, NULL);
   235             initstatus = eglInitialize(phdata->egl_display, NULL, NULL);
   238             if (initstatus != EGL_TRUE) {
   236             if (initstatus != EGL_TRUE) {
   239                 SDL_SetError("PND: Can't init OpenGL ES library");
   237                 return SDL_SetError("PND: Can't init OpenGL ES library");
   240                 return -1;
       
   241             }
   238             }
   242         }
   239         }
   243 
   240 
   244         phdata->egl_refcount++;
   241         phdata->egl_refcount++;
   245     }
   242     }
   354 
   351 
   355     /* Load dynamic library */
   352     /* Load dynamic library */
   356     _this->gl_config.dll_handle = SDL_LoadObject(path);
   353     _this->gl_config.dll_handle = SDL_LoadObject(path);
   357     if (!_this->gl_config.dll_handle) {
   354     if (!_this->gl_config.dll_handle) {
   358         /* Failed to load new GL ES library */
   355         /* Failed to load new GL ES library */
   359         SDL_SetError("PND: Failed to locate OpenGL ES library");
   356         return SDL_SetError("PND: Failed to locate OpenGL ES library");
   360         return -1;
       
   361     }
   357     }
   362 
   358 
   363     /* Store OpenGL ES library path and name */
   359     /* Store OpenGL ES library path and name */
   364     SDL_strlcpy(_this->gl_config.driver_path, path,
   360     SDL_strlcpy(_this->gl_config.driver_path, path,
   365                 SDL_arraysize(_this->gl_config.driver_path));
   361                 SDL_arraysize(_this->gl_config.driver_path));
   724     SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
   720     SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
   725     SDL_WindowData *wdata;
   721     SDL_WindowData *wdata;
   726     EGLBoolean status;
   722     EGLBoolean status;
   727 
   723 
   728     if (phdata->egl_initialized != SDL_TRUE) {
   724     if (phdata->egl_initialized != SDL_TRUE) {
   729         SDL_SetError("PND: GF initialization failed, no OpenGL ES support");
   725         return SDL_SetError("PND: GF initialization failed, no OpenGL ES support");
   730         return -1;
       
   731     }
   726     }
   732 
   727 
   733     if ((window == NULL) && (context == NULL)) {
   728     if ((window == NULL) && (context == NULL)) {
   734         status =
   729         status =
   735             eglMakeCurrent(phdata->egl_display, EGL_NO_SURFACE,
   730             eglMakeCurrent(phdata->egl_display, EGL_NO_SURFACE,
   736                            EGL_NO_SURFACE, EGL_NO_CONTEXT);
   731                            EGL_NO_SURFACE, EGL_NO_CONTEXT);
   737         if (status != EGL_TRUE) {
   732         if (status != EGL_TRUE) {
   738             /* Failed to set current GL ES context */
   733             /* Failed to set current GL ES context */
   739             SDL_SetError("PND: Can't set OpenGL ES context");
   734             return SDL_SetError("PND: Can't set OpenGL ES context");
   740             return -1;
       
   741         }
   735         }
   742     } else {
   736     } else {
   743         wdata = (SDL_WindowData *) window->driverdata;
   737         wdata = (SDL_WindowData *) window->driverdata;
   744         if (wdata->gles_surface == EGL_NO_SURFACE) {
   738         if (wdata->gles_surface == EGL_NO_SURFACE) {
   745             SDL_SetError
   739             return SDL_SetError
   746                 ("PND: OpenGL ES surface is not initialized for this window");
   740                 ("PND: OpenGL ES surface is not initialized for this window");
   747             return -1;
       
   748         }
   741         }
   749         if (wdata->gles_context == EGL_NO_CONTEXT) {
   742         if (wdata->gles_context == EGL_NO_CONTEXT) {
   750             SDL_SetError
   743             return SDL_SetError
   751                 ("PND: OpenGL ES context is not initialized for this window");
   744                 ("PND: OpenGL ES context is not initialized for this window");
   752             return -1;
       
   753         }
   745         }
   754         if (wdata->gles_context != context) {
   746         if (wdata->gles_context != context) {
   755             SDL_SetError
   747             return SDL_SetError
   756                 ("PND: OpenGL ES context is not belong to this window");
   748                 ("PND: OpenGL ES context is not belong to this window");
   757             return -1;
       
   758         }
   749         }
   759         status =
   750         status =
   760             eglMakeCurrent(phdata->egl_display, wdata->gles_surface,
   751             eglMakeCurrent(phdata->egl_display, wdata->gles_surface,
   761                            wdata->gles_surface, wdata->gles_context);
   752                            wdata->gles_surface, wdata->gles_context);
   762         if (status != EGL_TRUE) {
   753         if (status != EGL_TRUE) {
   763             /* Failed to set current GL ES context */
   754             /* Failed to set current GL ES context */
   764             SDL_SetError("PND: Can't set OpenGL ES context");
   755             return SDL_SetError("PND: Can't set OpenGL ES context");
   765             return -1;
       
   766         }
   756         }
   767     }
   757     }
   768     return 0;
   758     return 0;
   769 }
   759 }
   770 
   760 
   773 {
   763 {
   774     SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
   764     SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
   775     EGLBoolean status;
   765     EGLBoolean status;
   776 
   766 
   777     if (phdata->egl_initialized != SDL_TRUE) {
   767     if (phdata->egl_initialized != SDL_TRUE) {
   778         SDL_SetError("PND: EGL initialization failed, no OpenGL ES support");
   768         return SDL_SetError("PND: EGL initialization failed, no OpenGL ES support");
   779         return -1;
       
   780     }
   769     }
   781 
   770 
   782     /* Check if OpenGL ES connection has been initialized */
   771     /* Check if OpenGL ES connection has been initialized */
   783     if (phdata->egl_display != EGL_NO_DISPLAY) {
   772     if (phdata->egl_display != EGL_NO_DISPLAY) {
   784         /* Set swap OpenGL ES interval */
   773         /* Set swap OpenGL ES interval */
   789             return 0;
   778             return 0;
   790         }
   779         }
   791     }
   780     }
   792 
   781 
   793     /* Failed to set swap interval */
   782     /* Failed to set swap interval */
   794     SDL_SetError("PND: Cannot set swap interval");
   783     return SDL_SetError("PND: Cannot set swap interval");
   795     return -1;
       
   796 }
   784 }
   797 
   785 
   798 int
   786 int
   799 PND_gl_getswapinterval(_THIS)
   787 PND_gl_getswapinterval(_THIS)
   800 {
   788 {