comparison src/video/photon/SDL_photon.c @ 3399:f96615051c8c

Working on fullscreen video modes support
author Mike Gorchak <lestat@i.com.ua>
date Tue, 13 Oct 2009 20:17:11 +0000
parents 05499ec8c022
children d15a4daa4a58
comparison
equal deleted inserted replaced
3398:5ecc05616f39 3399:f96615051c8c
425 SDL_free(didata->cursor); 425 SDL_free(didata->cursor);
426 SDL_free(didata); 426 SDL_free(didata);
427 return -1; 427 return -1;
428 } 428 }
429 429
430 /* Get current video mode 2D capabilities */ 430 /* Get current video mode 2D capabilities for the renderer */
431 didata->mode_2dcaps=0; 431 didata->mode_2dcaps=0;
432 if ((modeinfo.mode_capabilities2 & PgVM_MODE_CAP2_ALPHA_BLEND)==PgVM_MODE_CAP2_ALPHA_BLEND) 432 if ((modeinfo.mode_capabilities2 & PgVM_MODE_CAP2_ALPHA_BLEND)==PgVM_MODE_CAP2_ALPHA_BLEND)
433 { 433 {
434 didata->mode_2dcaps|=SDL_VIDEO_PHOTON_CAP_ALPHA_BLEND; 434 didata->mode_2dcaps|=SDL_VIDEO_PHOTON_CAP_ALPHA_BLEND;
435 } 435 }
467 467
468 /* Initialize display structure */ 468 /* Initialize display structure */
469 SDL_zero(display); 469 SDL_zero(display);
470 display.desktop_mode = current_mode; 470 display.desktop_mode = current_mode;
471 display.current_mode = current_mode; 471 display.current_mode = current_mode;
472 display.fullscreen_mode = current_mode;
472 display.driverdata = didata; 473 display.driverdata = didata;
473 didata->current_mode = current_mode; 474 didata->current_mode = current_mode;
474 SDL_AddVideoDisplay(&display); 475 SDL_AddVideoDisplay(&display);
475 476
476 /* Check for environment variables which could override some SDL settings */ 477 /* Check for environment variables which could override some SDL settings */
613 if (phdata->current_device_id != didata->device_id) { 614 if (phdata->current_device_id != didata->device_id) {
614 /* Set target device as default for Pd and Pg functions */ 615 /* Set target device as default for Pd and Pg functions */
615 status = PdSetTargetDevice(NULL, phdata->rid[didata->device_id]); 616 status = PdSetTargetDevice(NULL, phdata->rid[didata->device_id]);
616 if (status != 0) { 617 if (status != 0) {
617 SDL_SetError("Photon: Can't set default target device\n"); 618 SDL_SetError("Photon: Can't set default target device\n");
618 return; 619 return -1;
619 } 620 }
620 phdata->current_device_id = didata->device_id; 621 phdata->current_device_id = didata->device_id;
621 } 622 }
622 623
623 /* Get array of available video modes */ 624 /* Get array of available video modes */
624 status = PgGetVideoModeList(&modes); 625 status = PgGetVideoModeList(&modes);
625 if (status != 0) { 626 if (status != 0) {
626 SDL_SetError("Photon: Can't get video mode list"); 627 SDL_SetError("Photon: Can't get video mode list");
627 return; 628 return -1;
628 } 629 }
629 630
630 /* Current display dimension and bpp are no more valid */ 631 /* Current display dimension and bpp are no more valid */
631 didata->current_mode.format = SDL_PIXELFORMAT_UNKNOWN; 632 didata->current_mode.format = SDL_PIXELFORMAT_UNKNOWN;
632 didata->current_mode.w = 0; 633 didata->current_mode.w = 0;
759 760
760 /* Store new video mode parameters */ 761 /* Store new video mode parameters */
761 didata->current_mode = *mode; 762 didata->current_mode = *mode;
762 didata->current_mode.refresh_rate = refresh_rate; 763 didata->current_mode.refresh_rate = refresh_rate;
763 764
764 /* Get current video mode 2D capabilities */ 765 /* Get current video mode 2D capabilities for the renderer */
765 didata->mode_2dcaps=0; 766 didata->mode_2dcaps=0;
766 if ((modeinfo.mode_capabilities2 & PgVM_MODE_CAP2_ALPHA_BLEND)==PgVM_MODE_CAP2_ALPHA_BLEND) 767 if ((modeinfo.mode_capabilities2 & PgVM_MODE_CAP2_ALPHA_BLEND)==PgVM_MODE_CAP2_ALPHA_BLEND)
767 { 768 {
768 didata->mode_2dcaps|=SDL_VIDEO_PHOTON_CAP_ALPHA_BLEND; 769 didata->mode_2dcaps|=SDL_VIDEO_PHOTON_CAP_ALPHA_BLEND;
769 } 770 }
1037 PtFlush(); 1038 PtFlush();
1038 1039
1039 /* By default last created window got a input focus */ 1040 /* By default last created window got a input focus */
1040 SDL_SetKeyboardFocus(0, window->id); 1041 SDL_SetKeyboardFocus(0, window->id);
1041 1042
1043 /* Emit focus gained event, because photon is not sending it */
1044 SDL_OnWindowFocusGained(window);
1045
1042 /* Window has been successfully created */ 1046 /* Window has been successfully created */
1043 return 0; 1047 return 0;
1044 } 1048 }
1045 1049
1046 int 1050 int
1285 } 1289 }
1286 1290
1287 /* Free OpenGL ES target surface */ 1291 /* Free OpenGL ES target surface */
1288 if (wdata->gfsurface != NULL) { 1292 if (wdata->gfsurface != NULL) {
1289 gf_surface_free(wdata->gfsurface); 1293 gf_surface_free(wdata->gfsurface);
1294 wdata->gfsurface=NULL;
1290 } 1295 }
1291 1296
1292 phdata->egl_refcount--; 1297 phdata->egl_refcount--;
1293 if (phdata->egl_refcount == 0) { 1298 if (phdata->egl_refcount == 0) {
1294 /* Terminate connection to OpenGL ES */ 1299 /* Terminate connection to OpenGL ES */
1698 eglCreatePixmapSurface(phdata->egldisplay, 1703 eglCreatePixmapSurface(phdata->egldisplay,
1699 wdata->gles_configs[wdata->gles_config], 1704 wdata->gles_configs[wdata->gles_config],
1700 wdata->gfsurface, NULL); 1705 wdata->gfsurface, NULL);
1701 if (wdata->gles_surface == EGL_NO_SURFACE) { 1706 if (wdata->gles_surface == EGL_NO_SURFACE) {
1702 gf_surface_free(wdata->gfsurface); 1707 gf_surface_free(wdata->gfsurface);
1708 wdata->gfsurface=NULL;
1703 eglDestroyContext(phdata->egldisplay, wdata->gles_context); 1709 eglDestroyContext(phdata->egldisplay, wdata->gles_context);
1704 wdata->gles_context = EGL_NO_CONTEXT; 1710 wdata->gles_context = EGL_NO_CONTEXT;
1705 SDL_SetError("Photon: Can't create EGL pixmap surface"); 1711 SDL_SetError("Photon: Can't create EGL pixmap surface");
1706 return NULL; 1712 return NULL;
1707 } 1713 }
1721 1727
1722 /* Destroy OpenGL ES surface */ 1728 /* Destroy OpenGL ES surface */
1723 eglDestroySurface(phdata->egldisplay, wdata->gles_surface); 1729 eglDestroySurface(phdata->egldisplay, wdata->gles_surface);
1724 wdata->gles_surface=EGL_NO_SURFACE; 1730 wdata->gles_surface=EGL_NO_SURFACE;
1725 gf_surface_free(wdata->gfsurface); 1731 gf_surface_free(wdata->gfsurface);
1732 wdata->gfsurface=NULL;
1726 eglDestroyContext(phdata->egldisplay, wdata->gles_context); 1733 eglDestroyContext(phdata->egldisplay, wdata->gles_context);
1727 wdata->gles_context = EGL_NO_CONTEXT; 1734 wdata->gles_context = EGL_NO_CONTEXT;
1728 SDL_SetError("Photon: Can't set OpenGL ES context on creation"); 1735 SDL_SetError("Photon: Can't set OpenGL ES context on creation");
1729 return NULL; 1736 return NULL;
1730 } 1737 }
1784 if (status != 0) { 1791 if (status != 0) {
1785 /* Destroy OpenGL ES surface */ 1792 /* Destroy OpenGL ES surface */
1786 eglDestroySurface(phdata->egldisplay, wdata->gles_surface); 1793 eglDestroySurface(phdata->egldisplay, wdata->gles_surface);
1787 wdata->gles_surface=EGL_NO_SURFACE; 1794 wdata->gles_surface=EGL_NO_SURFACE;
1788 gf_surface_free(wdata->gfsurface); 1795 gf_surface_free(wdata->gfsurface);
1796 wdata->gfsurface=NULL;
1789 eglDestroyContext(phdata->egldisplay, wdata->gles_context); 1797 eglDestroyContext(phdata->egldisplay, wdata->gles_context);
1790 wdata->gles_context = EGL_NO_CONTEXT; 1798 wdata->gles_context = EGL_NO_CONTEXT;
1791 SDL_SetError("Photon: Can't set default target device\n"); 1799 SDL_SetError("Photon: Can't set default target device\n");
1792 return NULL; 1800 return NULL;
1793 } 1801 }
1798 if (wdata->phsurface == NULL) { 1806 if (wdata->phsurface == NULL) {
1799 /* Destroy OpenGL ES surface */ 1807 /* Destroy OpenGL ES surface */
1800 eglDestroySurface(phdata->egldisplay, wdata->gles_surface); 1808 eglDestroySurface(phdata->egldisplay, wdata->gles_surface);
1801 wdata->gles_surface=EGL_NO_SURFACE; 1809 wdata->gles_surface=EGL_NO_SURFACE;
1802 gf_surface_free(wdata->gfsurface); 1810 gf_surface_free(wdata->gfsurface);
1811 wdata->gfsurface=NULL;
1803 eglDestroyContext(phdata->egldisplay, wdata->gles_context); 1812 eglDestroyContext(phdata->egldisplay, wdata->gles_context);
1804 wdata->gles_context = EGL_NO_CONTEXT; 1813 wdata->gles_context = EGL_NO_CONTEXT;
1805 SDL_SetError("Photon: Can't bind GF surface to Photon\n"); 1814 SDL_SetError("Photon: Can't bind GF surface to Photon\n");
1806 return NULL; 1815 return NULL;
1807 } 1816 }