Date: Sat, 30 Aug 2003 16:28:10 +0300
authorSam Lantinga <slouken@libsdl.org>
Sat, 30 Aug 2003 17:07:59 +0000
changeset 701 aaf3b8af6616
parent 700 c35edafc84d1
child 702 61b7f5eed0e8
Date: Sat, 30 Aug 2003 16:28:10 +0300 From: "Mike Gorchak" Subject: Re: SDL 1.2.6 - minor changes about shared library building under QNX6 into README.QNX - added forgotten libSDLmain.a into distribution, SDL.qpg.in - added header guards to the all headers. - fixed fullscreen double buffered mode. - fixed Photon crashes after/during using fullscreen OpenGL modes. - added GL_MakeCurrent function. - added SDL_VIDEOEXPOSE event, when OpenGL window have been resized - added more HAVE_OPENGL checks to avoid dead code compilation without using OpenGL - finished code reorganization (began into previous patches).
README.QNX
SDL.qpg.in
src/video/photon/SDL_ph_events_c.h
src/video/photon/SDL_ph_image.c
src/video/photon/SDL_ph_image_c.h
src/video/photon/SDL_ph_modes_c.h
src/video/photon/SDL_ph_mouse.c
src/video/photon/SDL_ph_mouse_c.h
src/video/photon/SDL_ph_video.c
src/video/photon/SDL_ph_video.h
src/video/photon/SDL_ph_wm_c.h
src/video/photon/SDL_phyuv_c.h
--- a/README.QNX	Sat Aug 30 09:09:09 2003 +0000
+++ b/README.QNX	Sat Aug 30 17:07:59 2003 +0000
@@ -77,7 +77,8 @@
 script you must manually delete the libtool.m4 stuff from the acinclu-
 de.m4 file (it comes after the ESD detection code up to the end of the
 file), because the libtool stuff in the acinclude.m4 file is very  old
-and doesn't know anything about QNX. Just remove it and run autogen.sh.
+and  doesn't  know  anything  about  QNX. Just   remove  it, then  run
+"libtoolize --force --copy" and after that run autogen.sh.
 
 ======================================================================
 Some building issues:
--- a/SDL.qpg.in	Sat Aug 30 09:09:09 2003 +0000
+++ b/SDL.qpg.in	Sat Aug 30 17:07:59 2003 +0000
@@ -30,6 +30,7 @@
          <QPG:Add filetype="symlink" file="libSDL-1.0.so.0" install="/opt/lib/" linkto="libSDL-1.2.so.0"/>
          <QPG:Add permissions="0644" file="./src/.libs/libSDL.a" install="/opt/lib/"/>
          <QPG:Add permissions="0644" file="./src/.libs/libSDL.lai" install="/opt/lib/libSDL.la"/>
+         <QPG:Add permissions="0644" file="./src/main/libSDLmain.a" install="/opt/lib/"/>
          <QPG:Add permissions="0644" file="./include/*.h" install="/opt/include/SDL/"/>
          <QPG:Add permissions="0755" file="./sdl-config" install="/opt/bin/"/>
          <QPG:Add permissions="0644" file="./BUGS" install="/usr/doc/SDL12/"/>
--- a/src/video/photon/SDL_ph_events_c.h	Sat Aug 30 09:09:09 2003 +0000
+++ b/src/video/photon/SDL_ph_events_c.h	Sat Aug 30 17:07:59 2003 +0000
@@ -20,10 +20,13 @@
     slouken@libsdl.org
 */
 
+#ifndef __SDL_PH_EVENTS_H__
+#define __SDL_PH_EVENTS_H__
+
 #ifdef SAVE_RCSID
 static char rcsid =
  "@(#) $Id$";
-#endif
+#endif /* SAVE_RCSID */
 
 #include "SDL_ph_video.h"
 
@@ -32,3 +35,5 @@
 /* Functions to be exported */
 extern void ph_InitOSKeymap(_THIS);
 extern void ph_PumpEvents(_THIS);
+
+#endif /* __SDL_PH_EVENTS_H__ */
--- a/src/video/photon/SDL_ph_image.c	Sat Aug 30 09:09:09 2003 +0000
+++ b/src/video/photon/SDL_ph_image.c	Sat Aug 30 17:07:59 2003 +0000
@@ -186,13 +186,6 @@
     return 0;
 }
 
