Mercurial > sdl-ios-xcode
diff src/video/photon/SDL_ph_modes.c @ 663:8bedd6d61642
Date: Sat, 2 Aug 2003 16:22:51 +0300
From: "Mike Gorchak"
Subject: New patches for QNX6
Here my patches for the SDL/QNX:
QNXSDL.diff - diff to non-QNX related sources:
- updated BUGS file, I think QNX6 is now will be officially supported
- configure.in - added shared library support for QNX, and removed dependency between the ALSA and QNX6.
- SDL_audio.c - added QNX NTO sound bootstrap insted of ALSA's.
- SDL_sysaudio.h - the same.
- SDL_nto_audio.c - the same.
- SDL_video.c - right now, QNX doesn't offer any method to obtain pointers to the OpenGL functions by function name, so they must be hardcoded in library, otherwise OpenGL will not be supported.
- testsprite.c - fixed: do not draw vertical red line if we are in non-double-buffered mode.
sdlqnxph.tar.gz - archive of the ./src/video/photon/* . Too many changes in code to make diffs :) :
+ Added stub for support hide/unhide window event
+ Added full YUV overlays support.
+ Added window maximize support.
+ Added mouse wheel events.
+ Added support for some specific key codes in Unicode mode (like ESC).
+ Added more checks to the all memory allocation code.
+ Added SDL_DOUBLEBUF support in all fullscreen modes.
+ Added fallback to window mode, if desired fullscreen mode is not supported.
+ Added stub support for the GL_LoadLibrary and GL_GetProcAddress functions.
+ Added resizable window support without caption.
! Fixed bug in the Ph_EV_EXPOSE event handler, when rectangles to update is 0 and when width or height of the rectangle is 0.
! Fixed bug in the event handler code. Events has not been passed to the window widget handler.
! Fixed codes for Win keys (Super/Hyper/Menu).
! Fixed memory leak, when deallocation palette.
! Fixed palette emulation code bugs.
! Fixed fullscreen and hwsurface handling.
! Fixed CLOSE button bug. First event was passed to the handler, but second terminated the application. Now all events passed to the application correctly.
- Removed all printfs in code, now SDL_SetError used instead of them.
- Disabled ToggleFullScreen function.
README.QNX - updated README.QNX file. Added much more issues.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 04 Aug 2003 00:52:42 +0000 |
parents | 8e3ce997621c |
children | 04dd6c6d7c30 |
line wrap: on
line diff
--- a/src/video/photon/SDL_ph_modes.c Mon Jul 28 01:47:55 2003 +0000 +++ b/src/video/photon/SDL_ph_modes.c Mon Aug 04 00:52:42 2003 +0000 @@ -25,6 +25,7 @@ "@(#) $Id$"; #endif +#include "SDL_error.h" #include "SDL_ph_modes_c.h" static unsigned long key1, key2; @@ -39,8 +40,6 @@ { if (PgGetVideoModeInfo(*(unsigned short*)mode1, &mode_info) < 0) { - fprintf(stderr,"error: In compare_modes_by_res PgGetVideoModeInfo failed on mode: 0x%x\n", - *(unsigned short*)mode1); return 0; } @@ -48,19 +47,26 @@ if (PgGetVideoModeInfo(*(unsigned short*)mode2, &mode_info) < 0) { - fprintf(stderr,"error: In compare_modes_by_res PgGetVideoModeInfo failed on mode: 0x%x\n", - *(unsigned short*)mode2); return 0; } key2 = mode_info.width * mode_info.height; if (key1 > key2) + { return 1; - else if (key1 == key2) - return 0; + } else - return -1; + { + if (key1 == key2) + { + return 0; + } + else + { + return -1; + } + } } SDL_Rect **ph_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags) @@ -76,7 +82,7 @@ if (PgGetVideoModeList( &mode_list ) < 0) { - fprintf(stderr,"error: PgGetVideoModeList failed\n"); + SDL_SetError("ph_ListModes(): PgGetVideoModeList() function failed !\n"); return NULL; } @@ -86,7 +92,7 @@ { if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0) { - fprintf(stderr,"error: PgGetVideoModeInfo failed on mode: 0x%x\n", mode_list.modes[i]); + SDL_SetError("ph_ListModes(): PgGetVideoModeInfo() function failed on mode: 0x%X.\n", mode_list.modes[i]); return NULL; } if(mode_info.bits_per_pixel == format->BitsPerPixel) @@ -120,22 +126,12 @@ /* return the mode associated with width, height and bpp */ /* if there is no mode then zero is returned */ -int get_mode(int width, int height, int bpp) +int ph_GetVideoMode(int width, int height, int bpp) { int i; - if(width<640) - { - width=640; - } - if(height<480) - { - height=480; - } - if (PgGetVideoModeList(&mode_list) < 0) { - fprintf(stderr,"error: PgGetVideoModeList failed\n"); return -1; } @@ -144,7 +140,6 @@ { if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0) { - fprintf(stderr,"error: PgGetVideoModeInfo failed\n"); return 0; } @@ -159,89 +154,124 @@ return (i == mode_list.num_modes) ? 0 : mode_list.modes[i]; } -int get_mode_any_format(int width, int height, int bpp) /* return the mode associated with width, height and bpp */ /* if requested bpp is not found the mode with closest bpp is returned */ +int get_mode_any_format(int width, int height, int bpp) { int i, closest, delta, min_delta; - if (PgGetVideoModeList( &mode_list ) < 0) - { - fprintf(stderr,"error: PgGetVideoModeList failed\n"); - return -1; - } + if (PgGetVideoModeList(&mode_list) < 0) + { + return -1; + } + + qsort(mode_list.modes, mode_list.num_modes, sizeof(unsigned short), compare_modes_by_res); - qsort(mode_list.modes, mode_list.num_modes, sizeof(unsigned short), compare_modes_by_res); - for(i=0;i<mode_list.num_modes;i++) - { - if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0) - { - fprintf(stderr,"error: PgGetVideoModeInfo failed\n"); - return 0; - } - if ((mode_info.width == width) && - (mode_info.height == height)) + for(i=0;i<mode_list.num_modes;i++) + { + if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0) + { + return 0; + } + if ((mode_info.width == width) && (mode_info.height == height)) + { break; - } - if (i<mode_list.num_modes) - { - /* get closest bpp */ - closest = i++; - if (mode_info.bits_per_pixel == bpp) - return mode_list.modes[closest]; + } + } + + if (i<mode_list.num_modes) + { + /* get closest bpp */ + closest = i++; + if (mode_info.bits_per_pixel == bpp) + { + return mode_list.modes[closest]; + } + + min_delta = abs(mode_info.bits_per_pixel - bpp); - min_delta = abs(mode_info.bits_per_pixel - bpp); - while(1) - { - if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0) - { - fprintf(stderr,"error: PgGetVideoModeInfo failed\n"); - return 0; - } + while(1) + { + if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0) + { + return 0; + } - if ((mode_info.width != width) || - (mode_info.height != height)) - break; - else if (mode_info.bits_per_pixel == bpp) - { - closest = i; - break; - } - else - { - delta = abs(mode_info.bits_per_pixel - bpp); - if (delta < min_delta) - { - closest = i; - min_delta = delta; - } - i++; - } - } - return mode_list.modes[closest]; - } - else + if ((mode_info.width != width) || (mode_info.height != height)) + { + break; + } + else + { + if (mode_info.bits_per_pixel == bpp) + { + closest = i; + break; + } + else + { + delta = abs(mode_info.bits_per_pixel - bpp); + if (delta < min_delta) + { + closest = i; + min_delta = delta; + } + i++; + } + } + } + return mode_list.modes[closest]; + } + return 0; } int ph_ToggleFullScreen(_THIS, int on) { - if (currently_fullscreen) - { - return ph_LeaveFullScreen(this); - } - else - { - return ph_EnterFullScreen(this); - } - - return 0; + return -1; } -int ph_EnterFullScreen(_THIS) +int ph_EnterFullScreen(_THIS, SDL_Surface* screen) { + PgDisplaySettings_t settings; + int mode; + if (!currently_fullscreen) { + /* Get the video mode and set it */ + if (screen->flags & SDL_ANYFORMAT) + { + if ((mode = get_mode_any_format(screen->w, screen->h, screen->format->BitsPerPixel)) == 0) + { + SDL_SetError("ph_EnterFullScreen(): can't find appropriate video mode !\n"); + return 0; + } + } + else + { + if ((mode = ph_GetVideoMode(screen->w, screen->h, screen->format->BitsPerPixel)) == 0) + { + SDL_SetError("ph_EnterFullScreen(): can't find appropriate video mode !\n"); + return 0; + } + } + + /* save old video mode caps */ + PgGetVideoMode(&settings); + old_video_mode=settings.mode; + old_refresh_rate=settings.refresh; + + /* setup new video mode */ + settings.mode = mode; + settings.refresh = 0; + settings.flags = 0; + + if (PgSetVideoMode(&settings) < 0) + { + SDL_SetError("ph_EnterFullScreen(): PgSetVideoMode() call failed !\n"); + return 0; + } + if (this->screen) { if ((this->screen->flags & SDL_OPENGL)==SDL_OPENGL) @@ -255,12 +285,12 @@ if (OCImage.direct_context==NULL) { OCImage.direct_context=(PdDirectContext_t*)PdCreateDirectContext(); - } - - if (!OCImage.direct_context) - { - fprintf(stderr, "ph_EnterFullScreen(): Can't create direct context !\n"); - return 0; + if (!OCImage.direct_context) + { + SDL_SetError("ph_EnterFullScreen(): Can't create direct context !\n"); + ph_LeaveFullScreen(this); + return 0; + } } OCImage.oldDC=PdDirectStart(OCImage.direct_context); @@ -277,7 +307,7 @@ if (currently_fullscreen) { - if ((this->screen->flags & SDL_OPENGL)==SDL_OPENGL) + if ((this->screen) && ((this->screen->flags & SDL_OPENGL)==SDL_OPENGL)) { #ifdef HAVE_OPENGL #endif /* HAVE_OPENGL */ @@ -285,22 +315,30 @@ } else { - PdDirectStop(OCImage.direct_context); - PdReleaseDirectContext(OCImage.direct_context); - PhDCSetCurrent(OCImage.oldDC); + if (OCImage.direct_context) + { + PdDirectStop(OCImage.direct_context); + PdReleaseDirectContext(OCImage.direct_context); + OCImage.direct_context=NULL; + } + if (OCImage.oldDC) + { + PhDCSetCurrent(OCImage.oldDC); + OCImage.oldDC=NULL; + } currently_fullscreen=0; /* Restore old video mode */ if (old_video_mode != -1) { - mymode_settings.mode= (unsigned short) old_video_mode; - mymode_settings.refresh= (unsigned short) old_refresh_rate; - mymode_settings.flags= 0; + mymode_settings.mode = (unsigned short) old_video_mode; + mymode_settings.refresh = (unsigned short) old_refresh_rate; + mymode_settings.flags = 0; if (PgSetVideoMode(&mymode_settings) < 0) { - fprintf(stderr, "Ph_LeaveFullScreen(): PgSetVideoMode failed !\n"); + SDL_SetError("Ph_LeaveFullScreen(): PgSetVideoMode() function failed !\n"); return 0; } } @@ -308,7 +346,6 @@ old_video_mode=-1; old_refresh_rate=-1; } - } return 1; }