Date: Thu, 21 Feb 2002 09:18:24 +0200
From: "Mike Gorchak" <mike@malva.ua> Subject: Re: Patches for QNX RtP again. SDL_ph_image.c - Added OpenGL update functions - fixed some application crashes. Some dead code removed, reformatting some functions. SDL_ph_image_c.h - Added OpenGL update function prototype. SDL_ph_video.c - Added GL_GetAttribute and GL_SetAttribute functions with next supported flags: SDL_GL_DOUBLEBUFFER, SDL_GL_STENCIL_SIZE, SDL_GL_DEPTH_SIZE GetWMInfo function (stub) has been implemented by me, but not listed in device structure - fixed. SDL_ph_wm.c - fixed warning 'no return in non-void function'. README.QNX - Updating readme. Some spellcheck. ;-) --HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40292
This commit is contained in:
parent
f6aa684abc
commit
84075e735c
5 changed files with 158 additions and 138 deletions
24
README.QNX
24
README.QNX
|
@ -1,17 +1,17 @@
|
||||||
README by Mike Gorchak <mike@malva.com.ua>
|
README by Mike Gorchak <mike@malva.ua>
|
||||||
|
|
||||||
Experimentally added OpenGL support in window mode (in fullscreen
|
OpenGL support was experimentally added in window mode (in
|
||||||
mode not yet). If you have QNX RtP v6.1.0 w/ or w/o Patch A you need
|
fullscreen mode not yet). If you have QNX RtP v6.1.0 w/ or w/o
|
||||||
to download new Photon3D runtime from http://developers.qnx.com. The
|
Patch A you must download new Photon3D runtime from http://de-
|
||||||
versions of OS before 6.1.0 is not supported.
|
velopers.qnx.com. The versions of OS before 6.1.0 are not sup-
|
||||||
|
ported.
|
||||||
|
|
||||||
Problems:
|
Problems:
|
||||||
1. OpenGL support is very raw. It is often fail. Update function has
|
1. Fullscreen mode (in OpenGL mode) has not been written yet.
|
||||||
not been written yet. Fullscreen mode has not been written yet.
|
2. Photon has some errors in detecting how much bits per pi-
|
||||||
2. Photon has some errors in detecting how much bits per pixel has
|
xel videomode has.
|
||||||
videomode, creating images with different color depth.
|
3. No shared libraries yet. We need manually set flag to
|
||||||
3. No shared libraries yet. We need manually set flags as
|
'configure' --disable-shared.
|
||||||
--disable-shared.
|
|
||||||
|
|
||||||
Some building issues:
|
Some building issues:
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ Some building issues:
|
||||||
--disable-video-x11 \
|
--disable-video-x11 \
|
||||||
--disable-shared
|
--disable-shared
|
||||||
|
|
||||||
a) without OpenGL support:
|
b) without OpenGL support:
|
||||||
./configure --prefix=/usr/local \
|
./configure --prefix=/usr/local \
|
||||||
--disable-video-x11 \
|
--disable-video-x11 \
|
||||||
--disable-shared \
|
--disable-shared \
|
||||||
|
|
|
@ -33,12 +33,6 @@ static char rcsid =
|
||||||
#include "SDL_endian.h"
|
#include "SDL_endian.h"
|
||||||
#include "SDL_ph_image_c.h"
|
#include "SDL_ph_image_c.h"
|
||||||
|
|
||||||
//printf("%s:%s:%d\n", __FILE__, __PRETTY_FUNCTION__, __LINE__ );
|
|
||||||
|
|
||||||
/* Various screen update functions available */
|
|
||||||
//static void ph_NormalUpdate(_THIS, int numrects, SDL_Rect *rects);
|
|
||||||
//static void ph_DummyUpdate(_THIS, int numrects, SDL_Rect *rects);
|
|
||||||
|
|
||||||
int ph_SetupImage(_THIS, SDL_Surface *screen)
|
int ph_SetupImage(_THIS, SDL_Surface *screen)
|
||||||
{
|
{
|
||||||
int type = 0;
|
int type = 0;
|
||||||
|
@ -58,12 +52,10 @@ int ph_SetupImage(_THIS, SDL_Surface *screen)
|
||||||
type = Pg_IMAGE_DIRECT_565;
|
type = Pg_IMAGE_DIRECT_565;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 24:{
|
case 24:{
|
||||||
type = Pg_IMAGE_DIRECT_888;
|
type = Pg_IMAGE_DIRECT_888;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 32:{
|
case 32:{
|
||||||
type = Pg_IMAGE_DIRECT_8888;
|
type = Pg_IMAGE_DIRECT_8888;
|
||||||
}
|
}
|
||||||
|
@ -77,8 +69,8 @@ int ph_SetupImage(_THIS, SDL_Surface *screen)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//using shared memory for speed (set last param to 1)
|
/* using shared memory for speed (set last param to 1) */
|
||||||
if ((SDL_Image = PhCreateImage( NULL, screen->w, screen->h, type, NULL, 0, 1 )) == NULL)
|
if ((SDL_Image = PhCreateImage(NULL, screen->w, screen->h, type, NULL, 0, 1)) == NULL)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"error: PhCreateImage failed.\n");
|
fprintf(stderr,"error: PhCreateImage failed.\n");
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -172,14 +164,15 @@ int ph_SetupOCImage(_THIS, SDL_Surface *screen) //Offscreen context
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ph_SetupOpenGLImage(_THIS, SDL_Surface* screen)
|
||||||
|
{
|
||||||
|
this->UpdateRects = ph_OpenGLUpdate;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void ph_DestroyImage(_THIS, SDL_Surface *screen)
|
void ph_DestroyImage(_THIS, SDL_Surface *screen)
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
if(SDL_Image == NULL)
|
|
||||||
return;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (OCImage.offscreen_context != NULL)
|
if (OCImage.offscreen_context != NULL)
|
||||||
{
|
{
|
||||||
PhDCRelease(OCImage.offscreen_context);
|
PhDCRelease(OCImage.offscreen_context);
|
||||||
|
@ -192,16 +185,12 @@ void ph_DestroyImage(_THIS, SDL_Surface *screen)
|
||||||
|
|
||||||
if (SDL_Image)
|
if (SDL_Image)
|
||||||
{
|
{
|
||||||
// SDL_Image->flags=Ph_RELEASE_IMAGE;
|
PgShmemDestroy(SDL_Image->image);
|
||||||
// PhReleaseImage(SDL_Image);
|
|
||||||
if (SDL_Image->image)
|
|
||||||
PgShmemDestroy(SDL_Image->image); // Use this if you using shared memory, or uncomment
|
|
||||||
// lines above if not (and comment this line ;-)
|
|
||||||
free(SDL_Image);
|
free(SDL_Image);
|
||||||
SDL_Image = NULL;
|
SDL_Image = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( screen )
|
if (screen)
|
||||||
{
|
{
|
||||||
screen->pixels = NULL;
|
screen->pixels = NULL;
|
||||||
}
|
}
|
||||||
|
@ -213,12 +202,12 @@ int ph_ResizeImage(_THIS, SDL_Surface *screen, Uint32 flags)
|
||||||
|
|
||||||
if( flags & SDL_HWSURFACE)
|
if( flags & SDL_HWSURFACE)
|
||||||
{
|
{
|
||||||
OCImage.flags = flags; //needed for SDL_DOUBLEBUF check
|
OCImage.flags = flags; /* needed for SDL_DOUBLEBUF check */
|
||||||
return ph_SetupOCImage(this,screen);
|
return ph_SetupOCImage(this, screen);
|
||||||
}
|
}
|
||||||
else if(flags & SDL_OPENGL) /* No image when using GL */
|
else if(flags & SDL_OPENGL)
|
||||||
{
|
{
|
||||||
return 0;
|
return ph_SetupOpenGLImage(this, screen);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -260,6 +249,13 @@ static PhPoint_t ph_pos;
|
||||||
static PhRect_t ph_rect;
|
static PhRect_t ph_rect;
|
||||||
static int i;
|
static int i;
|
||||||
|
|
||||||
|
void ph_OpenGLUpdate(_THIS, int numrects, SDL_Rect* rects)
|
||||||
|
{
|
||||||
|
this->GL_SwapBuffers(this);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
void ph_NormalUpdate(_THIS, int numrects, SDL_Rect *rects)
|
void ph_NormalUpdate(_THIS, int numrects, SDL_Rect *rects)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -39,4 +39,4 @@ extern int ph_FlipHWSurface(_THIS, SDL_Surface *surface);
|
||||||
|
|
||||||
extern void ph_NormalUpdate(_THIS, int numrects, SDL_Rect *rects);
|
extern void ph_NormalUpdate(_THIS, int numrects, SDL_Rect *rects);
|
||||||
extern void ph_OCUpdate(_THIS, int numrects, SDL_Rect *rects);
|
extern void ph_OCUpdate(_THIS, int numrects, SDL_Rect *rects);
|
||||||
extern void ph_DummyUpdate(_THIS, int numrects, SDL_Rect *rects);
|
extern void ph_OpenGLUpdate(_THIS, int numrects, SDL_Rect *rects);
|
||||||
|
|
|
@ -56,7 +56,11 @@ 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);
|
||||||
|
|
||||||
|
#ifdef HAVE_OPENGL
|
||||||
static void ph_GL_SwapBuffers(_THIS);
|
static void ph_GL_SwapBuffers(_THIS);
|
||||||
|
static int ph_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value);
|
||||||
|
#endif /* HAVE_OPENGL */
|
||||||
|
|
||||||
#ifdef HAVE_OPENGL
|
#ifdef HAVE_OPENGL
|
||||||
PdOpenGLContext_t* OGLContext=NULL;
|
PdOpenGLContext_t* OGLContext=NULL;
|
||||||
|
@ -112,7 +116,7 @@ static SDL_VideoDevice *ph_CreateDevice(int devindex)
|
||||||
device->SetIcon = NULL;
|
device->SetIcon = NULL;
|
||||||
device->IconifyWindow = ph_IconifyWindow;
|
device->IconifyWindow = ph_IconifyWindow;
|
||||||
device->GrabInput = ph_GrabInput;
|
device->GrabInput = ph_GrabInput;
|
||||||
device->GetWMInfo = NULL;
|
device->GetWMInfo = ph_GetWMInfo;
|
||||||
device->FreeWMCursor = ph_FreeWMCursor;
|
device->FreeWMCursor = ph_FreeWMCursor;
|
||||||
device->CreateWMCursor = ph_CreateWMCursor;
|
device->CreateWMCursor = ph_CreateWMCursor;
|
||||||
device->ShowWMCursor = ph_ShowWMCursor;
|
device->ShowWMCursor = ph_ShowWMCursor;
|
||||||
|
@ -124,12 +128,13 @@ static SDL_VideoDevice *ph_CreateDevice(int devindex)
|
||||||
/* OpenGL support. */
|
/* OpenGL support. */
|
||||||
device->GL_LoadLibrary = NULL;
|
device->GL_LoadLibrary = NULL;
|
||||||
device->GL_GetProcAddress = NULL;
|
device->GL_GetProcAddress = NULL;
|
||||||
device->GL_GetAttribute = NULL;
|
|
||||||
device->GL_MakeCurrent = NULL;
|
device->GL_MakeCurrent = NULL;
|
||||||
#ifdef HAVE_OPENGL
|
#ifdef HAVE_OPENGL
|
||||||
device->GL_SwapBuffers = ph_GL_SwapBuffers;
|
device->GL_SwapBuffers = ph_GL_SwapBuffers;
|
||||||
|
device->GL_GetAttribute = ph_GL_GetAttribute;
|
||||||
#else
|
#else
|
||||||
device->GL_SwapBuffers = NULL;
|
device->GL_SwapBuffers = NULL;
|
||||||
|
device->GL_GetAttribute = NULL;
|
||||||
#endif /* HAVE_OPENGL */
|
#endif /* HAVE_OPENGL */
|
||||||
|
|
||||||
device->free = ph_DeleteDevice;
|
device->free = ph_DeleteDevice;
|
||||||
|
@ -271,10 +276,6 @@ 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)
|
||||||
{
|
{
|
||||||
PgDisplaySettings_t settings;
|
PgDisplaySettings_t settings;
|
||||||
/*
|
|
||||||
PgHWCaps_t my_hwcaps;
|
|
||||||
PgVideoModeInfo_t mode_info;
|
|
||||||
*/
|
|
||||||
int mode, actual_width, actual_height;
|
int mode, actual_width, actual_height;
|
||||||
PtArg_t arg[5];
|
PtArg_t arg[5];
|
||||||
PhDim_t dim;
|
PhDim_t dim;
|
||||||
|
@ -285,7 +286,8 @@ static SDL_Surface *ph_SetVideoMode(_THIS, SDL_Surface *current,
|
||||||
|
|
||||||
#ifdef HAVE_OPENGL
|
#ifdef HAVE_OPENGL
|
||||||
uint64_t OGLAttrib[PH_OGL_MAX_ATTRIBS];
|
uint64_t OGLAttrib[PH_OGL_MAX_ATTRIBS];
|
||||||
#endif // HAVE_OPENGL
|
int OGLargc;
|
||||||
|
#endif /* HAVE_OPENGL */
|
||||||
|
|
||||||
actual_width = width;
|
actual_width = width;
|
||||||
actual_height = height;
|
actual_height = height;
|
||||||
|
@ -315,8 +317,6 @@ static SDL_Surface *ph_SetVideoMode(_THIS, SDL_Surface *current,
|
||||||
fprintf(stderr,"error: get_mode failed\n");
|
fprintf(stderr,"error: get_mode failed\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
settings.mode = mode;
|
settings.mode = mode;
|
||||||
settings.refresh = 0;
|
settings.refresh = 0;
|
||||||
|
@ -332,10 +332,9 @@ static SDL_Surface *ph_SetVideoMode(_THIS, SDL_Surface *current,
|
||||||
current->flags = (flags & (~SDL_RESIZABLE)); /* no resize for Direct Context */
|
current->flags = (flags & (~SDL_RESIZABLE)); /* no resize for Direct Context */
|
||||||
|
|
||||||
/* Begin direct mode */
|
/* Begin direct mode */
|
||||||
|
|
||||||
ph_EnterFullScreen(this);
|
ph_EnterFullScreen(this);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} /* end fullscreen flag */
|
} /* end fullscreen flag */
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -352,17 +351,40 @@ static SDL_Surface *ph_SetVideoMode(_THIS, SDL_Surface *current,
|
||||||
#ifdef HAVE_OPENGL
|
#ifdef HAVE_OPENGL
|
||||||
if (flags & SDL_OPENGL) /* for now support OpenGL in window mode only */
|
if (flags & SDL_OPENGL) /* for now support OpenGL in window mode only */
|
||||||
{
|
{
|
||||||
OGLAttrib[0]=PHOGL_ATTRIB_DEPTH_BITS;
|
OGLargc=0;
|
||||||
OGLAttrib[1]=bpp;
|
if (this->gl_config.depth_size)
|
||||||
OGLAttrib[2]=PHOGL_ATTRIB_NONE;
|
{
|
||||||
|
OGLAttrib[OGLargc++]=PHOGL_ATTRIB_DEPTH_BITS;
|
||||||
|
OGLAttrib[OGLargc++]=this->gl_config.depth_size;
|
||||||
|
}
|
||||||
|
if (this->gl_config.stencil_size)
|
||||||
|
{
|
||||||
|
OGLAttrib[OGLargc++]=PHOGL_ATTRIB_STENCIL_BITS;
|
||||||
|
OGLAttrib[OGLargc++]=this->gl_config.stencil_size;
|
||||||
|
}
|
||||||
|
OGLAttrib[OGLargc++]=PHOGL_ATTRIB_NONE;
|
||||||
|
if (this->gl_config.double_buffer)
|
||||||
|
{
|
||||||
OGLContext=PdCreateOpenGLContext(2, &dim, 0, OGLAttrib);
|
OGLContext=PdCreateOpenGLContext(2, &dim, 0, OGLAttrib);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OGLContext=PdCreateOpenGLContext(1, &dim, 0, OGLAttrib);
|
||||||
|
}
|
||||||
if (OGLContext==NULL)
|
if (OGLContext==NULL)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"error: cannot create OpenGL context\n");
|
fprintf(stderr,"error: cannot create OpenGL context.\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
PhDCSetCurrent(OGLContext);
|
PhDCSetCurrent(OGLContext);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
if (flags & SDL_OPENGL) /* if no OpenGL support */
|
||||||
|
{
|
||||||
|
fprintf(stderr, "error: no OpenGL support, try to recompile library.\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* HAVE_OPENGL */
|
#endif /* HAVE_OPENGL */
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -491,25 +513,25 @@ void ph_GL_SwapBuffers(_THIS)
|
||||||
PgSetRegion(PtWidgetRid(window));
|
PgSetRegion(PtWidgetRid(window));
|
||||||
PdOpenGLContextSwapBuffers(OGLContext);
|
PdOpenGLContextSwapBuffers(OGLContext);
|
||||||
}
|
}
|
||||||
#endif // HAVE_OPENGL
|
|
||||||
|
|
||||||
/*
|
int ph_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value)
|
||||||
static int ph_ResizeWindow(_THIS,
|
|
||||||
SDL_Surface *screen, int w, int h, Uint32 flags)
|
|
||||||
{
|
{
|
||||||
PhWindowEvent_t winevent;
|
switch (attrib)
|
||||||
|
|
||||||
memset( &winevent, 0, sizeof(winevent) );
|
|
||||||
winevent.event_f = Ph_WM_RESIZE;
|
|
||||||
winevent.size.w = w;
|
|
||||||
winevent.size.h = h;
|
|
||||||
winevent.rid = PtWidgetRid( window );
|
|
||||||
if (PtForwardWindowEvent( &winevent ) < 0)
|
|
||||||
{
|
{
|
||||||
fprintf(stderr,"error: PtForwardWindowEvent failed.\n");
|
case SDL_GL_DOUBLEBUFFER:
|
||||||
|
*value=this->gl_config.double_buffer;
|
||||||
|
break;
|
||||||
|
case SDL_GL_STENCIL_SIZE:
|
||||||
|
*value=this->gl_config.stencil_size;
|
||||||
|
break;
|
||||||
|
case SDL_GL_DEPTH_SIZE:
|
||||||
|
*value=this->gl_config.depth_size;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
*value=0;
|
||||||
|
return(-1);
|
||||||
}
|
}
|
||||||
current_w = w;
|
return 0;
|
||||||
current_h = h;
|
|
||||||
return(0);
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
#endif /* HAVE_OPENGL */
|
||||||
|
|
|
@ -242,6 +242,8 @@ int ph_IconifyWindow(_THIS)
|
||||||
windowevent.rid = PtWidgetRid( window );
|
windowevent.rid = PtWidgetRid( window );
|
||||||
PtForwardWindowEvent( &windowevent );
|
PtForwardWindowEvent( &windowevent );
|
||||||
SDL_Unlock_EventThread();
|
SDL_Unlock_EventThread();
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_GrabMode ph_GrabInputNoLock(_THIS, SDL_GrabMode mode)
|
SDL_GrabMode ph_GrabInputNoLock(_THIS, SDL_GrabMode mode)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue