Commit 9ddae6ea authored by Sam Lantinga's avatar Sam Lantinga

Date: Thu, 28 Mar 2002 09:20:03 +0200

From: "Mike Gorchak" <mike@malva.ua>
Subject: New QNX patch.

Hi !

1. Removed warning (possible bug) with invalid type, passing to the function
in ph_WarpedMotion.
2. Rewritten handler of Ph_WM_RESIZE message, now works, but buggy (old
handler doesn't work at all).
3. Added stub handler for Ph_WM_MAX (maximize) message.
4. Added more #ifdef HAVE_OPENGL to disable OpenGL stuff when it not needed.
5. Added support for SDL_NOFRAME and SDL_RESIZABLE flags (in OpenGL windows
too).
6. Added cosmetic changes, if no SDL_RESIZABLE flag defined, disable resize
handlers in window border and maximize button at caption.
7. Fixed my bug with invalid arguments count passed to PtCreateWidget call.
8. Fixed some palette problems.
9. Updated README.QNX file.

And I changed testgl.c test application:

10. Added in testgl.c application support for SDL_NOFRAME flag and
option -noframe.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40321
parent a437e285
......@@ -7,10 +7,11 @@ new Photon3D runtime from http://developers.qnx.com. The versions
of OS before 6.1.0 are not supported.
Problems:
1. While creating OpenGL context artificially selected software
renderer mode (QSSL made acceleration only for Voodoo boards
in fullscreen mode, sorry but I don't have this board, if you
want acceleration - you may remove some line in source).
1. While creating OpenGL context software renderer mode is
artificially selected (QSSL made acceleration only for Voodoo
boards in fullscreen mode, sorry but I don't have this board,
if you want acceleration - you may remove some line in source
code).
2. Photon has some errors in detecting how much bits per pixel
videomode has.
3. No shared libraries yet. We need manually set flag to
......@@ -31,7 +32,8 @@ Some building issues:
--disable-shared \
--disable-video-opengl
In test directory also run ./configure script without x11 support, e.g.:
In test directory also run ./configure script without x11
support, e.g.:
./configure --with-sdl-prefix=/usr/local \
--with-sdl-exec-prefix=/usr/local \
......
......@@ -74,7 +74,7 @@ static int ph_KeyRepeat(_THIS, PhKeyEvent_t* keyevent)
(peekevent->timestamp == event->timestamp)
) {
repeated = 1;
//PhEventNext( peekevent, EVENT_SIZE );
/* PhEventNext( peekevent, EVENT_SIZE ); */
}
}
}
......@@ -85,7 +85,7 @@ static int ph_KeyRepeat(_THIS, PhKeyEvent_t* keyevent)
}
break;
default: // no events pending
default: /* no events pending */
}
return(repeated);
}
......@@ -93,11 +93,12 @@ static int ph_KeyRepeat(_THIS, PhKeyEvent_t* keyevent)
static int ph_WarpedMotion(_THIS, PhEvent_t *winEvent)
{
PhPointerEvent_t *pointer = PhGetData( winEvent );
/* PhPointerEvent_t *pointer = PhGetData( winEvent ); */
PhRect_t *rect = PhGetRects( winEvent );
int centre_x, centre_y;
int dx, dy, abs_x, abs_y;
int dx, dy;
short abs_x, abs_y;
int posted;
centre_x = SDL_VideoSurface->w / 2;
......@@ -165,29 +166,37 @@ static int ph_DispatchEvent(_THIS)
posted = 0;
switch (event->type) {
switch (event->type)
{
case Ph_EV_BOUNDARY:
{
if (event->subtype == Ph_EV_PTR_ENTER)
{
posted = SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
}
else if (event->subtype ==Ph_EV_PTR_LEAVE)
{
posted = SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
}
}
break;
case Ph_EV_PTR_MOTION_BUTTON:
case Ph_EV_PTR_MOTION_NOBUTTON:
{
if ( SDL_VideoSurface ) {
pointerEvent = PhGetData( event );
rect = PhGetRects( event );
if( mouse_relative )
if (SDL_VideoSurface)
{
pointerEvent = PhGetData(event);
rect = PhGetRects(event);
if (mouse_relative)
{
posted = ph_WarpedMotion(this, event);
}
else
posted = SDL_PrivateMouseMotion(0, 0,
rect->ul.x, rect->ul.y);
{
posted = SDL_PrivateMouseMotion(0, 0, rect->ul.x, rect->ul.y);
}
}
}
break;
......@@ -196,9 +205,10 @@ static int ph_DispatchEvent(_THIS)
{
pointerEvent = PhGetData( event );
buttons = ph2sdl_mousebutton( pointerEvent->buttons );
if( buttons != 0 )
posted = SDL_PrivateMouseButton( SDL_PRESSED, buttons,
0, 0 );
if (buttons != 0)
{
posted = SDL_PrivateMouseButton(SDL_PRESSED, buttons, 0, 0);
}
}
break;
......@@ -206,13 +216,11 @@ static int ph_DispatchEvent(_THIS)
{
pointerEvent = PhGetData(event);
buttons = ph2sdl_mousebutton(pointerEvent->buttons);
if( event->subtype == Ph_EV_RELEASE_REAL &&
buttons != 0 )
if (event->subtype == Ph_EV_RELEASE_REAL && buttons != 0)
{
posted = SDL_PrivateMouseButton( SDL_RELEASED,
buttons, 0, 0 );
posted = SDL_PrivateMouseButton(SDL_RELEASED, buttons, 0, 0);
}
else if( event->subtype == Ph_EV_RELEASE_PHANTOM )
else if(event->subtype == Ph_EV_RELEASE_PHANTOM)
{
/* If the mouse is outside the window,
* only a phantom release event is sent, so
......@@ -220,10 +228,9 @@ static int ph_DispatchEvent(_THIS)
* Not perfect, maybe checking the mouse button
* state for Ph_EV_BOUNDARY events would be
* better. */
if( ( SDL_GetAppState() & SDL_APPMOUSEFOCUS ) == 0 )
if ((SDL_GetAppState() & SDL_APPMOUSEFOCUS) == 0)
{
posted = SDL_PrivateMouseButton( SDL_RELEASED,
buttons, 0, 0 );
posted = SDL_PrivateMouseButton(SDL_RELEASED, buttons, 0, 0);
}
}
}
......@@ -231,11 +238,10 @@ static int ph_DispatchEvent(_THIS)
case Ph_EV_WM:
{
winEvent = PhGetData( event );
winEvent = PhGetData(event);
/* losing focus */
if ((winEvent->event_f==Ph_WM_FOCUS)&&
(winEvent->event_state==Ph_WM_EVSTATE_FOCUSLOST))
if ((winEvent->event_f==Ph_WM_FOCUS) && (winEvent->event_state==Ph_WM_EVSTATE_FOCUSLOST))
{
set_motion_sensitivity(this, Ph_EV_PTR_MOTION_BUTTON);
posted = SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS);
......@@ -244,31 +250,26 @@ static int ph_DispatchEvent(_THIS)
switch_waiting = 0x01;
switch_time = SDL_GetTicks() + 200;
}
/* gaining focus */
else if ((winEvent->event_f==Ph_WM_FOCUS)&&
(winEvent->event_state==Ph_WM_EVSTATE_FOCUS))
else if ((winEvent->event_f==Ph_WM_FOCUS) && (winEvent->event_state==Ph_WM_EVSTATE_FOCUS))
{
set_motion_sensitivity(this, -1);
posted = SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS);
#if 0
/* Queue entry into fullscreen mode */
switch_waiting = 0x01 | SDL_FULLSCREEN;
switch_time = SDL_GetTicks() + 1500;
#endif
}
/* request to quit */
else if (winEvent->event_f==Ph_WM_CLOSE)
{
posted = SDL_PrivateQuit();
}
/* request to resize */
else if (winEvent->event_f==Ph_WM_RESIZE)
{
PhDim_t *size;
PtGetResource( window, Pt_ARG_DIM, &size, 0 );
SDL_PrivateResize(size->w,size->h);
SDL_PrivateResize(winEvent->size.w, winEvent->size.h);
}
/* request to maximize */
else if (winEvent->event_f==Ph_WM_MAX)
{
/* TODO: get screen resolution, set window pos to 0, 0 and resize it ! */
}
}
break;
......@@ -278,9 +279,8 @@ static int ph_DispatchEvent(_THIS)
{
if (SDL_VideoSurface)
{
rect = PhGetRects( event );
rect = PhGetRects(event);
//PgSetClipping(1, rect );
for(i=0;i<event->num_rects;i++)
{
sdlrects[i].x = rect[i].ul.x;
......@@ -290,14 +290,12 @@ static int ph_DispatchEvent(_THIS)
}
this->UpdateRects(this, event->num_rects, sdlrects);
}
}
break;
case Ph_EV_KEY:
{
SDL_keysym keysym;
posted = 0;
......@@ -306,25 +304,19 @@ static int ph_DispatchEvent(_THIS)
if (Pk_KF_Key_Down & keyEvent->key_flags)
{
posted = SDL_PrivateKeyboard(SDL_PRESSED,
ph_TranslateKey( keyEvent, &keysym));
posted = SDL_PrivateKeyboard(SDL_PRESSED, ph_TranslateKey(keyEvent, &keysym));
}
else /* must be key release */
{
/* Ignore repeated key release events */
/*if (! Pk_KF_Key_Repeat & keyEvent->key_flags )*/
/* if (! Pk_KF_Key_Repeat & keyEvent->key_flags ) */
posted = SDL_PrivateKeyboard(SDL_RELEASED,
ph_TranslateKey( keyEvent, &keysym));
/*}*/
posted = SDL_PrivateKeyboard(SDL_RELEASED, ph_TranslateKey( keyEvent, &keysym));
}
}
break;
}
return(posted);
}
......
......@@ -175,15 +175,14 @@ static void ph_DeleteDevice(SDL_VideoDevice *device)
static int ph_VideoInit(_THIS, SDL_PixelFormat *vformat)
{
int i;
unsigned long *tempptr;
int rtnval;
PgVideoModeInfo_t my_mode_info;
PgHWCaps_t my_hwcaps;
window=NULL;
oglctx=NULL;
desktoppal=SDLPH_PAL_NONE;
#ifdef HAVE_OPENGL
oglctx=NULL;
#endif /* HAVE_OPENGL */
captionflag=0;
old_video_mode=-1;
......@@ -219,28 +218,10 @@ static int ph_VideoInit(_THIS, SDL_PixelFormat *vformat)
vformat->BytesPerPixel = my_mode_info.bytes_per_scanline/my_mode_info.width;
desktopbpp = my_mode_info.bits_per_pixel;
/* return a palette if we are in 256 color mode */
if (vformat->BitsPerPixel == 8)
/* save current palette */
if (desktopbpp==8)
{
vformat->palette = malloc(sizeof(SDL_Palette));
memset(vformat->palette, 0, sizeof(SDL_Palette));
vformat->palette->ncolors = 256;
vformat->palette->colors = (SDL_Color *)malloc(256 *sizeof(SDL_Color));
/* fill the palette */
rtnval = PgGetPalette(ph_palette);
if (rtnval < 0)
{
fprintf(stderr, "ph_VideoInit: PgGetPalette failed\n");
}
tempptr = (unsigned long *)vformat->palette->colors;
for(i=0;i<256; i++)
{
*tempptr = (((unsigned long)ph_palette[i]) << 8);
tempptr++;
}
PgGetPalette(ph_palette);
}
currently_fullscreen = 0;
......@@ -268,6 +249,8 @@ static SDL_Surface *ph_SetVideoMode(_THIS, SDL_Surface *current,
/* Lock the event thread, in multi-threading environments */
SDL_Lock_EventThread();
current->flags = flags;
/* create window if no OpenGL support selected */
if ((flags & SDL_OPENGL)!=SDL_OPENGL)
{
......@@ -276,6 +259,34 @@ static SDL_Surface *ph_SetVideoMode(_THIS, SDL_Surface *current,
PtSetArg(&arg[pargc++], Pt_ARG_DIM, &dim, 0);
PtSetArg(&arg[pargc++], Pt_ARG_RESIZE_FLAGS, Pt_FALSE, Pt_RESIZE_XY_AS_REQUIRED);
/* enable window minimizing */
PtSetArg(&arg[pargc++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE, Ph_WM_HIDE);
/* remove border and caption if no frame flag selected */
if ((flags & SDL_NOFRAME) == SDL_NOFRAME)
{
PtSetArg(&arg[pargc++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_FALSE, Ph_WM_RENDER_TITLE | Ph_WM_RENDER_BORDER);
}
else
{
PtSetArg(&arg[pargc++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_TRUE, Ph_WM_RENDER_TITLE | Ph_WM_RENDER_BORDER);
}
/* if window is not resizable then remove resize handles and maximize button */
if ((flags & SDL_RESIZABLE) != SDL_RESIZABLE)
{
PtSetArg(&arg[pargc++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_FALSE, Ph_WM_RENDER_RESIZE | Ph_WM_RENDER_MAX);
PtSetArg(&arg[pargc++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE, Ph_WM_RESIZE | Ph_WM_MAX);
PtSetArg(&arg[pargc++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_FALSE, Ph_WM_RESIZE | Ph_WM_MAX);
}
else
{
PtSetArg(&arg[pargc++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_TRUE, Ph_WM_RENDER_RESIZE | Ph_WM_RENDER_MAX);
/* it is need to be Pt_FALSE to allow the application to process the resize callback */
PtSetArg(&arg[pargc++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE, Ph_WM_RESIZE | Ph_WM_MAX);
PtSetArg(&arg[pargc++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE, Ph_WM_RESIZE | Ph_WM_MAX);
}
if (window!=NULL)
{
PtUnrealizeWidget(window);
......@@ -283,7 +294,7 @@ static SDL_Surface *ph_SetVideoMode(_THIS, SDL_Surface *current,
window=NULL;
}
window=PtCreateWidget(PtWindow, NULL, pargc-1, arg);
window=PtCreateWidget(PtWindow, NULL, pargc, arg);
PtRealizeWidget(window);
PtFlush();
......@@ -295,7 +306,6 @@ static SDL_Surface *ph_SetVideoMode(_THIS, SDL_Surface *current,
/* ph_SetupOpenGLContext creates also window as need */
if (ph_SetupOpenGLContext(this, width, height, bpp, flags)==0)
{
current->flags=flags;
/* setup OGL update function ... ugly method */
ph_ResizeImage(this, current, flags);
}
......@@ -363,15 +373,13 @@ static SDL_Surface *ph_SetVideoMode(_THIS, SDL_Surface *current,
} /* end fullscreen flag */
else
{
if (flags & SDL_HWSURFACE) /* Use offscreen memory iff SDL_HWSURFACE flag is set */
/* Use offscreen memory iff SDL_HWSURFACE flag is set */
if (flags & SDL_HWSURFACE)
{
/* Hardware surface is Offsceen Context. ph_ResizeImage handles the switch */
current->flags = (flags & (~SDL_RESIZABLE)); /* no stretch blit in offscreen context */
}
else /* must be SDL_SWSURFACE */
{
current->flags = (flags | SDL_RESIZABLE); /* yes we can resize as this is a software surface */
/* no stretch blit in offscreen context */
current->flags = (flags & (~SDL_RESIZABLE));
}
/* using palette emulation code in window mode */
if (bpp==8)
{
......@@ -425,6 +433,9 @@ static SDL_Surface *ph_SetVideoMode(_THIS, SDL_Surface *current,
ph_SetCaption(this, this->wm_title, NULL);
}
/* finish window drawing */
PtFlush();
SDL_Unlock_EventThread();
/* We're done! */
......@@ -433,7 +444,9 @@ static SDL_Surface *ph_SetVideoMode(_THIS, SDL_Surface *current,
static void ph_VideoQuit(_THIS)
{
#ifdef HAVE_OPENGL
PhRegion_t region_info;
#endif /* HAVE_OPENGL */
ph_DestroyImage(this, SDL_VideoSurface);
......@@ -443,7 +456,7 @@ static void ph_VideoQuit(_THIS)
}
#ifdef HAVE_OPENGL
/* prevent double SEGFAULT with parachute mode */
/* prevent double SEGFAULT during parachute mode */
if (this->screen)
{
if (((this->screen->flags & SDL_FULLSCREEN)==SDL_FULLSCREEN) &&
......@@ -518,14 +531,14 @@ static int ph_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
if ((this->screen->flags & SDL_FULLSCREEN) != SDL_FULLSCREEN)
{
/* window mode must use soft palette */
PgSetPalette((PgColor_t*)&syspalph, 0, firstcolor, ncolors, Pg_PALSET_SOFT, 0);
PgSetPalette((PgColor_t*)&syspalph[firstcolor], 0, firstcolor, ncolors, Pg_PALSET_SOFT, 0);
/* image needs to be redrawed, very slow method */
PgDrawPhImage(&point, SDL_Image, 0);
}
else
{
/* fullscreen mode must use hardware palette */
PgSetPalette((PgColor_t*)&syspalph, 0, firstcolor, ncolors, Pg_PALSET_GLOBAL, 0);
PgSetPalette((PgColor_t*)&syspalph[firstcolor], 0, firstcolor, ncolors, Pg_PALSET_GLOBAL, 0);
}
}
else
......@@ -586,9 +599,10 @@ int ph_SetupOpenGLContext(_THIS, int width, int height, int bpp, Uint32 flags)
{
oglctx=PdCreateOpenGLContext(1, &dim, 0, OGLAttrib);
}
if (oglctx==NULL)
{
fprintf(stderr,"error: cannot create OpenGL context.\n");
fprintf(stderr,"ph_SetupOpenGLContext: cannot create OpenGL context.\n");
return (-1);
}
......@@ -608,10 +622,26 @@ int ph_SetupOpenGLContext(_THIS, int width, int height, int bpp, Uint32 flags)
pos.y=0;
PtSetArg(&args[pargc++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_FALSE, ~0);
PtSetArg(&args[pargc++], Pt_ARG_WINDOW_MANAGED_FLAGS,Pt_TRUE, Ph_WM_FFRONT | Ph_WM_CLOSE | Ph_WM_TOFRONT | Ph_WM_CONSWITCH);
PtSetArg(&args[pargc++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE, Ph_WM_FFRONT | Ph_WM_CLOSE | Ph_WM_TOFRONT | Ph_WM_CONSWITCH);
PtSetArg(&args[pargc++], Pt_ARG_WINDOW_STATE, Pt_TRUE, Ph_WM_STATE_ISFRONT | Ph_WM_STATE_ISFOCUS);
PtSetArg(&args[pargc++], Pt_ARG_POS, &pos, 0);
}
else
{
/* remove border and caption if no frame flag selected */
if ((flags & SDL_NOFRAME) == SDL_NOFRAME)
{
PtSetArg(&args[pargc++], Pt_ARG_WINDOW_RENDER_FLAGS, 0, Ph_WM_RENDER_TITLE | Ph_WM_RENDER_BORDER);
}
else
{
/* if window is not resizable then remove resize handles */
if ((flags & SDL_RESIZABLE) != SDL_RESIZABLE)
{
PtSetArg(&args[pargc++], Pt_ARG_WINDOW_RENDER_FLAGS, 0, Ph_WM_RENDER_RESIZE);
}
}
}
if (window!=NULL)
{
......@@ -620,7 +650,7 @@ int ph_SetupOpenGLContext(_THIS, int width, int height, int bpp, Uint32 flags)
window=NULL;
}
window=PtCreateWidget(PtWindow, NULL, pargc-1, args);
window=PtCreateWidget(PtWindow, NULL, pargc, args);
PtRealizeWidget(window);
/* disable mouse for fullscreen */
......
......@@ -393,7 +393,7 @@ void DrawLogoBlit(void)
}
int RunGLTest( int argc, char* argv[],
int logo, int slowly, int bpp, float gamma )
int logo, int slowly, int bpp, float gamma, int noframe )
{
int i;
int rgb_size[3];
......@@ -447,6 +447,10 @@ int RunGLTest( int argc, char* argv[],
}
}
if (noframe) {
video_flags |= SDL_NOFRAME;
}
/* Initialize the display */
switch (bpp) {
case 8:
......@@ -686,6 +690,7 @@ int main(int argc, char *argv[])
int bpp = 0;
int slowly;
float gamma = 0.0;
int noframe = 0;
logo = 0;
slowly = 0;
......@@ -711,15 +716,18 @@ int main(int argc, char *argv[])
if ( strcmp(argv[i], "-gamma") == 0 ) {
gamma = (float)atof(argv[++i]);
}
if ( strcmp(argv[i], "-noframe") == 0 ) {
noframe = 1;
}
if ( strncmp(argv[i], "-h", 2) == 0 ) {
printf(
"Usage: %s [-twice] [-logo] [-slow] [-bpp n] [-gamma n]\n",
"Usage: %s [-twice] [-logo] [-slow] [-bpp n] [-gamma n] [-noframe]\n",
argv[0]);
exit(0);
}
}
for ( i=0; i<numtests; ++i ) {
RunGLTest(argc, argv, logo, slowly, bpp, gamma);
RunGLTest(argc, argv, logo, slowly, bpp, gamma, noframe);
}
return 0;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment