Commit 84075e73 authored by Sam Lantinga's avatar Sam Lantinga

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
parent f6aa684a
README by Mike Gorchak <mike@malva.com.ua>
README by Mike Gorchak <mike@malva.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 was experimentally added in window mode (in
fullscreen mode not yet). If you have QNX RtP v6.1.0 w/ or w/o
Patch A you must download new Photon3D runtime from http://de-
velopers.qnx.com. The versions of OS before 6.1.0 are not sup-
ported.
Problems:
1. OpenGL support is very raw. It is often fail. Update function has
not been written yet. Fullscreen mode has not been written yet.
2. Photon has some errors in detecting how much bits per pixel has
videomode, creating images with different color depth.
3. No shared libraries yet. We need manually set flags as
--disable-shared.
1. Fullscreen mode (in OpenGL mode) has not been written yet.
2. Photon has some errors in detecting how much bits per pi-
xel videomode has.
3. No shared libraries yet. We need manually set flag to
'configure' --disable-shared.
Some building issues:
......@@ -22,7 +22,7 @@ Some building issues:
--disable-video-x11 \
--disable-shared
a) without OpenGL support:
b) without OpenGL support:
./configure --prefix=/usr/local \
--disable-video-x11 \
--disable-shared \
......
......@@ -33,12 +33,6 @@ static char rcsid =
#include "SDL_endian.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 type = 0;
......@@ -58,12 +52,10 @@ int ph_SetupImage(_THIS, SDL_Surface *screen)
type = Pg_IMAGE_DIRECT_565;
}
break;
case 24:{
type = Pg_IMAGE_DIRECT_888;
}
break;
case 32:{
type = Pg_IMAGE_DIRECT_8888;
}
......@@ -77,8 +69,8 @@ int ph_SetupImage(_THIS, SDL_Surface *screen)
break;
}
//using shared memory for speed (set last param to 1)
if ((SDL_Image = PhCreateImage( NULL, screen->w, screen->h, type, NULL, 0, 1 )) == NULL)
/* using shared memory for speed (set last param to 1) */
if ((SDL_Image = PhCreateImage(NULL, screen->w, screen->h, type, NULL, 0, 1)) == NULL)
{
fprintf(stderr,"error: PhCreateImage failed.\n");
return -1;
......@@ -172,14 +164,15 @@ int ph_SetupOCImage(_THIS, SDL_Surface *screen) //Offscreen context
return 0;
}
int ph_SetupOpenGLImage(_THIS, SDL_Surface* screen)
{
this->UpdateRects = ph_OpenGLUpdate;
return 0;
}
void ph_DestroyImage(_THIS, SDL_Surface *screen)
{
#if 0
if(SDL_Image == NULL)
return;
#endif
if (OCImage.offscreen_context != NULL)
{
PhDCRelease(OCImage.offscreen_context);
......@@ -192,16 +185,12 @@ void ph_DestroyImage(_THIS, SDL_Surface *screen)
if (SDL_Image)
{
// SDL_Image->flags=Ph_RELEASE_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 ;-)
PgShmemDestroy(SDL_Image->image);
free(SDL_Image);
SDL_Image = NULL;
}
if ( screen )
if (screen)
{
screen->pixels = NULL;
}
......@@ -213,12 +202,12 @@ int ph_ResizeImage(_THIS, SDL_Surface *screen, Uint32 flags)
if( flags & SDL_HWSURFACE)
{
OCImage.flags = flags; //needed for SDL_DOUBLEBUF check
return ph_SetupOCImage(this,screen);
OCImage.flags = flags; /* needed for SDL_DOUBLEBUF check */
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
{
......@@ -260,6 +249,13 @@ static PhPoint_t ph_pos;
static PhRect_t ph_rect;
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)
{
......
......@@ -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_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 void ph_VideoQuit(_THIS);
static void ph_DeleteDevice(SDL_VideoDevice *device);
#ifdef HAVE_OPENGL
static void ph_GL_SwapBuffers(_THIS);
static int ph_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value);
#endif /* HAVE_OPENGL */
#ifdef HAVE_OPENGL
PdOpenGLContext_t* OGLContext=NULL;
......@@ -112,7 +116,7 @@ static SDL_VideoDevice *ph_CreateDevice(int devindex)
device->SetIcon = NULL;
device->IconifyWindow = ph_IconifyWindow;
device->GrabInput = ph_GrabInput;
device->GetWMInfo = NULL;
device->GetWMInfo = ph_GetWMInfo;
device->FreeWMCursor = ph_FreeWMCursor;
device->CreateWMCursor = ph_CreateWMCursor;
device->ShowWMCursor = ph_ShowWMCursor;
......@@ -124,12 +128,13 @@ static SDL_VideoDevice *ph_CreateDevice(int devindex)
/* OpenGL support. */
device->GL_LoadLibrary = NULL;
device->GL_GetProcAddress = NULL;
device->GL_GetAttribute = NULL;
device->GL_MakeCurrent = NULL;
#ifdef HAVE_OPENGL
device->GL_SwapBuffers = ph_GL_SwapBuffers;
device->GL_GetAttribute = ph_GL_GetAttribute;
#else
device->GL_SwapBuffers = NULL;
device->GL_GetAttribute = NULL;
#endif /* HAVE_OPENGL */
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)
{
PgDisplaySettings_t settings;
/*
PgHWCaps_t my_hwcaps;
PgVideoModeInfo_t mode_info;
*/
int mode, actual_width, actual_height;
PtArg_t arg[5];
PhDim_t dim;
......@@ -285,7 +286,8 @@ static SDL_Surface *ph_SetVideoMode(_THIS, SDL_Surface *current,
#ifdef HAVE_OPENGL
uint64_t OGLAttrib[PH_OGL_MAX_ATTRIBS];
#endif // HAVE_OPENGL
int OGLargc;
#endif /* HAVE_OPENGL */
actual_width = width;
actual_height = height;
......@@ -315,8 +317,6 @@ static SDL_Surface *ph_SetVideoMode(_THIS, SDL_Surface *current,
fprintf(stderr,"error: get_mode failed\n");
exit(1);
}
}
settings.mode = mode;
settings.refresh = 0;
......@@ -332,9 +332,8 @@ static SDL_Surface *ph_SetVideoMode(_THIS, SDL_Surface *current,
current->flags = (flags & (~SDL_RESIZABLE)); /* no resize for Direct Context */
/* Begin direct mode */
ph_EnterFullScreen(this);
ph_EnterFullScreen(this);
} /* end fullscreen flag */
else
......@@ -352,17 +351,40 @@ static SDL_Surface *ph_SetVideoMode(_THIS, SDL_Surface *current,
#ifdef HAVE_OPENGL
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;
OGLargc=0;
if (this->gl_config.depth_size)
{
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);
}
else
{
OGLContext=PdCreateOpenGLContext(1, &dim, 0, OGLAttrib);
}
if (OGLContext==NULL)
{
fprintf(stderr,"error: cannot create OpenGL context\n");
fprintf(stderr,"error: cannot create OpenGL context.\n");
exit(1);
}
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 */
}
......@@ -491,25 +513,25 @@ void ph_GL_SwapBuffers(_THIS)
PgSetRegion(PtWidgetRid(window));
PdOpenGLContextSwapBuffers(OGLContext);
}
#endif // HAVE_OPENGL
/*
static int ph_ResizeWindow(_THIS,
SDL_Surface *screen, int w, int h, Uint32 flags)
int ph_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value)
{
PhWindowEvent_t winevent;
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)
switch (attrib)
{
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;
current_h = h;
return(0);
return 0;
}
*/
#endif /* HAVE_OPENGL */
......@@ -242,6 +242,8 @@ int ph_IconifyWindow(_THIS)
windowevent.rid = PtWidgetRid( window );
PtForwardWindowEvent( &windowevent );
SDL_Unlock_EventThread();
return 0;
}
SDL_GrabMode ph_GrabInputNoLock(_THIS, SDL_GrabMode mode)
......
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