-int ph_SetupOpenGLImage(_THIS, SDL_Surface* screen)
-{
-   this->UpdateRects = ph_OpenGLUpdate;
-   
-   return 0;
-}
-
 int ph_SetupFullScreenImage(_THIS, SDL_Surface* screen)
 {
     OCImage.flags = screen->flags;
@@ -210,7 +203,7 @@
         PgGetPalette(syspalph);
     }
 
-    OCImage.offscreen_context = PdCreateOffscreenContext(0, 0, 0, Pg_OSC_MAIN_DISPLAY);
+    OCImage.offscreen_context = PdCreateOffscreenContext(0, 0, 0, Pg_OSC_MAIN_DISPLAY | Pg_OSC_MEM_PAGE_ALIGN | Pg_OSC_CRTC_SAFE);
     if (OCImage.offscreen_context == NULL)
     {
         SDL_SetError("ph_SetupFullScreenImage(): PdCreateOffscreenContext() function failed !\n");
@@ -219,7 +212,7 @@
     
     if ((screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF)
     {
-        OCImage.offscreen_backcontext = PdDupOffscreenContext(OCImage.offscreen_context, Pg_OSC_CRTC_SAFE);
+        OCImage.offscreen_backcontext = PdDupOffscreenContext(OCImage.offscreen_context, Pg_OSC_CRTC_SAFE | Pg_OSC_MEM_PAGE_ALIGN);
         if (OCImage.offscreen_backcontext == NULL)
         {
             SDL_SetError("ph_SetupFullScreenImage(): PdCreateOffscreenContext(back) function failed !\n");
@@ -272,8 +265,122 @@
     return 0;
 }
 
-void ph_DestroyImage(_THIS, SDL_Surface *screen)
+#ifdef HAVE_OPENGL
+
+static int ph_SetupOpenGLContext(_THIS, int width, int height, int bpp, Uint32 flags)
 {
+    PhDim_t dim;
+    uint64_t OGLAttrib[PH_OGL_MAX_ATTRIBS];
+    int exposepost=0;
+    int OGLargc;
+
+    dim.w=width;
+    dim.h=height;
+    
+    if ((oglctx!=NULL) && (oglflags==flags) && (oglbpp==bpp))
+    {
+       PdOpenGLContextResize(oglctx, &dim);
+       PhDCSetCurrent(oglctx);
+       return 0;
+    }
+    else
+    {
+       if (oglctx!=NULL)
+       {
+          PhDCSetCurrent(NULL);
+          PhDCRelease(oglctx);
+          oglctx=NULL;
+          exposepost=1;
+       }
+    }
+
+    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_FORCE_SW;
+    if (flags & SDL_FULLSCREEN)
+    {
+        OGLAttrib[OGLargc++]=PHOGL_ATTRIB_FULLSCREEN;
+        OGLAttrib[OGLargc++]=PHOGL_ATTRIB_DIRECT;
+        OGLAttrib[OGLargc++]=PHOGL_ATTRIB_FULLSCREEN_BEST;
+        OGLAttrib[OGLargc++]=PHOGL_ATTRIB_FULLSCREEN_CENTER;
+    }
+    OGLAttrib[OGLargc++]=PHOGL_ATTRIB_NONE;
+
+    if (this->gl_config.double_buffer)
+    {
+        oglctx=PdCreateOpenGLContext(2, &dim, 0, OGLAttrib);
+    }
+    else
+    {
+        oglctx=PdCreateOpenGLContext(1, &dim, 0, OGLAttrib);
+    }
+
+    if (oglctx==NULL)
+    {
+        SDL_SetError("ph_SetupOpenGLContext(): cannot create OpenGL context !\n");
+        return (-1);
+    }
+
+    PhDCSetCurrent(oglctx);
+
+    PtFlush();
+
+    oglflags=flags;
+    oglbpp=bpp;
+
+    if (exposepost!=0)
+    {
+        /* OpenGL context has been recreated, so report about this fact */
+        SDL_PrivateExpose();
+    }
+
+    return 0;
+}
+
+int ph_SetupOpenGLImage(_THIS, SDL_Surface* screen)
+{
+   this->UpdateRects = ph_OpenGLUpdate;
+   screen->pixels=NULL;
+   screen->pitch=NULL;
+
+   if (ph_SetupOpenGLContext(this, screen->w, screen->h, screen->format->BitsPerPixel, screen->flags)!=0)
+   {
+      screen->flags &= ~SDL_OPENGL;
+      return -1;
+   }
+   
+   return 0;
+}
+
+#endif /* HAVE_OPENGL */
+
+void ph_DestroyImage(_THIS, SDL_Surface* screen)
+{
+
+#ifdef HAVE_OPENGL
+    if ((screen->flags & SDL_OPENGL)==SDL_OPENGL)
+    {
+        if (oglctx)
+        {
+            PhDCSetCurrent(NULL);
+            PhDCRelease(oglctx);
+            oglctx=NULL;
+            oglflags=0;
+            oglbpp=0;
+        }
+        return;
+    }
+#endif /* HAVE_OPENGL */
+
     if (currently_fullscreen)
     {
         /* if we right now in 8bpp fullscreen we must release palette */
@@ -320,10 +427,16 @@
     }
 }
 
-int ph_SetupUpdateFunction(_THIS, SDL_Surface *screen, Uint32 flags)
+int ph_SetupUpdateFunction(_THIS, SDL_Surface* screen, Uint32 flags)
 {
     ph_DestroyImage(this, screen);
     
+#ifdef HAVE_OPENGL
+    if ((flags & SDL_OPENGL)==SDL_OPENGL)
+    {
+        return ph_SetupOpenGLImage(this, screen);
+    }
+#endif /* HAVE_OPENGL */
     if ((flags & SDL_FULLSCREEN)==SDL_FULLSCREEN)
     {
         return ph_SetupFullScreenImage(this, screen);
@@ -332,43 +445,31 @@
     {
         return ph_SetupOCImage(this, screen);
     }
-    if ((flags & SDL_OPENGL)==SDL_OPENGL)
-    {
-        return ph_SetupOpenGLImage(this, screen);
-    } 
 
     return ph_SetupImage(this, screen);
 }
 
-int ph_AllocHWSurface(_THIS, SDL_Surface *surface)
+int ph_AllocHWSurface(_THIS, SDL_Surface* surface)
 {
     return(-1);
 }
 
-void ph_FreeHWSurface(_THIS, SDL_Surface *surface)
+void ph_FreeHWSurface(_THIS, SDL_Surface* surface)
 {
     return;
 }
 
-int ph_FlipHWSurface(_THIS, SDL_Surface *screen)
+int ph_FlipHWSurface(_THIS, SDL_Surface* screen)
 {
-    PhArea_t area;
-
-    area.pos.x=0;
-    area.pos.y=0;
-    area.size.w=screen->w;
-    area.size.h=screen->h;
-
     if ((screen->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN)
     {
+        PgWaitHWIdle();
         if (OCImage.current==0)
         {
             PgSwapDisplay(OCImage.offscreen_context, 0);
             OCImage.current=1;
             screen->pitch = OCImage.offscreen_backcontext->pitch;
             screen->pixels = OCImage.FrameData1;
-//            memcpy(OCImage.FrameData1, OCImage.FrameData0, OCImage.offscreen_context->shared_size);
-            PgContextBlitArea(OCImage.offscreen_context, &area, OCImage.offscreen_backcontext, &area);
             PhDCSetCurrent(OCImage.offscreen_backcontext);
             PgFlush();
         }
@@ -378,8 +479,6 @@
             OCImage.current=0;
             screen->pitch = OCImage.offscreen_context->pitch;
             screen->pixels = OCImage.FrameData0;
-//            memcpy(OCImage.FrameData0, OCImage.FrameData1, OCImage.offscreen_context->shared_size);
-            PgContextBlitArea(OCImage.offscreen_backcontext, &area, OCImage.offscreen_context, &area);
             PhDCSetCurrent(OCImage.offscreen_context);
             PgFlush();
         }
@@ -397,12 +496,14 @@
     return;
 }
 
+#ifdef HAVE_OPENGL
 void ph_OpenGLUpdate(_THIS, int numrects, SDL_Rect* rects)
 {
    this->GL_SwapBuffers(this);
    
    return;
 }
+#endif /* HAVE_OPENGL */
 
 void ph_NormalUpdate(_THIS, int numrects, SDL_Rect *rects)
 {
--- a/src/video/photon/SDL_ph_image_c.h	Sat Aug 30 09:09:09 2003 +0000
+++ b/src/video/photon/SDL_ph_image_c.h	Sat Aug 30 17:07:59 2003 +0000
@@ -20,16 +20,20 @@
     slouken@libsdl.org
 */
 
+#ifndef __SDL_PH_IMAGE_H__
+#define __SDL_PH_IMAGE_H__
+
 #ifdef SAVE_RCSID
 static char rcsid =
  "@(#) $Id$";
-#endif
+#endif /* SAVE_RCSID */
 
+#include "SDL_events_c.h"
 #include "SDL_ph_video.h"
 
-extern int ph_SetupImage(_THIS, SDL_Surface *screen);
-extern void ph_DestroyImage(_THIS, SDL_Surface *screen);
-extern int ph_SetupUpdateFunction(_THIS, SDL_Surface *screen, Uint32 flags);
+extern int ph_SetupImage(_THIS, SDL_Surface* screen);
+extern void ph_DestroyImage(_THIS, SDL_Surface* screen);
+extern int ph_SetupUpdateFunction(_THIS, SDL_Surface* screen, Uint32 flags);
 
 extern int ph_AllocHWSurface(_THIS, SDL_Surface *surface);
 extern void ph_FreeHWSurface(_THIS, SDL_Surface *surface);
@@ -41,3 +45,5 @@
 extern void ph_OCUpdate(_THIS, int numrects, SDL_Rect *rects);
 extern void ph_OCDCUpdate(_THIS, int numrects, SDL_Rect *rects);
 extern void ph_OpenGLUpdate(_THIS, int numrects, SDL_Rect *rects);
+
+#endif /* __SDL_PH_IMAGE_H__ */
--- a/src/video/photon/SDL_ph_modes_c.h	Sat Aug 30 09:09:09 2003 +0000
+++ b/src/video/photon/SDL_ph_modes_c.h	Sat Aug 30 17:07:59 2003 +0000
@@ -20,14 +20,13 @@
     slouken@libsdl.org
 */
 
+#ifndef __SDL_PH_MODES_H__
+#define __SDL_PH_MODES_H__
+
 #ifdef SAVE_RCSID
 static char rcsid =
  "@(#) $Id$";
-#endif
-
-
-#ifndef _PH_MODES_INCLUDED_
-#define _PH_MODES_INCLUDED_
+#endif /* SAVE_RCSID */
 
 #include "SDL_ph_video.h"
 
@@ -42,4 +41,4 @@
 extern int get_mode_any_format(int width, int height, int bpp);
 extern int ph_ToggleFullScreen(_THIS, int on);
 
-#endif /* _PH_MODES_INCLUDED_ */
+#endif /* __SDL_PH_MODES_H__ */
--- a/src/video/photon/SDL_ph_mouse.c	Sat Aug 30 09:09:09 2003 +0000
+++ b/src/video/photon/SDL_ph_mouse.c	Sat Aug 30 17:07:59 2003 +0000
@@ -120,10 +120,10 @@
 
 PhCursorDef_t ph_GetWMPhCursor(WMcursor *cursor)
 {
-    return(*cursor->ph_cursor);
+    return (*cursor->ph_cursor);
 }
 
-int ph_ShowWMCursor(_THIS, WMcursor *cursor)
+int ph_ShowWMCursor(_THIS, WMcursor* cursor)
 {
     PtArg_t args[3];
     int nargs = 0;
@@ -137,7 +137,15 @@
     /* looks like photon can't draw mouse cursor in direct mode */
     if ((this->screen->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN)
     {
-        return (0);
+         /* disable the fake mouse in the fullscreen OpenGL mode */
+         if ((this->screen->flags & SDL_OPENGL) == SDL_OPENGL)
+         {
+             cursor=NULL;
+         }
+         else
+         {
+             return (0);
+         }
     }
 
     /* Set the photon cursor, or blank if cursor is NULL */
@@ -167,6 +175,7 @@
     return (1);
 }
 
+
 void ph_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
 {
     short abs_x, abs_y;
@@ -190,3 +199,31 @@
         mouse_relative = 0;
     }
 }
+
+
+void ph_UpdateMouse(_THIS)
+{
+    PhCursorInfo_t phcursor;
+    short abs_x;
+    short abs_y;
+
+    /* Lock the event thread, in multi-threading environments */
+    SDL_Lock_EventThread();
+
+    /* synchronizing photon mouse cursor position and SDL mouse position, if cursor appears over window. */
+    PtGetAbsPosition(window, &abs_x, &abs_y);
+    PhQueryCursor(PhInputGroup(NULL), &phcursor);
+    if (((phcursor.pos.x >= abs_x) && (phcursor.pos.x <= abs_x + this->screen->w)) &&
+        ((phcursor.pos.y >= abs_y) && (phcursor.pos.y <= abs_y + this->screen->h)))
+    {
+        SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
+        SDL_PrivateMouseMotion(0, 0, phcursor.pos.x-abs_x, phcursor.pos.y-abs_y);
+    }
+    else
+    {
+        SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
+    }
+
+    /* Unlock the event thread, in multi-threading environments */
+    SDL_Unlock_EventThread();
+}
--- a/src/video/photon/SDL_ph_mouse_c.h	Sat Aug 30 09:09:09 2003 +0000
+++ b/src/video/photon/SDL_ph_mouse_c.h	Sat Aug 30 17:07:59 2003 +0000
@@ -20,10 +20,13 @@
     slouken@libsdl.org
 */
 
+#ifndef __SDL_PH_MOUSE_H__
+#define __SDL_PH_MOUSE_H__
+
 #ifdef SAVE_RCSID
 static char rcsid =
  "@(#) $Id$";
-#endif
+#endif /* SAVE_RCSID */
 
 #include "SDL_ph_video.h"
 
@@ -35,3 +38,6 @@
 extern int ph_ShowWMCursor(_THIS, WMcursor *cursor);
 extern void ph_WarpWMCursor(_THIS, Uint16 x, Uint16 y);
 extern void ph_CheckMouseMode(_THIS);
+extern void ph_UpdateMouse(_THIS);
+
+#endif /* __SDL_PH_MOUSE_H__ */
--- a/src/video/photon/SDL_ph_video.c	Sat Aug 30 09:09:09 2003 +0000
+++ b/src/video/photon/SDL_ph_video.c	Sat Aug 30 17:07:59 2003 +0000
@@ -50,21 +50,18 @@
 #include "SDL_phyuv_c.h"
 #include "blank_cursor.h"
 
-static int ph_VideoInit(_THIS, SDL_PixelFormat *vformat);
-static SDL_Surface *ph_SetVideoMode(_THIS, SDL_Surface *current,
-                int width, int height, int bpp, Uint32 flags);
-static int ph_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors);
+static int  ph_VideoInit(_THIS, SDL_PixelFormat *vformat);
+static SDL_Surface *ph_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);
+static int  ph_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors);
 static void ph_VideoQuit(_THIS);
 static void ph_DeleteDevice(SDL_VideoDevice *device);
-static void ph_UpdateMouse(_THIS);
 
 #ifdef HAVE_OPENGL
-static int ph_SetupOpenGLContext(_THIS, int width, int height, int bpp, Uint32 flags);
-static void ph_GL_SwapBuffers(_THIS);
-static int ph_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value);
-static int ph_GL_LoadLibrary(_THIS, const char* path);
+static void  ph_GL_SwapBuffers(_THIS);
+static int   ph_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value);
+static int   ph_GL_LoadLibrary(_THIS, const char* path);
 static void* ph_GL_GetProcAddress(_THIS, const char* proc);
-
+static int   ph_GL_MakeCurrent(_THIS);
 #endif /* HAVE_OPENGL */
 
 static int ph_Available(void)
@@ -132,18 +129,20 @@
     device->CreateWMCursor = ph_CreateWMCursor;
     device->ShowWMCursor = ph_ShowWMCursor;
     device->WarpWMCursor = ph_WarpWMCursor;
+    device->MoveWMCursor = NULL;
     device->CheckMouseMode = ph_CheckMouseMode;
     device->InitOSKeymap = ph_InitOSKeymap;
     device->PumpEvents = ph_PumpEvents;
 
     /* OpenGL support. */
-    device->GL_MakeCurrent = NULL;
 #ifdef HAVE_OPENGL
+    device->GL_MakeCurrent = ph_GL_MakeCurrent;
     device->GL_SwapBuffers = ph_GL_SwapBuffers;
     device->GL_GetAttribute = ph_GL_GetAttribute;
     device->GL_LoadLibrary = ph_GL_LoadLibrary;
     device->GL_GetProcAddress = ph_GL_GetProcAddress;
 #else
+    device->GL_MakeCurrent = NULL;
     device->GL_SwapBuffers = NULL;
     device->GL_GetAttribute = NULL;
     device->GL_LoadLibrary = NULL;
@@ -313,8 +312,11 @@
 
     window=NULL;
     desktoppal=SDLPH_PAL_NONE;
+
 #ifdef HAVE_OPENGL
     oglctx=NULL;
+    oglflags=0;
+    oglbpp=0;
 #endif /* HAVE_OPENGL */
     
     old_video_mode=-1;
@@ -428,21 +430,10 @@
     }
 
 #ifdef HAVE_OPENGL
-    if (current->flags & SDL_OPENGL)
+    if ((current->flags & SDL_OPENGL)==SDL_OPENGL)
     {
-        /* ph_SetupOpenGLContext creates also window as need */
-        if (ph_SetupOpenGLContext(this, width, height, bpp, flags)==0)
-        {
-            ph_SetupUpdateFunction(this, current, flags); 
-        }
-        else
-        {
-            /* if context creation fail, report no OpenGL to high level */
-            current->flags &= ~SDL_OPENGL;
-            return NULL;
-        }
 #else
-    if (current->flags & SDL_OPENGL) /* if no built-in OpenGL support */
+    if ((current->flags & SDL_OPENGL)==SDL_OPENGL) /* if no built-in OpenGL support */
     {
         SDL_SetError("ph_SetVideoMode(): no OpenGL support, try to recompile library.\n");
         current->flags &= ~SDL_OPENGL;
@@ -528,10 +519,6 @@
 
 static void ph_VideoQuit(_THIS)
 {
-#ifdef HAVE_OPENGL
-    PhRegion_t region_info;
-#endif /* HAVE_OPENGL */
-
     /* restore palette */
     if (desktopbpp==8)
     {
@@ -542,22 +529,6 @@
 
     ph_DestroyImage(this, SDL_VideoSurface); 
 
-#ifdef HAVE_OPENGL
-    /* prevent double SEGFAULT during parachute mode */
-    if (this->screen)
-    {
-        if (((this->screen->flags & SDL_FULLSCREEN)==SDL_FULLSCREEN) &&
-            ((this->screen->flags & SDL_OPENGL)==SDL_OPENGL))
-        {
-            region_info.cursor_type=Ph_CURSOR_POINTER;
-            region_info.rid=PtWidgetRid(window);
-            PhRegionChange(Ph_REGION_CURSOR, 0, &region_info, NULL, NULL);
-        }
-    }
-
-    PtFlush();
-#endif /* HAVE_OPENGL */
-    
     if (window)
     {
         PtUnrealizeWidget(window);
@@ -565,15 +536,6 @@
         window=NULL;
     }
 
-#ifdef HAVE_OPENGL
-    if (oglctx)
-    {
-        PhDCSetCurrent(NULL);
-        PhDCRelease(oglctx);
-        oglctx=NULL;
-    }
-#endif /* HAVE_OPENGL */
-
     if (event!=NULL)
     {
         free(event);
@@ -638,82 +600,13 @@
 
 #ifdef HAVE_OPENGL
 
-int ph_SetupOpenGLContext(_THIS, int width, int height, int bpp, Uint32 flags)
-{
-    PhDim_t dim;
-    uint64_t OGLAttrib[PH_OGL_MAX_ATTRIBS];
-    int OGLargc;
-
-    dim.w=width;
-    dim.h=height;
-    
-    if (oglctx!=NULL)
-    {
-       PhDCSetCurrent(NULL);
-       PhDCRelease(oglctx);
-       oglctx=NULL;
-    }
-
-    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_FORCE_SW;
-    if (flags & SDL_FULLSCREEN)
-    {
-        OGLAttrib[OGLargc++]=PHOGL_ATTRIB_FULLSCREEN;
-        OGLAttrib[OGLargc++]=PHOGL_ATTRIB_DIRECT;
-        OGLAttrib[OGLargc++]=PHOGL_ATTRIB_FULLSCREEN_BEST;
-        OGLAttrib[OGLargc++]=PHOGL_ATTRIB_FULLSCREEN_CENTER;
-    }
-    OGLAttrib[OGLargc++]=PHOGL_ATTRIB_NONE;
-
-    if (this->gl_config.double_buffer)
-    {
-        oglctx=PdCreateOpenGLContext(2, &dim, 0, OGLAttrib);
-    }
-    else
-    {
-        oglctx=PdCreateOpenGLContext(1, &dim, 0, OGLAttrib);
-    }
-
-    if (oglctx==NULL)
-    {
-        SDL_SetError("ph_SetupOpenGLContext(): cannot create OpenGL context !\n");
-        return (-1);
-    }
-
-    PhDCSetCurrent(oglctx);
-
-    /* disable mouse for fullscreen */
-    if (flags & SDL_FULLSCREEN)
-    {
-        PhRegion_t region_info;
-
-        region_info.cursor_type=Ph_CURSOR_NONE;
-        region_info.rid=PtWidgetRid(window);
-        PhRegionChange(Ph_REGION_CURSOR, 0, &region_info, NULL, NULL);
-    }
-
-    PtFlush();
-
-    return 0;
-}
-
-void ph_GL_SwapBuffers(_THIS)
+static void ph_GL_SwapBuffers(_THIS)
 {
     PgSetRegion(PtWidgetRid(window));
     PdOpenGLContextSwapBuffers(oglctx);
 }
 
-int ph_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value)
+static int ph_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value)
 {
     switch (attrib)
     {
@@ -733,44 +626,29 @@
     return 0;
 }
 
-int ph_GL_LoadLibrary(_THIS, const char* path)
+static int ph_GL_LoadLibrary(_THIS, const char* path)
 {
-   /* if code compiled with HAVE_OPENGL, the library already linked */
+   /* if code compiled with HAVE_OPENGL, that mean that library already linked */
    this->gl_config.driver_loaded = 1;
 
    return 0;
 }
 
-void* ph_GL_GetProcAddress(_THIS, const char* proc)
+static void* ph_GL_GetProcAddress(_THIS, const char* proc)
 {
    return NULL;
 }
 
-#endif /* HAVE_OPENGL */
-
-static void ph_UpdateMouse(_THIS)
+static int ph_GL_MakeCurrent(_THIS)
 {
-    PhCursorInfo_t phcursor;
-    short abs_x;
-    short abs_y;
-
-    /* Lock the event thread, in multi-threading environments */
-    SDL_Lock_EventThread();
+    PgSetRegion(PtWidgetRid(window));
 
-    /* synchronizing photon mouse cursor position and SDL mouse position, if cursor appears over window. */
-    PtGetAbsPosition(window, &abs_x, &abs_y);
-    PhQueryCursor(PhInputGroup(NULL), &phcursor);
-    if (((phcursor.pos.x >= abs_x) && (phcursor.pos.x <= abs_x + this->screen->w)) &&
-        ((phcursor.pos.y >= abs_y) && (phcursor.pos.y <= abs_y + this->screen->h)))
+    if (oglctx!=NULL)
     {
-        SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
-        SDL_PrivateMouseMotion(0, 0, phcursor.pos.x-abs_x, phcursor.pos.y-abs_y);
-    }
-    else
-    {
-        SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
+        PhDCSetCurrent(oglctx);
     }
 
-    /* Unlock the event thread, in multi-threading environments */
-    SDL_Unlock_EventThread();
+    return 0;
 }
+
+#endif /* HAVE_OPENGL */
--- a/src/video/photon/SDL_ph_video.h	Sat Aug 30 09:09:09 2003 +0000
+++ b/src/video/photon/SDL_ph_video.h	Sat Aug 30 17:07:59 2003 +0000
@@ -46,9 +46,9 @@
 
 typedef struct
 {
-	unsigned char* Y;
-	unsigned char* V;
-	unsigned char* U;
+    unsigned char* Y;
+    unsigned char* V;
+    unsigned char* U;
 } FRAMEDATA;
 
 /* Mask values for SDL_ReallocFormat() */
@@ -68,6 +68,8 @@
     PhImage_t *image;	                 /* used to display image       */
 #ifdef HAVE_OPENGL
     PdOpenGLContext_t* OGLContext;       /* OpenGL context              */
+    Uint32 OGLFlags;                     /* OpenGL flags                */
+    Uint32 OGLBPP;                       /* OpenGL bpp                  */
 #endif /* HAVE_OPENGL */
     PgColor_t savedpal[_Pg_MAX_PALETTE];
     PgColor_t syspalph[_Pg_MAX_PALETTE];
@@ -82,8 +84,8 @@
         unsigned char*        CurrentFrameData;
         unsigned char*        FrameData0;
         unsigned char*        FrameData1;
-        int                   current;
-        long                  flags;
+        Uint32                current;
+        Uint32                flags;
     } ocimage;
 
     PgHWCaps_t graphics_card_caps;  /* Graphics card caps at the moment of start   */
@@ -94,9 +96,9 @@
     int mouse_relative;
     WMcursor* BlankCursor;
 
-    int depth;			/* current visual depth (not bpp)           */
-    int desktopbpp;             /* bpp of desktop at the moment of start    */
-    int desktoppal;             /* palette mode emulation or system         */
+    Uint32 depth;	            /* current visual depth (not bpp)           */
+    Uint32 desktopbpp;              /* bpp of desktop at the moment of start    */
+    Uint32 desktoppal;              /* palette mode emulation or system         */
 
     int currently_fullscreen;
     int currently_hided;        /* 1 - window hided (minimazed), 0 - normal */
@@ -107,7 +109,6 @@
 
 #define mode_settings        (this->hidden->mode_settings)
 #define window	             (this->hidden->Window)
-#define oglctx               (this->hidden->OGLContext)
 #define SDL_Image            (this->hidden->image)
 #define OCImage              (this->hidden->ocimage)
 #define old_video_mode       (this->hidden->old_video_mode)
@@ -122,9 +123,13 @@
 #define event                (this->hidden->event)
 #define current_overlay      (this->hidden->overlay)
 #define desktop_mode         (this->hidden->desktop_mode)
-
-/* Old variable names */
 #define mouse_relative       (this->hidden->mouse_relative)
 #define SDL_BlankCursor      (this->hidden->BlankCursor)
 
+#ifdef HAVE_OPENGL
+     #define oglctx               (this->hidden->OGLContext)
+     #define oglflags             (this->hidden->OGLFlags)
+     #define oglbpp               (this->hidden->OGLBPP)
+#endif /* HAVE_OPENGL */
+
 #endif /* __SDL_PH_VIDEO_H__ */
--- a/src/video/photon/SDL_ph_wm_c.h	Sat Aug 30 09:09:09 2003 +0000
+++ b/src/video/photon/SDL_ph_wm_c.h	Sat Aug 30 17:07:59 2003 +0000
@@ -20,10 +20,13 @@
     slouken@libsdl.org
 */
 
+#ifndef __SDL_PH_WM_H__
+#define __SDL_PH_WM_H__
+
 #ifdef SAVE_RCSID
 static char rcsid =
  "@(#) $Id$";
-#endif
+#endif /* SAVE_RCSID */
 
 #include "SDL_ph_video.h"
 
@@ -35,3 +38,4 @@
 extern SDL_GrabMode ph_GrabInput(_THIS, SDL_GrabMode mode);
 extern int ph_GetWMInfo(_THIS, SDL_SysWMinfo *info);
 
+#endif /* __SDL_PH_WM_H__ */
--- a/src/video/photon/SDL_phyuv_c.h	Sat Aug 30 09:09:09 2003 +0000
+++ b/src/video/photon/SDL_phyuv_c.h	Sat Aug 30 17:07:59 2003 +0000
@@ -20,10 +20,14 @@
     slouken@libsdl.org
 */
 
+
+#ifndef __SDL_PH_YUV_H__
+#define __SDL_PH_YUV_H__
+
 #ifdef SAVE_RCSID
 static char rcsid =
  "@(#) $Id$";
-#endif
+#endif /* SAVE_RCSID */
 
 /* This is the photon implementation of YUV video overlays */
 
@@ -59,3 +63,5 @@
 extern void ph_UnlockYUVOverlay(_THIS, SDL_Overlay* overlay);
 extern int ph_DisplayYUVOverlay(_THIS, SDL_Overlay* overlay, SDL_Rect* dstrect);
 extern void ph_FreeYUVOverlay(_THIS, SDL_Overlay* overlay);
+
+#endif /* __SDL_PH_YUV_H__ */