Added QNX cleanups by Mike Gorchak (thanks!)
--HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40267
This commit is contained in:
parent
86a83938b6
commit
3a8a4d7b07
11 changed files with 245 additions and 329 deletions
19
README.QNX
Normal file
19
README.QNX
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
README by Mike Gorchak <mike@malva.com.ua>
|
||||||
|
|
||||||
|
Experimentally added OpenGL support in window mode (in fullscreen
|
||||||
|
mode not yet). If you have QNX RtP v6.1.0 w/ or w/o Patch A you need
|
||||||
|
to download new Photon3D runtime from http://developers.qnx.com. The
|
||||||
|
versions of OS before 6.1.0 is not supported. OpenGL support is very
|
||||||
|
raw. It is often fail.
|
||||||
|
|
||||||
|
Some building issues:
|
||||||
|
|
||||||
|
Run configure script without x11 support, e.g.:
|
||||||
|
|
||||||
|
./configure --prefix=/usr/local --disable-video-x11
|
||||||
|
|
||||||
|
In test directory also run ./configure script without x11 support, e.g.:
|
||||||
|
|
||||||
|
./configure --with-sdl-prefix=/usr/local \
|
||||||
|
--with-sdl-exec-prefix=/usr/local \
|
||||||
|
--prefix=/usr/local --without-x
|
|
@ -1392,6 +1392,8 @@ void SDL_GL_SwapBuffers(void)
|
||||||
|
|
||||||
if ( video->screen->flags & SDL_OPENGL ) {
|
if ( video->screen->flags & SDL_OPENGL ) {
|
||||||
video->GL_SwapBuffers(this);
|
video->GL_SwapBuffers(this);
|
||||||
|
} else {
|
||||||
|
SDL_SetError("OpenGL video mode has not been set");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,9 +55,10 @@ SDL_keysym *ph_TranslateKey(PhKeyEvent_t *key, SDL_keysym *keysym);
|
||||||
(idea shamelessly lifted from GII -- thanks guys! :)
|
(idea shamelessly lifted from GII -- thanks guys! :)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
static int ph_KeyRepeat(_THIS, PhKeyEvent_t* keyevent)
|
static int ph_KeyRepeat(_THIS, PhKeyEvent_t* keyevent)
|
||||||
{
|
{
|
||||||
PhEvent_t* peekevent;
|
// PhEvent_t* peekevent;
|
||||||
PhKeyEvent_t* keyEvent;
|
PhKeyEvent_t* keyEvent;
|
||||||
int repeated;
|
int repeated;
|
||||||
|
|
||||||
|
@ -84,11 +85,13 @@ static int ph_KeyRepeat(_THIS, PhKeyEvent_t* keyevent)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: /* no events pending */
|
default: // no events pending
|
||||||
}
|
}
|
||||||
return(repeated);
|
return(repeated);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
/* Note: The X server buffers and accumulates mouse motion events, so
|
/* Note: The X server buffers and accumulates mouse motion events, so
|
||||||
the motion event generated by the warp may not appear exactly as we
|
the motion event generated by the warp may not appear exactly as we
|
||||||
expect it to. We work around this (and improve performance) by only
|
expect it to. We work around this (and improve performance) by only
|
||||||
|
@ -118,7 +121,7 @@ static inline int X11_WarpedMotion(_THIS, XEvent *xevent)
|
||||||
(xevent->xmotion.x > (w-MOUSE_FUDGE_FACTOR)) ||
|
(xevent->xmotion.x > (w-MOUSE_FUDGE_FACTOR)) ||
|
||||||
(xevent->xmotion.y < MOUSE_FUDGE_FACTOR) ||
|
(xevent->xmotion.y < MOUSE_FUDGE_FACTOR) ||
|
||||||
(xevent->xmotion.y > (h-MOUSE_FUDGE_FACTOR)) ) {
|
(xevent->xmotion.y > (h-MOUSE_FUDGE_FACTOR)) ) {
|
||||||
/* Get the events that have accumulated */
|
// Get the events that have accumulated
|
||||||
/* while ( XCheckTypedEvent(SDL_Display, MotionNotify, xevent) ) {
|
/* while ( XCheckTypedEvent(SDL_Display, MotionNotify, xevent) ) {
|
||||||
deltax = xevent->xmotion.x - mouse_last.x;
|
deltax = xevent->xmotion.x - mouse_last.x;
|
||||||
deltay = xevent->xmotion.y - mouse_last.y;
|
deltay = xevent->xmotion.y - mouse_last.y;
|
||||||
|
@ -161,6 +164,7 @@ static inline int X11_WarpedMotion(_THIS, XEvent *xevent)
|
||||||
|
|
||||||
/* Control which motion flags the window has set, a flags value of -1 sets
|
/* Control which motion flags the window has set, a flags value of -1 sets
|
||||||
* MOTION_BUTTON and MOTION_NOBUTTON */
|
* MOTION_BUTTON and MOTION_NOBUTTON */
|
||||||
|
|
||||||
static void set_motion_sensitivity(_THIS, unsigned int flags)
|
static void set_motion_sensitivity(_THIS, unsigned int flags)
|
||||||
{
|
{
|
||||||
int rid, fields = Ph_EV_PTR_MOTION_BUTTON | Ph_EV_PTR_MOTION_NOBUTTON;
|
int rid, fields = Ph_EV_PTR_MOTION_BUTTON | Ph_EV_PTR_MOTION_NOBUTTON;
|
||||||
|
|
|
@ -175,14 +175,11 @@ int ph_SetupOCImage(_THIS, SDL_Surface *screen) //Offscreen context
|
||||||
|
|
||||||
void ph_DestroyImage(_THIS, SDL_Surface *screen)
|
void ph_DestroyImage(_THIS, SDL_Surface *screen)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
if(SDL_Image == NULL)
|
if(SDL_Image == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (OCImage.offscreen_context != NULL)
|
if (OCImage.offscreen_context != NULL)
|
||||||
{
|
{
|
||||||
|
|
||||||
PhDCRelease(OCImage.offscreen_context);
|
PhDCRelease(OCImage.offscreen_context);
|
||||||
OCImage.offscreen_context = NULL;
|
OCImage.offscreen_context = NULL;
|
||||||
free(OCImage.FrameData0);
|
free(OCImage.FrameData0);
|
||||||
|
@ -210,7 +207,6 @@ void ph_DestroyImage(_THIS, SDL_Surface *screen)
|
||||||
|
|
||||||
int ph_ResizeImage(_THIS, SDL_Surface *screen, Uint32 flags)
|
int ph_ResizeImage(_THIS, SDL_Surface *screen, Uint32 flags)
|
||||||
{
|
{
|
||||||
|
|
||||||
ph_DestroyImage(this, screen);
|
ph_DestroyImage(this, screen);
|
||||||
|
|
||||||
if( flags & SDL_HWSURFACE)
|
if( flags & SDL_HWSURFACE)
|
||||||
|
@ -226,30 +222,25 @@ int ph_ResizeImage(_THIS, SDL_Surface *screen, Uint32 flags)
|
||||||
{
|
{
|
||||||
return ph_SetupImage(this, screen);
|
return ph_SetupImage(this, screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ph_AllocHWSurface(_THIS, SDL_Surface *surface)
|
int ph_AllocHWSurface(_THIS, SDL_Surface *surface)
|
||||||
{
|
{
|
||||||
|
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ph_FreeHWSurface(_THIS, SDL_Surface *surface)
|
void ph_FreeHWSurface(_THIS, SDL_Surface *surface)
|
||||||
{
|
{
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ph_FlipHWSurface(_THIS, SDL_Surface *surface)
|
int ph_FlipHWSurface(_THIS, SDL_Surface *surface)
|
||||||
{
|
{
|
||||||
|
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ph_LockHWSurface(_THIS, SDL_Surface *surface)
|
int ph_LockHWSurface(_THIS, SDL_Surface *surface)
|
||||||
{
|
{
|
||||||
|
|
||||||
if ( (surface == SDL_VideoSurface) && blit_queued ) {
|
if ( (surface == SDL_VideoSurface) && blit_queued ) {
|
||||||
// XSync(GFX_Display, False);
|
// XSync(GFX_Display, False);
|
||||||
PgFlush();
|
PgFlush();
|
||||||
|
@ -260,7 +251,6 @@ int ph_LockHWSurface(_THIS, SDL_Surface *surface)
|
||||||
|
|
||||||
void ph_UnlockHWSurface(_THIS, SDL_Surface *surface)
|
void ph_UnlockHWSurface(_THIS, SDL_Surface *surface)
|
||||||
{
|
{
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,16 +25,15 @@ static char rcsid =
|
||||||
"@(#) $Id$";
|
"@(#) $Id$";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#include "SDL_ph_modes_c.h"
|
#include "SDL_ph_modes_c.h"
|
||||||
|
|
||||||
static unsigned long key1, key2;
|
static unsigned long key1, key2;
|
||||||
static PgVideoModeInfo_t mode_info;
|
static PgVideoModeInfo_t mode_info;
|
||||||
static PgVideoModes_t mode_list;
|
static PgVideoModes_t mode_list;
|
||||||
|
|
||||||
/* The current list of available video modes */
|
/* The current list of available video modes */
|
||||||
SDL_Rect SDL_modelist[127];
|
SDL_Rect SDL_modelist[PH_MAX_VIDEOMODES];
|
||||||
SDL_Rect *SDLmod_ptr;
|
SDL_Rect* SDL_modearray[PH_MAX_VIDEOMODES];
|
||||||
SDL_Rect **SDLmod_ptrptr ;
|
|
||||||
|
|
||||||
static int compare_modes_by_res(const void* mode1, const void* mode2)
|
static int compare_modes_by_res(const void* mode1, const void* mode2)
|
||||||
{
|
{
|
||||||
|
@ -63,6 +62,7 @@ static int compare_modes_by_res(const void* mode1, const void* mode2)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
static int compare_modes_by_bpp(const void* mode1, const void* mode2)
|
static int compare_modes_by_bpp(const void* mode1, const void* mode2)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -89,7 +89,9 @@ static int compare_modes_by_bpp(const void* mode1, const void* mode2)
|
||||||
else
|
else
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
int ph_GetVideoModes(_THIS)
|
int ph_GetVideoModes(_THIS)
|
||||||
{
|
{
|
||||||
unsigned short *front;
|
unsigned short *front;
|
||||||
|
@ -149,13 +151,18 @@ int ph_GetVideoModes(_THIS)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
static SDL_Rect** ph_SupportedVisual( SDL_PixelFormat *format)
|
SDL_Rect **ph_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int j = 0;
|
int j = 0;
|
||||||
SDL_Rect Amodelist[127];
|
SDL_Rect Amodelist[PH_MAX_VIDEOMODES];
|
||||||
|
|
||||||
|
for (i=0; i<PH_MAX_VIDEOMODES; i++)
|
||||||
|
{
|
||||||
|
SDL_modearray[i]=&SDL_modelist[i];
|
||||||
|
}
|
||||||
|
|
||||||
if (PgGetVideoModeList( &mode_list ) < 0)
|
if (PgGetVideoModeList( &mode_list ) < 0)
|
||||||
{
|
{
|
||||||
|
@ -185,6 +192,7 @@ static SDL_Rect** ph_SupportedVisual( SDL_PixelFormat *format)
|
||||||
}
|
}
|
||||||
|
|
||||||
//reorder biggest for smallest, assume width dominates
|
//reorder biggest for smallest, assume width dominates
|
||||||
|
|
||||||
for(i=0; i< j ; i++)
|
for(i=0; i< j ; i++)
|
||||||
{
|
{
|
||||||
SDL_modelist[i].w = Amodelist[j - i -1].w;
|
SDL_modelist[i].w = Amodelist[j - i -1].w;
|
||||||
|
@ -192,28 +200,14 @@ static SDL_Rect** ph_SupportedVisual( SDL_PixelFormat *format)
|
||||||
SDL_modelist[i].x = Amodelist[j - i -1].x;
|
SDL_modelist[i].x = Amodelist[j - i -1].x;
|
||||||
SDL_modelist[i].y = Amodelist[j - i -1].y;
|
SDL_modelist[i].y = Amodelist[j - i -1].y;
|
||||||
}
|
}
|
||||||
|
SDL_modearray[j]=NULL;
|
||||||
|
|
||||||
SDLmod_ptr = SDL_modelist;
|
return SDL_modearray;
|
||||||
SDLmod_ptrptr = &SDLmod_ptr;
|
|
||||||
return SDLmod_ptrptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_Rect **ph_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
|
|
||||||
{
|
|
||||||
return ph_SupportedVisual( format);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ph_FreeVideoModes(_THIS)
|
void ph_FreeVideoModes(_THIS)
|
||||||
{
|
{
|
||||||
// int i;
|
return;
|
||||||
|
|
||||||
// if ( SDL_modelist ) {
|
|
||||||
// for ( i=0; SDL_modelist[i]; ++i ) {
|
|
||||||
// free(SDL_modelist[i]);
|
|
||||||
// }
|
|
||||||
// free(SDL_modelist);
|
|
||||||
// SDL_modelist = NULL;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_best_resolution(_THIS, int width, int height)
|
static void set_best_resolution(_THIS, int width, int height)
|
||||||
|
@ -287,6 +281,7 @@ static void set_best_resolution(_THIS, int width, int height)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
static void get_real_resolution(_THIS, int* w, int* h)
|
static void get_real_resolution(_THIS, int* w, int* h)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -294,13 +289,13 @@ static void get_real_resolution(_THIS, int* w, int* h)
|
||||||
//PgDisplaySettings_t settings;
|
//PgDisplaySettings_t settings;
|
||||||
PgVideoModeInfo_t current_mode_info;
|
PgVideoModeInfo_t current_mode_info;
|
||||||
PgHWCaps_t my_hwcaps;
|
PgHWCaps_t my_hwcaps;
|
||||||
int unused;
|
// int unused;
|
||||||
/*
|
|
||||||
if (PgGetVideoMode( &settings ) >= 0) {
|
// if (PgGetVideoMode( &settings ) >= 0) {
|
||||||
*w = settings.xres;
|
// *w = settings.xres;
|
||||||
*h = settings.yres;
|
// *h = settings.yres;
|
||||||
return;
|
// return;
|
||||||
}*/
|
// }
|
||||||
if (PgGetGraphicsHWCaps(&my_hwcaps) >= 0)
|
if (PgGetGraphicsHWCaps(&my_hwcaps) >= 0)
|
||||||
{
|
{
|
||||||
if (PgGetVideoModeInfo(my_hwcaps.current_video_mode, ¤t_mode_info) < 0)
|
if (PgGetVideoModeInfo(my_hwcaps.current_video_mode, ¤t_mode_info) < 0)
|
||||||
|
@ -314,6 +309,7 @@ static void get_real_resolution(_THIS, int* w, int* h)
|
||||||
// *w = DisplayWidth(SDL_Display, SDL_Screen);
|
// *w = DisplayWidth(SDL_Display, SDL_Screen);
|
||||||
// *h = DisplayHeight(SDL_Display, SDL_Screen);
|
// *h = DisplayHeight(SDL_Display, SDL_Screen);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
int ph_ResizeFullScreen(_THIS)
|
int ph_ResizeFullScreen(_THIS)
|
||||||
{
|
{
|
||||||
|
|
|
@ -31,7 +31,9 @@ static char rcsid =
|
||||||
|
|
||||||
#include "SDL_ph_video.h"
|
#include "SDL_ph_video.h"
|
||||||
|
|
||||||
extern int ph_GetVideoModes(_THIS);
|
#define PH_MAX_VIDEOMODES 127
|
||||||
|
|
||||||
|
//extern int ph_GetVideoModes(_THIS);
|
||||||
extern SDL_Rect **ph_ListModes(_THIS,SDL_PixelFormat *format, Uint32 flags);
|
extern SDL_Rect **ph_ListModes(_THIS,SDL_PixelFormat *format, Uint32 flags);
|
||||||
extern void ph_FreeVideoModes(_THIS);
|
extern void ph_FreeVideoModes(_THIS);
|
||||||
extern int ph_ResizeFullScreen(_THIS);
|
extern int ph_ResizeFullScreen(_THIS);
|
||||||
|
|
|
@ -95,7 +95,8 @@ WMcursor *ph_CreateWMCursor(_THIS,
|
||||||
|
|
||||||
/* Copy the mask and the data to different
|
/* Copy the mask and the data to different
|
||||||
bitmap planes */
|
bitmap planes */
|
||||||
for ( i=0; i<clen; ++i ) {
|
for ( i=0; i<clen; ++i )
|
||||||
|
{
|
||||||
cursor->ph_cursor->images[i] = data[i];
|
cursor->ph_cursor->images[i] = data[i];
|
||||||
cursor->ph_cursor->images[i+clen] = mask[i];
|
cursor->ph_cursor->images[i+clen] = mask[i];
|
||||||
}
|
}
|
||||||
|
@ -109,7 +110,6 @@ WMcursor *ph_CreateWMCursor(_THIS,
|
||||||
|
|
||||||
PhCursorDef_t ph_GetWMPhCursor(WMcursor *cursor)
|
PhCursorDef_t ph_GetWMPhCursor(WMcursor *cursor)
|
||||||
{
|
{
|
||||||
|
|
||||||
return(*cursor->ph_cursor);
|
return(*cursor->ph_cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,8 +120,6 @@ int ph_ShowWMCursor(_THIS, WMcursor *cursor)
|
||||||
int nargs = 0;
|
int nargs = 0;
|
||||||
short cursor_is_defined = 0;
|
short cursor_is_defined = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Don't do anything if the display is gone */
|
/* Don't do anything if the display is gone */
|
||||||
if ( window == NULL ) {
|
if ( window == NULL ) {
|
||||||
return(0);
|
return(0);
|
||||||
|
@ -163,7 +161,6 @@ int ph_ShowWMCursor(_THIS, WMcursor *cursor)
|
||||||
|
|
||||||
void ph_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
|
void ph_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
|
||||||
{
|
{
|
||||||
|
|
||||||
SDL_Lock_EventThread();
|
SDL_Lock_EventThread();
|
||||||
PhMoveCursorRel( PhInputGroup(NULL), x, y );
|
PhMoveCursorRel( PhInputGroup(NULL), x, y );
|
||||||
SDL_Unlock_EventThread();
|
SDL_Unlock_EventThread();
|
||||||
|
@ -172,6 +169,5 @@ void ph_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
|
||||||
|
|
||||||
void ph_CheckMouseMode(_THIS)
|
void ph_CheckMouseMode(_THIS)
|
||||||
{
|
{
|
||||||
|
|
||||||
mouse_relative = 1;
|
mouse_relative = 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,10 +56,12 @@ static SDL_Surface *ph_SetVideoMode(_THIS, SDL_Surface *current,
|
||||||
static int ph_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors);
|
static int ph_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors);
|
||||||
static void ph_VideoQuit(_THIS);
|
static void ph_VideoQuit(_THIS);
|
||||||
static void ph_DeleteDevice(SDL_VideoDevice *device);
|
static void ph_DeleteDevice(SDL_VideoDevice *device);
|
||||||
|
static void ph_GL_SwapBuffers(_THIS);
|
||||||
|
|
||||||
|
PdOpenGLContext_t* OGLContext=NULL;
|
||||||
|
|
||||||
static int ph_Available(void)
|
static int ph_Available(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,6 +119,13 @@ static SDL_VideoDevice *ph_CreateDevice(int devindex)
|
||||||
device->InitOSKeymap = ph_InitOSKeymap;
|
device->InitOSKeymap = ph_InitOSKeymap;
|
||||||
device->PumpEvents = ph_PumpEvents;
|
device->PumpEvents = ph_PumpEvents;
|
||||||
|
|
||||||
|
// OpenGL support.
|
||||||
|
device->GL_LoadLibrary = NULL;
|
||||||
|
device->GL_GetProcAddress = NULL;
|
||||||
|
device->GL_GetAttribute = NULL;
|
||||||
|
device->GL_MakeCurrent = NULL;
|
||||||
|
device->GL_SwapBuffers = ph_GL_SwapBuffers;
|
||||||
|
|
||||||
device->free = ph_DeleteDevice;
|
device->free = ph_DeleteDevice;
|
||||||
|
|
||||||
return device;
|
return device;
|
||||||
|
@ -152,7 +161,7 @@ static int ph_VideoInit(_THIS, SDL_PixelFormat *vformat)
|
||||||
int i;
|
int i;
|
||||||
unsigned long *tempptr;
|
unsigned long *tempptr;
|
||||||
int rtnval;
|
int rtnval;
|
||||||
PgDisplaySettings_t mysettings;
|
// PgDisplaySettings_t mysettings;
|
||||||
PgVideoModeInfo_t my_mode_info;
|
PgVideoModeInfo_t my_mode_info;
|
||||||
PgHWCaps_t my_hwcaps;
|
PgHWCaps_t my_hwcaps;
|
||||||
|
|
||||||
|
@ -224,6 +233,7 @@ static int ph_VideoInit(_THIS, SDL_PixelFormat *vformat)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"ph_VideoInit: PgGetVideoModeInfo failed\n");
|
fprintf(stderr,"ph_VideoInit: PgGetVideoModeInfo failed\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
//We need to return BytesPerPixel as it in used by CreateRGBsurface
|
//We need to return BytesPerPixel as it in used by CreateRGBsurface
|
||||||
vformat->BitsPerPixel = my_mode_info.bits_per_pixel;
|
vformat->BitsPerPixel = my_mode_info.bits_per_pixel;
|
||||||
vformat->BytesPerPixel = vformat->BitsPerPixel/8;
|
vformat->BytesPerPixel = vformat->BitsPerPixel/8;
|
||||||
|
@ -263,7 +273,7 @@ static int ph_VideoInit(_THIS, SDL_PixelFormat *vformat)
|
||||||
static SDL_Surface *ph_SetVideoMode(_THIS, SDL_Surface *current,
|
static SDL_Surface *ph_SetVideoMode(_THIS, SDL_Surface *current,
|
||||||
int width, int height, int bpp, Uint32 flags)
|
int width, int height, int bpp, Uint32 flags)
|
||||||
{
|
{
|
||||||
PhRegion_t region_info;
|
// PhRegion_t region_info;
|
||||||
PgDisplaySettings_t settings;
|
PgDisplaySettings_t settings;
|
||||||
PgHWCaps_t my_hwcaps;
|
PgHWCaps_t my_hwcaps;
|
||||||
PgVideoModeInfo_t mode_info;
|
PgVideoModeInfo_t mode_info;
|
||||||
|
@ -271,24 +281,23 @@ static SDL_Surface *ph_SetVideoMode(_THIS, SDL_Surface *current,
|
||||||
PtArg_t arg[5];
|
PtArg_t arg[5];
|
||||||
PhDim_t dim;
|
PhDim_t dim;
|
||||||
int rtnval;
|
int rtnval;
|
||||||
SDL_Rect ** mymodelist;
|
|
||||||
SDL_PixelFormat myformat;
|
|
||||||
PgColor_t ph_palette[_Pg_MAX_PALETTE];
|
PgColor_t ph_palette[_Pg_MAX_PALETTE];
|
||||||
int i;
|
int i;
|
||||||
unsigned long *tempptr;
|
unsigned long *tempptr;
|
||||||
|
uint64_t OGLAttrib[PH_OGL_MAX_ATTRIBS];
|
||||||
|
|
||||||
actual_width = width;
|
actual_width = width;
|
||||||
actual_height = height;
|
actual_height = height;
|
||||||
|
|
||||||
|
dim.w=width;
|
||||||
|
dim.h=height;
|
||||||
|
|
||||||
/* Lock the event thread, in multi-threading environments */
|
/* Lock the event thread, in multi-threading environments */
|
||||||
SDL_Lock_EventThread();
|
SDL_Lock_EventThread();
|
||||||
|
|
||||||
|
|
||||||
/* Initialize the window */
|
/* Initialize the window */
|
||||||
if (flags & SDL_FULLSCREEN) //Direct Context , assume SDL_HWSURFACE also set
|
if (flags & SDL_FULLSCREEN) //Direct Context , assume SDL_HWSURFACE also set
|
||||||
{
|
{
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if (old_video_mode==-1)
|
if (old_video_mode==-1)
|
||||||
{
|
{
|
||||||
|
@ -298,8 +307,6 @@ static SDL_Surface *ph_SetVideoMode(_THIS, SDL_Surface *current,
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Get the video mode and set it */
|
/* Get the video mode and set it */
|
||||||
if (bpp == 0)
|
if (bpp == 0)
|
||||||
{
|
{
|
||||||
|
@ -342,7 +349,6 @@ static SDL_Surface *ph_SetVideoMode(_THIS, SDL_Surface *current,
|
||||||
settings.refresh = 0;
|
settings.refresh = 0;
|
||||||
settings.flags = 0;
|
settings.flags = 0;
|
||||||
|
|
||||||
|
|
||||||
if (PgSetVideoMode( &settings ) < 0)
|
if (PgSetVideoMode( &settings ) < 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"error: PgSetVideoMode failed\n");
|
fprintf(stderr,"error: PgSetVideoMode failed\n");
|
||||||
|
@ -358,7 +364,9 @@ static SDL_Surface *ph_SetVideoMode(_THIS, SDL_Surface *current,
|
||||||
|
|
||||||
|
|
||||||
} //end fullscreen flag
|
} //end fullscreen flag
|
||||||
else if (flags & SDL_HWSURFACE) /* Use offscreen memory iff SDL_HWSURFACE flag is set */
|
else
|
||||||
|
{
|
||||||
|
if (flags & SDL_HWSURFACE) /* Use offscreen memory iff SDL_HWSURFACE flag is set */
|
||||||
{
|
{
|
||||||
// Hardware surface is Offsceen Context. ph_ResizeImage handles the switch
|
// Hardware surface is Offsceen Context. ph_ResizeImage handles the switch
|
||||||
current->flags = (flags|(~SDL_RESIZABLE)); //no stretch blit in offscreen context
|
current->flags = (flags|(~SDL_RESIZABLE)); //no stretch blit in offscreen context
|
||||||
|
@ -368,6 +376,21 @@ static SDL_Surface *ph_SetVideoMode(_THIS, SDL_Surface *current,
|
||||||
current->flags = (flags|SDL_RESIZABLE); //yes we can resize as this is a software surface
|
current->flags = (flags|SDL_RESIZABLE); //yes we can resize as this is a software surface
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (flags & SDL_OPENGL) // for now support OpenGL in window mode only
|
||||||
|
{
|
||||||
|
OGLAttrib[0]=PHOGL_ATTRIB_DEPTH_BITS;
|
||||||
|
OGLAttrib[1]=bpp;
|
||||||
|
OGLAttrib[2]=PHOGL_ATTRIB_NONE;
|
||||||
|
OGLContext=PdCreateOpenGLContext(2, &dim, 0, OGLAttrib);
|
||||||
|
if (OGLContext==NULL)
|
||||||
|
{
|
||||||
|
fprintf(stderr,"error: cannot create OpenGL context\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
PhDCSetCurrent(OGLContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//If we are setting video to use the palette make sure we have allocated memory for it
|
//If we are setting video to use the palette make sure we have allocated memory for it
|
||||||
if(bpp == 8)
|
if(bpp == 8)
|
||||||
|
@ -422,7 +445,6 @@ static void ph_VideoQuit(_THIS)
|
||||||
if(SDL_Image != NULL)
|
if(SDL_Image != NULL)
|
||||||
{
|
{
|
||||||
ph_DestroyImage(this, SDL_VideoSurface);
|
ph_DestroyImage(this, SDL_VideoSurface);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currently_fullscreen)
|
if (currently_fullscreen)
|
||||||
|
@ -494,6 +516,13 @@ static int ph_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
|
||||||
return alloct_all;
|
return alloct_all;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ph_GL_SwapBuffers(_THIS)
|
||||||
|
{
|
||||||
|
PgSetRegion(PtWidgetRid(window));
|
||||||
|
PdOpenGLContextSwapBuffers(OGLContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
static int ph_ResizeWindow(_THIS,
|
static int ph_ResizeWindow(_THIS,
|
||||||
SDL_Surface *screen, int w, int h, Uint32 flags)
|
SDL_Surface *screen, int w, int h, Uint32 flags)
|
||||||
{
|
{
|
||||||
|
@ -512,5 +541,4 @@ static int ph_ResizeWindow(_THIS,
|
||||||
current_h = h;
|
current_h = h;
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
|
@ -50,10 +50,13 @@ static unsigned TranslatedFillColor;
|
||||||
#include "Pt.h"
|
#include "Pt.h"
|
||||||
#include <photon/Pg.h>
|
#include <photon/Pg.h>
|
||||||
#include <photon/PdDirect.h>
|
#include <photon/PdDirect.h>
|
||||||
|
#include <photon/PdGL.h>
|
||||||
|
|
||||||
/* Hidden "this" pointer for the video functions */
|
/* Hidden "this" pointer for the video functions */
|
||||||
#define _THIS SDL_VideoDevice *this
|
#define _THIS SDL_VideoDevice *this
|
||||||
|
|
||||||
|
#define PH_OGL_MAX_ATTRIBS 32
|
||||||
|
|
||||||
typedef union vidptr{
|
typedef union vidptr{
|
||||||
uint8_t *volatile ptr8;
|
uint8_t *volatile ptr8;
|
||||||
uint16_t *volatile ptr16;
|
uint16_t *volatile ptr16;
|
||||||
|
|
|
@ -230,14 +230,13 @@ void ph_SetCaption(_THIS, const char *title, const char *icon)
|
||||||
SDL_Unlock_EventThread();
|
SDL_Unlock_EventThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Iconify the window (stolen from PhHotKey sources by phearbear ;-) */
|
/* Iconify current window */
|
||||||
int ph_IconifyWindow(_THIS)
|
int ph_IconifyWindow(_THIS)
|
||||||
{
|
{
|
||||||
#if 1 /* Code submitted by Luca <barbato_luca@yahoo.com> */
|
|
||||||
WmApiContext_t context=WmCreateContext();
|
WmApiContext_t context=WmCreateContext();
|
||||||
WmWindowDefinition_t
|
WmWindowDefinition_t **wininfo=malloc(sizeof(WmWindowDefinition_t)*2);
|
||||||
**wininfo=malloc(sizeof(WmWindowDefinition_t)*2);
|
|
||||||
int num;
|
int num;
|
||||||
|
|
||||||
SDL_Lock_EventThread();
|
SDL_Lock_EventThread();
|
||||||
WmGetFocusList(context,2,&num,wininfo);
|
WmGetFocusList(context,2,&num,wininfo);
|
||||||
WmPerformFrameAction(context, wininfo[0]->rid,Pt_ACTION_MIN);
|
WmPerformFrameAction(context, wininfo[0]->rid,Pt_ACTION_MIN);
|
||||||
|
@ -245,153 +244,30 @@ int ph_IconifyWindow(_THIS)
|
||||||
WmDestroyContext (context);
|
WmDestroyContext (context);
|
||||||
SDL_Unlock_EventThread();
|
SDL_Unlock_EventThread();
|
||||||
free(wininfo);
|
free(wininfo);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
#else
|
|
||||||
int result=0;
|
|
||||||
int myerr;
|
|
||||||
int num;
|
|
||||||
PtConnectionClient_t *Client=0;
|
|
||||||
WmMsg_t* Message=malloc(sizeof(WmMsg_t));
|
|
||||||
WmReply_t *Reply=malloc(sizeof(WmReply_t));
|
|
||||||
WmApiContext_t MsgStruct=malloc(sizeof(WmApiContext_t));
|
|
||||||
WmWindowDefinition_t **WNDDEF=malloc(sizeof(WmWindowDefinition_t)*2);
|
|
||||||
|
|
||||||
SDL_Lock_EventThread();
|
|
||||||
|
|
||||||
PtInit("/dev/photon");
|
|
||||||
|
|
||||||
Client=PtConnectionFindName("pwm",0,0);
|
|
||||||
|
|
||||||
if(!Client)
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
MsgStruct->input_group=PhInputGroup(0);
|
|
||||||
MsgStruct->connection=PtConnectionFindName("pwm",0,0);
|
|
||||||
myerr=WmGetFocusList(MsgStruct,2,&num,WNDDEF);
|
|
||||||
|
|
||||||
Message->hdr.type=WM_REQUEST_WIN_ACTION;
|
|
||||||
Message->hdr.subtype=Pt_ACTION_MIN;
|
|
||||||
Message->hdr.rid=WNDDEF[0]->rid;
|
|
||||||
myerr=WmSendMessage(Client,Message,Reply,0);
|
|
||||||
|
|
||||||
free(Message);
|
|
||||||
free(Reply);
|
|
||||||
|
|
||||||
SDL_Unlock_EventThread();
|
|
||||||
|
|
||||||
return(result);
|
|
||||||
#endif /* 1 */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_GrabMode ph_GrabInputNoLock(_THIS, SDL_GrabMode mode)
|
SDL_GrabMode ph_GrabInputNoLock(_THIS, SDL_GrabMode mode)
|
||||||
{
|
{
|
||||||
#if 0 /*big*/
|
|
||||||
int numtries, result;
|
|
||||||
|
|
||||||
if ( this->screen == NULL ) {
|
|
||||||
return(SDL_GRAB_OFF);
|
|
||||||
}
|
|
||||||
if ( ! SDL_Window ) {
|
|
||||||
return(mode); /* Will be set later on mode switch */
|
|
||||||
}
|
|
||||||
if ( mode == SDL_GRAB_OFF ) {
|
|
||||||
XUngrabPointer(SDL_Display, CurrentTime);
|
|
||||||
if ( this->screen->flags & SDL_FULLSCREEN ) {
|
|
||||||
/* Rebind the mouse to the fullscreen window */
|
|
||||||
for ( numtries = 0; numtries < 10; ++numtries ) {
|
|
||||||
result = XGrabPointer(SDL_Display, FSwindow,
|
|
||||||
True, 0,
|
|
||||||
GrabModeAsync, GrabModeAsync,
|
|
||||||
FSwindow, None, CurrentTime);
|
|
||||||
if ( result == AlreadyGrabbed ) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
SDL_Delay(100);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#ifdef GRAB_FULLSCREEN
|
|
||||||
if ( !(this->screen->flags & SDL_FULLSCREEN) )
|
|
||||||
#endif
|
|
||||||
XUngrabKeyboard(SDL_Display, CurrentTime);
|
|
||||||
} else {
|
|
||||||
if ( this->screen->flags & SDL_FULLSCREEN ) {
|
|
||||||
/* Unbind the mouse from the fullscreen window */
|
|
||||||
XUngrabPointer(SDL_Display, CurrentTime);
|
|
||||||
}
|
|
||||||
/* Try to grab the mouse */
|
|
||||||
for ( numtries = 0; numtries < 10; ++numtries ) {
|
|
||||||
result = XGrabPointer(SDL_Display, SDL_Window, True, 0,
|
|
||||||
GrabModeAsync, GrabModeAsync,
|
|
||||||
SDL_Window, None, CurrentTime);
|
|
||||||
if ( result != AlreadyGrabbed ) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
SDL_Delay(100);
|
|
||||||
}
|
|
||||||
#ifdef GRAB_FULLSCREEN
|
|
||||||
if ( !(this->screen->flags & SDL_FULLSCREEN) )
|
|
||||||
#endif
|
|
||||||
XGrabKeyboard(SDL_Display, WMwindow, True,
|
|
||||||
GrabModeAsync, GrabModeAsync, CurrentTime);
|
|
||||||
}
|
|
||||||
XSync(SDL_Display, False);
|
|
||||||
|
|
||||||
|
|
||||||
#endif /*big*/
|
|
||||||
return(mode);
|
return(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_GrabMode ph_GrabInput(_THIS, SDL_GrabMode mode)
|
SDL_GrabMode ph_GrabInput(_THIS, SDL_GrabMode mode)
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
SDL_Lock_EventThread();
|
|
||||||
mode = X11_GrabInputNoLock(this, mode);
|
|
||||||
SDL_Unlock_EventThread();
|
|
||||||
#endif
|
|
||||||
return(mode);
|
return(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If 'info' is the right version, this function fills it and returns 1.
|
|
||||||
Otherwise, in case of a version mismatch, it returns -1.
|
|
||||||
*/
|
|
||||||
static void lock_display(void)
|
|
||||||
{
|
|
||||||
SDL_Lock_EventThread();
|
|
||||||
}
|
|
||||||
static void unlock_display(void)
|
|
||||||
{
|
|
||||||
#if 0
|
|
||||||
/* Make sure any X11 transactions are completed */
|
|
||||||
SDL_VideoDevice *this = current_video;
|
|
||||||
XSync(SDL_Display, False);
|
|
||||||
#endif
|
|
||||||
SDL_Unlock_EventThread();
|
|
||||||
}
|
|
||||||
int ph_GetWMInfo(_THIS, SDL_SysWMinfo *info)
|
int ph_GetWMInfo(_THIS, SDL_SysWMinfo *info)
|
||||||
{
|
{
|
||||||
#if 0
|
if (info->version.major <= SDL_MAJOR_VERSION)
|
||||||
if ( info->version.major <= SDL_MAJOR_VERSION ) {
|
{
|
||||||
info->subsystem = SDL_SYSWM_X11;
|
return 1;
|
||||||
info->info.x11.display = SDL_Display;
|
|
||||||
info->info.x11.window = SDL_Window;
|
|
||||||
if ( SDL_VERSIONNUM(info->version.major,
|
|
||||||
info->version.minor,
|
|
||||||
info->version.patch) >= 1002 ) {
|
|
||||||
info->info.x11.fswindow = FSwindow;
|
|
||||||
info->info.x11.wmwindow = WMwindow;
|
|
||||||
}
|
}
|
||||||
info->info.x11.lock_func = lock_display;
|
else
|
||||||
info->info.x11.unlock_func = unlock_display;
|
{
|
||||||
return(1);
|
|
||||||
} else {
|
|
||||||
SDL_SetError("Application not compiled with SDL %d.%d\n",
|
SDL_SetError("Application not compiled with SDL %d.%d\n",
|
||||||
SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
|
SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
|
||||||
return(-1);
|
return -1;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return -1; // for now ...
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ int main(int argc, char *argv[])
|
||||||
} else {
|
} else {
|
||||||
printf("Fullscreen video modes:\n");
|
printf("Fullscreen video modes:\n");
|
||||||
for ( i=0; modes[i]; ++i ) {
|
for ( i=0; modes[i]; ++i ) {
|
||||||
printf("\t%dx%d\n", modes[i]->w, modes[i]->h);
|
printf("\t%dx%dx%d\n", modes[i]->w, modes[i]->h, info->vfmt->BitsPerPixel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( info->wm_available ) {
|
if ( info->wm_available ) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue