Date: Sat, 30 Aug 2003 16:28:10 +0300
authorSam Lantinga <slouken@libsdl.org>
Sat, 30 Aug 2003 17:07:59 +0000
changeset 701aaf3b8af6616
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
     1.1 --- a/README.QNX	Sat Aug 30 09:09:09 2003 +0000
     1.2 +++ b/README.QNX	Sat Aug 30 17:07:59 2003 +0000
     1.3 @@ -77,7 +77,8 @@
     1.4  script you must manually delete the libtool.m4 stuff from the acinclu-
     1.5  de.m4 file (it comes after the ESD detection code up to the end of the
     1.6  file), because the libtool stuff in the acinclude.m4 file is very  old
     1.7 -and doesn't know anything about QNX. Just remove it and run autogen.sh.
     1.8 +and  doesn't  know  anything  about  QNX. Just   remove  it, then  run
     1.9 +"libtoolize --force --copy" and after that run autogen.sh.
    1.10  
    1.11  ======================================================================
    1.12  Some building issues:
     2.1 --- a/SDL.qpg.in	Sat Aug 30 09:09:09 2003 +0000
     2.2 +++ b/SDL.qpg.in	Sat Aug 30 17:07:59 2003 +0000
     2.3 @@ -30,6 +30,7 @@
     2.4           <QPG:Add filetype="symlink" file="libSDL-1.0.so.0" install="/opt/lib/" linkto="libSDL-1.2.so.0"/>
     2.5           <QPG:Add permissions="0644" file="./src/.libs/libSDL.a" install="/opt/lib/"/>
     2.6           <QPG:Add permissions="0644" file="./src/.libs/libSDL.lai" install="/opt/lib/libSDL.la"/>
     2.7 +         <QPG:Add permissions="0644" file="./src/main/libSDLmain.a" install="/opt/lib/"/>
     2.8           <QPG:Add permissions="0644" file="./include/*.h" install="/opt/include/SDL/"/>
     2.9           <QPG:Add permissions="0755" file="./sdl-config" install="/opt/bin/"/>
    2.10           <QPG:Add permissions="0644" file="./BUGS" install="/usr/doc/SDL12/"/>
     3.1 --- a/src/video/photon/SDL_ph_events_c.h	Sat Aug 30 09:09:09 2003 +0000
     3.2 +++ b/src/video/photon/SDL_ph_events_c.h	Sat Aug 30 17:07:59 2003 +0000
     3.3 @@ -20,10 +20,13 @@
     3.4      slouken@libsdl.org
     3.5  */
     3.6  
     3.7 +#ifndef __SDL_PH_EVENTS_H__
     3.8 +#define __SDL_PH_EVENTS_H__
     3.9 +
    3.10  #ifdef SAVE_RCSID
    3.11  static char rcsid =
    3.12   "@(#) $Id$";
    3.13 -#endif
    3.14 +#endif /* SAVE_RCSID */
    3.15  
    3.16  #include "SDL_ph_video.h"
    3.17  
    3.18 @@ -32,3 +35,5 @@
    3.19  /* Functions to be exported */
    3.20  extern void ph_InitOSKeymap(_THIS);
    3.21  extern void ph_PumpEvents(_THIS);
    3.22 +
    3.23 +#endif /* __SDL_PH_EVENTS_H__ */
     4.1 --- a/src/video/photon/SDL_ph_image.c	Sat Aug 30 09:09:09 2003 +0000
     4.2 +++ b/src/video/photon/SDL_ph_image.c	Sat Aug 30 17:07:59 2003 +0000
     4.3 @@ -186,13 +186,6 @@
     4.4      return 0;
     4.5  }
     4.6  
     4.7 -int ph_SetupOpenGLImage(_THIS, SDL_Surface* screen)
     4.8 -{
     4.9 -   this->UpdateRects = ph_OpenGLUpdate;
    4.10 -   
    4.11 -   return 0;
    4.12 -}
    4.13 -
    4.14  int ph_SetupFullScreenImage(_THIS, SDL_Surface* screen)
    4.15  {
    4.16      OCImage.flags = screen->flags;
    4.17 @@ -210,7 +203,7 @@
    4.18          PgGetPalette(syspalph);
    4.19      }
    4.20  
    4.21 -    OCImage.offscreen_context = PdCreateOffscreenContext(0, 0, 0, Pg_OSC_MAIN_DISPLAY);
    4.22 +    OCImage.offscreen_context = PdCreateOffscreenContext(0, 0, 0, Pg_OSC_MAIN_DISPLAY | Pg_OSC_MEM_PAGE_ALIGN | Pg_OSC_CRTC_SAFE);
    4.23      if (OCImage.offscreen_context == NULL)
    4.24      {
    4.25          SDL_SetError("ph_SetupFullScreenImage(): PdCreateOffscreenContext() function failed !\n");
    4.26 @@ -219,7 +212,7 @@
    4.27      
    4.28      if ((screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF)
    4.29      {
    4.30 -        OCImage.offscreen_backcontext = PdDupOffscreenContext(OCImage.offscreen_context, Pg_OSC_CRTC_SAFE);
    4.31 +        OCImage.offscreen_backcontext = PdDupOffscreenContext(OCImage.offscreen_context, Pg_OSC_CRTC_SAFE | Pg_OSC_MEM_PAGE_ALIGN);
    4.32          if (OCImage.offscreen_backcontext == NULL)
    4.33          {
    4.34              SDL_SetError("ph_SetupFullScreenImage(): PdCreateOffscreenContext(back) function failed !\n");
    4.35 @@ -272,8 +265,122 @@
    4.36      return 0;
    4.37  }
    4.38  
    4.39 -void ph_DestroyImage(_THIS, SDL_Surface *screen)
    4.40 +#ifdef HAVE_OPENGL
    4.41 +
    4.42 +static int ph_SetupOpenGLContext(_THIS, int width, int height, int bpp, Uint32 flags)
    4.43  {
    4.44 +    PhDim_t dim;
    4.45 +    uint64_t OGLAttrib[PH_OGL_MAX_ATTRIBS];
    4.46 +    int exposepost=0;
    4.47 +    int OGLargc;
    4.48 +
    4.49 +    dim.w=width;
    4.50 +    dim.h=height;
    4.51 +    
    4.52 +    if ((oglctx!=NULL) && (oglflags==flags) && (oglbpp==bpp))
    4.53 +    {
    4.54 +       PdOpenGLContextResize(oglctx, &dim);
    4.55 +       PhDCSetCurrent(oglctx);
    4.56 +       return 0;
    4.57 +    }
    4.58 +    else
    4.59 +    {
    4.60 +       if (oglctx!=NULL)
    4.61 +       {
    4.62 +          PhDCSetCurrent(NULL);
    4.63 +          PhDCRelease(oglctx);
    4.64 +          oglctx=NULL;
    4.65 +          exposepost=1;
    4.66 +       }
    4.67 +    }
    4.68 +
    4.69 +    OGLargc=0;
    4.70 +    if (this->gl_config.depth_size)
    4.71 +    {
    4.72 +        OGLAttrib[OGLargc++]=PHOGL_ATTRIB_DEPTH_BITS;
    4.73 +        OGLAttrib[OGLargc++]=this->gl_config.depth_size;
    4.74 +    }
    4.75 +    if (this->gl_config.stencil_size)
    4.76 +    {
    4.77 +        OGLAttrib[OGLargc++]=PHOGL_ATTRIB_STENCIL_BITS;
    4.78 +        OGLAttrib[OGLargc++]=this->gl_config.stencil_size;
    4.79 +    }
    4.80 +    OGLAttrib[OGLargc++]=PHOGL_ATTRIB_FORCE_SW;
    4.81 +    if (flags & SDL_FULLSCREEN)
    4.82 +    {
    4.83 +        OGLAttrib[OGLargc++]=PHOGL_ATTRIB_FULLSCREEN;
    4.84 +        OGLAttrib[OGLargc++]=PHOGL_ATTRIB_DIRECT;
    4.85 +        OGLAttrib[OGLargc++]=PHOGL_ATTRIB_FULLSCREEN_BEST;
    4.86 +        OGLAttrib[OGLargc++]=PHOGL_ATTRIB_FULLSCREEN_CENTER;
    4.87 +    }
    4.88 +    OGLAttrib[OGLargc++]=PHOGL_ATTRIB_NONE;
    4.89 +
    4.90 +    if (this->gl_config.double_buffer)
    4.91 +    {
    4.92 +        oglctx=PdCreateOpenGLContext(2, &dim, 0, OGLAttrib);
    4.93 +    }
    4.94 +    else
    4.95 +    {
    4.96 +        oglctx=PdCreateOpenGLContext(1, &dim, 0, OGLAttrib);
    4.97 +    }
    4.98 +
    4.99 +    if (oglctx==NULL)
   4.100 +    {
   4.101 +        SDL_SetError("ph_SetupOpenGLContext(): cannot create OpenGL context !\n");
   4.102 +        return (-1);
   4.103 +    }
   4.104 +
   4.105 +    PhDCSetCurrent(oglctx);
   4.106 +
   4.107 +    PtFlush();
   4.108 +
   4.109 +    oglflags=flags;
   4.110 +    oglbpp=bpp;
   4.111 +
   4.112 +    if (exposepost!=0)
   4.113 +    {
   4.114 +        /* OpenGL context has been recreated, so report about this fact */
   4.115 +        SDL_PrivateExpose();
   4.116 +    }
   4.117 +
   4.118 +    return 0;
   4.119 +}
   4.120 +
   4.121 +int ph_SetupOpenGLImage(_THIS, SDL_Surface* screen)
   4.122 +{
   4.123 +   this->UpdateRects = ph_OpenGLUpdate;
   4.124 +   screen->pixels=NULL;
   4.125 +   screen->pitch=NULL;
   4.126 +
   4.127 +   if (ph_SetupOpenGLContext(this, screen->w, screen->h, screen->format->BitsPerPixel, screen->flags)!=0)
   4.128 +   {
   4.129 +      screen->flags &= ~SDL_OPENGL;
   4.130 +      return -1;
   4.131 +   }
   4.132 +   
   4.133 +   return 0;
   4.134 +}
   4.135 +
   4.136 +#endif /* HAVE_OPENGL */
   4.137 +
   4.138 +void ph_DestroyImage(_THIS, SDL_Surface* screen)
   4.139 +{
   4.140 +
   4.141 +#ifdef HAVE_OPENGL
   4.142 +    if ((screen->flags & SDL_OPENGL)==SDL_OPENGL)
   4.143 +    {
   4.144 +        if (oglctx)
   4.145 +        {
   4.146 +            PhDCSetCurrent(NULL);
   4.147 +            PhDCRelease(oglctx);
   4.148 +            oglctx=NULL;
   4.149 +            oglflags=0;
   4.150 +            oglbpp=0;
   4.151 +        }
   4.152 +        return;
   4.153 +    }
   4.154 +#endif /* HAVE_OPENGL */
   4.155 +
   4.156      if (currently_fullscreen)
   4.157      {
   4.158          /* if we right now in 8bpp fullscreen we must release palette */
   4.159 @@ -320,10 +427,16 @@
   4.160      }
   4.161  }
   4.162  
   4.163 -int ph_SetupUpdateFunction(_THIS, SDL_Surface *screen, Uint32 flags)
   4.164 +int ph_SetupUpdateFunction(_THIS, SDL_Surface* screen, Uint32 flags)
   4.165  {
   4.166      ph_DestroyImage(this, screen);
   4.167      
   4.168 +#ifdef HAVE_OPENGL
   4.169 +    if ((flags & SDL_OPENGL)==SDL_OPENGL)
   4.170 +    {
   4.171 +        return ph_SetupOpenGLImage(this, screen);
   4.172 +    }
   4.173 +#endif /* HAVE_OPENGL */
   4.174      if ((flags & SDL_FULLSCREEN)==SDL_FULLSCREEN)
   4.175      {
   4.176          return ph_SetupFullScreenImage(this, screen);
   4.177 @@ -332,43 +445,31 @@
   4.178      {
   4.179          return ph_SetupOCImage(this, screen);
   4.180      }
   4.181 -    if ((flags & SDL_OPENGL)==SDL_OPENGL)
   4.182 -    {
   4.183 -        return ph_SetupOpenGLImage(this, screen);
   4.184 -    } 
   4.185  
   4.186      return ph_SetupImage(this, screen);
   4.187  }
   4.188  
   4.189 -int ph_AllocHWSurface(_THIS, SDL_Surface *surface)
   4.190 +int ph_AllocHWSurface(_THIS, SDL_Surface* surface)
   4.191  {
   4.192      return(-1);
   4.193  }
   4.194  
   4.195 -void ph_FreeHWSurface(_THIS, SDL_Surface *surface)
   4.196 +void ph_FreeHWSurface(_THIS, SDL_Surface* surface)
   4.197  {
   4.198      return;
   4.199  }
   4.200  
   4.201 -int ph_FlipHWSurface(_THIS, SDL_Surface *screen)
   4.202 +int ph_FlipHWSurface(_THIS, SDL_Surface* screen)
   4.203  {
   4.204 -    PhArea_t area;
   4.205 -
   4.206 -    area.pos.x=0;
   4.207 -    area.pos.y=0;
   4.208 -    area.size.w=screen->w;
   4.209 -    area.size.h=screen->h;
   4.210 -
   4.211      if ((screen->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN)
   4.212      {
   4.213 +        PgWaitHWIdle();
   4.214          if (OCImage.current==0)
   4.215          {
   4.216              PgSwapDisplay(OCImage.offscreen_context, 0);
   4.217              OCImage.current=1;
   4.218              screen->pitch = OCImage.offscreen_backcontext->pitch;
   4.219              screen->pixels = OCImage.FrameData1;
   4.220 -//            memcpy(OCImage.FrameData1, OCImage.FrameData0, OCImage.offscreen_context->shared_size);
   4.221 -            PgContextBlitArea(OCImage.offscreen_context, &area, OCImage.offscreen_backcontext, &area);
   4.222              PhDCSetCurrent(OCImage.offscreen_backcontext);
   4.223              PgFlush();
   4.224          }
   4.225 @@ -378,8 +479,6 @@
   4.226              OCImage.current=0;
   4.227              screen->pitch = OCImage.offscreen_context->pitch;
   4.228              screen->pixels = OCImage.FrameData0;
   4.229 -//            memcpy(OCImage.FrameData0, OCImage.FrameData1, OCImage.offscreen_context->shared_size);
   4.230 -            PgContextBlitArea(OCImage.offscreen_backcontext, &area, OCImage.offscreen_context, &area);
   4.231              PhDCSetCurrent(OCImage.offscreen_context);
   4.232              PgFlush();
   4.233          }
   4.234 @@ -397,12 +496,14 @@
   4.235      return;
   4.236  }
   4.237  
   4.238 +#ifdef HAVE_OPENGL
   4.239  void ph_OpenGLUpdate(_THIS, int numrects, SDL_Rect* rects)
   4.240  {
   4.241     this->GL_SwapBuffers(this);
   4.242     
   4.243     return;
   4.244  }
   4.245 +#endif /* HAVE_OPENGL */
   4.246  
   4.247  void ph_NormalUpdate(_THIS, int numrects, SDL_Rect *rects)
   4.248  {
     5.1 --- a/src/video/photon/SDL_ph_image_c.h	Sat Aug 30 09:09:09 2003 +0000
     5.2 +++ b/src/video/photon/SDL_ph_image_c.h	Sat Aug 30 17:07:59 2003 +0000
     5.3 @@ -20,16 +20,20 @@
     5.4      slouken@libsdl.org
     5.5  */
     5.6  
     5.7 +#ifndef __SDL_PH_IMAGE_H__
     5.8 +#define __SDL_PH_IMAGE_H__
     5.9 +
    5.10  #ifdef SAVE_RCSID
    5.11  static char rcsid =
    5.12   "@(#) $Id$";
    5.13 -#endif
    5.14 +#endif /* SAVE_RCSID */
    5.15  
    5.16 +#include "SDL_events_c.h"
    5.17  #include "SDL_ph_video.h"
    5.18  
    5.19 -extern int ph_SetupImage(_THIS, SDL_Surface *screen);
    5.20 -extern void ph_DestroyImage(_THIS, SDL_Surface *screen);
    5.21 -extern int ph_SetupUpdateFunction(_THIS, SDL_Surface *screen, Uint32 flags);
    5.22 +extern int ph_SetupImage(_THIS, SDL_Surface* screen);
    5.23 +extern void ph_DestroyImage(_THIS, SDL_Surface* screen);
    5.24 +extern int ph_SetupUpdateFunction(_THIS, SDL_Surface* screen, Uint32 flags);
    5.25  
    5.26  extern int ph_AllocHWSurface(_THIS, SDL_Surface *surface);
    5.27  extern void ph_FreeHWSurface(_THIS, SDL_Surface *surface);
    5.28 @@ -41,3 +45,5 @@
    5.29  extern void ph_OCUpdate(_THIS, int numrects, SDL_Rect *rects);
    5.30  extern void ph_OCDCUpdate(_THIS, int numrects, SDL_Rect *rects);
    5.31  extern void ph_OpenGLUpdate(_THIS, int numrects, SDL_Rect *rects);
    5.32 +
    5.33 +#endif /* __SDL_PH_IMAGE_H__ */
     6.1 --- a/src/video/photon/SDL_ph_modes_c.h	Sat Aug 30 09:09:09 2003 +0000
     6.2 +++ b/src/video/photon/SDL_ph_modes_c.h	Sat Aug 30 17:07:59 2003 +0000
     6.3 @@ -20,14 +20,13 @@
     6.4      slouken@libsdl.org
     6.5  */
     6.6  
     6.7 +#ifndef __SDL_PH_MODES_H__
     6.8 +#define __SDL_PH_MODES_H__
     6.9 +
    6.10  #ifdef SAVE_RCSID
    6.11  static char rcsid =
    6.12   "@(#) $Id$";
    6.13 -#endif
    6.14 -
    6.15 -
    6.16 -#ifndef _PH_MODES_INCLUDED_
    6.17 -#define _PH_MODES_INCLUDED_
    6.18 +#endif /* SAVE_RCSID */
    6.19  
    6.20  #include "SDL_ph_video.h"
    6.21  
    6.22 @@ -42,4 +41,4 @@
    6.23  extern int get_mode_any_format(int width, int height, int bpp);
    6.24  extern int ph_ToggleFullScreen(_THIS, int on);
    6.25  
    6.26 -#endif /* _PH_MODES_INCLUDED_ */
    6.27 +#endif /* __SDL_PH_MODES_H__ */
     7.1 --- a/src/video/photon/SDL_ph_mouse.c	Sat Aug 30 09:09:09 2003 +0000
     7.2 +++ b/src/video/photon/SDL_ph_mouse.c	Sat Aug 30 17:07:59 2003 +0000
     7.3 @@ -120,10 +120,10 @@
     7.4  
     7.5  PhCursorDef_t ph_GetWMPhCursor(WMcursor *cursor)
     7.6  {
     7.7 -    return(*cursor->ph_cursor);
     7.8 +    return (*cursor->ph_cursor);
     7.9  }
    7.10  
    7.11 -int ph_ShowWMCursor(_THIS, WMcursor *cursor)
    7.12 +int ph_ShowWMCursor(_THIS, WMcursor* cursor)
    7.13  {
    7.14      PtArg_t args[3];
    7.15      int nargs = 0;
    7.16 @@ -137,7 +137,15 @@
    7.17      /* looks like photon can't draw mouse cursor in direct mode */
    7.18      if ((this->screen->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN)
    7.19      {
    7.20 -        return (0);
    7.21 +         /* disable the fake mouse in the fullscreen OpenGL mode */
    7.22 +         if ((this->screen->flags & SDL_OPENGL) == SDL_OPENGL)
    7.23 +         {
    7.24 +             cursor=NULL;
    7.25 +         }
    7.26 +         else
    7.27 +         {
    7.28 +             return (0);
    7.29 +         }
    7.30      }
    7.31  
    7.32      /* Set the photon cursor, or blank if cursor is NULL */
    7.33 @@ -167,6 +175,7 @@
    7.34      return (1);
    7.35  }
    7.36  
    7.37 +
    7.38  void ph_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
    7.39  {
    7.40      short abs_x, abs_y;
    7.41 @@ -190,3 +199,31 @@
    7.42          mouse_relative = 0;
    7.43      }
    7.44  }
    7.45 +
    7.46 +
    7.47 +void ph_UpdateMouse(_THIS)
    7.48 +{
    7.49 +    PhCursorInfo_t phcursor;
    7.50 +    short abs_x;
    7.51 +    short abs_y;
    7.52 +
    7.53 +    /* Lock the event thread, in multi-threading environments */
    7.54 +    SDL_Lock_EventThread();
    7.55 +
    7.56 +    /* synchronizing photon mouse cursor position and SDL mouse position, if cursor appears over window. */
    7.57 +    PtGetAbsPosition(window, &abs_x, &abs_y);
    7.58 +    PhQueryCursor(PhInputGroup(NULL), &phcursor);
    7.59 +    if (((phcursor.pos.x >= abs_x) && (phcursor.pos.x <= abs_x + this->screen->w)) &&
    7.60 +        ((phcursor.pos.y >= abs_y) && (phcursor.pos.y <= abs_y + this->screen->h)))
    7.61 +    {
    7.62 +        SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
    7.63 +        SDL_PrivateMouseMotion(0, 0, phcursor.pos.x-abs_x, phcursor.pos.y-abs_y);
    7.64 +    }
    7.65 +    else
    7.66 +    {
    7.67 +        SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
    7.68 +    }
    7.69 +
    7.70 +    /* Unlock the event thread, in multi-threading environments */
    7.71 +    SDL_Unlock_EventThread();
    7.72 +}
     8.1 --- a/src/video/photon/SDL_ph_mouse_c.h	Sat Aug 30 09:09:09 2003 +0000
     8.2 +++ b/src/video/photon/SDL_ph_mouse_c.h	Sat Aug 30 17:07:59 2003 +0000
     8.3 @@ -20,10 +20,13 @@
     8.4      slouken@libsdl.org
     8.5  */
     8.6  
     8.7 +#ifndef __SDL_PH_MOUSE_H__
     8.8 +#define __SDL_PH_MOUSE_H__
     8.9 +
    8.10  #ifdef SAVE_RCSID
    8.11  static char rcsid =
    8.12   "@(#) $Id$";
    8.13 -#endif
    8.14 +#endif /* SAVE_RCSID */
    8.15  
    8.16  #include "SDL_ph_video.h"
    8.17  
    8.18 @@ -35,3 +38,6 @@
    8.19  extern int ph_ShowWMCursor(_THIS, WMcursor *cursor);
    8.20  extern void ph_WarpWMCursor(_THIS, Uint16 x, Uint16 y);
    8.21  extern void ph_CheckMouseMode(_THIS);
    8.22 +extern void ph_UpdateMouse(_THIS);
    8.23 +
    8.24 +#endif /* __SDL_PH_MOUSE_H__ */
     9.1 --- a/src/video/photon/SDL_ph_video.c	Sat Aug 30 09:09:09 2003 +0000
     9.2 +++ b/src/video/photon/SDL_ph_video.c	Sat Aug 30 17:07:59 2003 +0000
     9.3 @@ -50,21 +50,18 @@
     9.4  #include "SDL_phyuv_c.h"
     9.5  #include "blank_cursor.h"
     9.6  
     9.7 -static int ph_VideoInit(_THIS, SDL_PixelFormat *vformat);
     9.8 -static SDL_Surface *ph_SetVideoMode(_THIS, SDL_Surface *current,
     9.9 -                int width, int height, int bpp, Uint32 flags);
    9.10 -static int ph_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors);
    9.11 +static int  ph_VideoInit(_THIS, SDL_PixelFormat *vformat);
    9.12 +static SDL_Surface *ph_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);
    9.13 +static int  ph_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors);
    9.14  static void ph_VideoQuit(_THIS);
    9.15  static void ph_DeleteDevice(SDL_VideoDevice *device);
    9.16 -static void ph_UpdateMouse(_THIS);
    9.17  
    9.18  #ifdef HAVE_OPENGL
    9.19 -static int ph_SetupOpenGLContext(_THIS, int width, int height, int bpp, Uint32 flags);
    9.20 -static void ph_GL_SwapBuffers(_THIS);
    9.21 -static int ph_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value);
    9.22 -static int ph_GL_LoadLibrary(_THIS, const char* path);
    9.23 +static void  ph_GL_SwapBuffers(_THIS);
    9.24 +static int   ph_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value);
    9.25 +static int   ph_GL_LoadLibrary(_THIS, const char* path);
    9.26  static void* ph_GL_GetProcAddress(_THIS, const char* proc);
    9.27 -
    9.28 +static int   ph_GL_MakeCurrent(_THIS);
    9.29  #endif /* HAVE_OPENGL */
    9.30  
    9.31  static int ph_Available(void)
    9.32 @@ -132,18 +129,20 @@
    9.33      device->CreateWMCursor = ph_CreateWMCursor;
    9.34      device->ShowWMCursor = ph_ShowWMCursor;
    9.35      device->WarpWMCursor = ph_WarpWMCursor;
    9.36 +    device->MoveWMCursor = NULL;
    9.37      device->CheckMouseMode = ph_CheckMouseMode;
    9.38      device->InitOSKeymap = ph_InitOSKeymap;
    9.39      device->PumpEvents = ph_PumpEvents;
    9.40  
    9.41      /* OpenGL support. */
    9.42 -    device->GL_MakeCurrent = NULL;
    9.43  #ifdef HAVE_OPENGL
    9.44 +    device->GL_MakeCurrent = ph_GL_MakeCurrent;
    9.45      device->GL_SwapBuffers = ph_GL_SwapBuffers;
    9.46      device->GL_GetAttribute = ph_GL_GetAttribute;
    9.47      device->GL_LoadLibrary = ph_GL_LoadLibrary;
    9.48      device->GL_GetProcAddress = ph_GL_GetProcAddress;
    9.49  #else
    9.50 +    device->GL_MakeCurrent = NULL;
    9.51      device->GL_SwapBuffers = NULL;
    9.52      device->GL_GetAttribute = NULL;
    9.53      device->GL_LoadLibrary = NULL;
    9.54 @@ -313,8 +312,11 @@
    9.55  
    9.56      window=NULL;
    9.57      desktoppal=SDLPH_PAL_NONE;
    9.58 +
    9.59  #ifdef HAVE_OPENGL
    9.60      oglctx=NULL;
    9.61 +    oglflags=0;
    9.62 +    oglbpp=0;
    9.63  #endif /* HAVE_OPENGL */
    9.64      
    9.65      old_video_mode=-1;
    9.66 @@ -428,21 +430,10 @@
    9.67      }
    9.68  
    9.69  #ifdef HAVE_OPENGL
    9.70 -    if (current->flags & SDL_OPENGL)
    9.71 +    if ((current->flags & SDL_OPENGL)==SDL_OPENGL)
    9.72      {
    9.73 -        /* ph_SetupOpenGLContext creates also window as need */
    9.74 -        if (ph_SetupOpenGLContext(this, width, height, bpp, flags)==0)
    9.75 -        {
    9.76 -            ph_SetupUpdateFunction(this, current, flags); 
    9.77 -        }
    9.78 -        else
    9.79 -        {
    9.80 -            /* if context creation fail, report no OpenGL to high level */
    9.81 -            current->flags &= ~SDL_OPENGL;
    9.82 -            return NULL;
    9.83 -        }
    9.84  #else
    9.85 -    if (current->flags & SDL_OPENGL) /* if no built-in OpenGL support */
    9.86 +    if ((current->flags & SDL_OPENGL)==SDL_OPENGL) /* if no built-in OpenGL support */
    9.87      {
    9.88          SDL_SetError("ph_SetVideoMode(): no OpenGL support, try to recompile library.\n");
    9.89          current->flags &= ~SDL_OPENGL;
    9.90 @@ -528,10 +519,6 @@
    9.91  
    9.92  static void ph_VideoQuit(_THIS)
    9.93  {
    9.94 -#ifdef HAVE_OPENGL
    9.95 -    PhRegion_t region_info;
    9.96 -#endif /* HAVE_OPENGL */
    9.97 -
    9.98      /* restore palette */
    9.99      if (desktopbpp==8)
   9.100      {
   9.101 @@ -542,22 +529,6 @@
   9.102  
   9.103      ph_DestroyImage(this, SDL_VideoSurface); 
   9.104  
   9.105 -#ifdef HAVE_OPENGL
   9.106 -    /* prevent double SEGFAULT during parachute mode */
   9.107 -    if (this->screen)
   9.108 -    {
   9.109 -        if (((this->screen->flags & SDL_FULLSCREEN)==SDL_FULLSCREEN) &&
   9.110 -            ((this->screen->flags & SDL_OPENGL)==SDL_OPENGL))
   9.111 -        {
   9.112 -            region_info.cursor_type=Ph_CURSOR_POINTER;
   9.113 -            region_info.rid=PtWidgetRid(window);
   9.114 -            PhRegionChange(Ph_REGION_CURSOR, 0, &region_info, NULL, NULL);
   9.115 -        }
   9.116 -    }
   9.117 -
   9.118 -    PtFlush();
   9.119 -#endif /* HAVE_OPENGL */
   9.120 -    
   9.121      if (window)
   9.122      {
   9.123          PtUnrealizeWidget(window);
   9.124 @@ -565,15 +536,6 @@
   9.125          window=NULL;
   9.126      }
   9.127  
   9.128 -#ifdef HAVE_OPENGL
   9.129 -    if (oglctx)
   9.130 -    {
   9.131 -        PhDCSetCurrent(NULL);
   9.132 -        PhDCRelease(oglctx);
   9.133 -        oglctx=NULL;
   9.134 -    }
   9.135 -#endif /* HAVE_OPENGL */
   9.136 -
   9.137      if (event!=NULL)
   9.138      {
   9.139          free(event);
   9.140 @@ -638,82 +600,13 @@
   9.141  
   9.142  #ifdef HAVE_OPENGL
   9.143  
   9.144 -int ph_SetupOpenGLContext(_THIS, int width, int height, int bpp, Uint32 flags)
   9.145 -{
   9.146 -    PhDim_t dim;
   9.147 -    uint64_t OGLAttrib[PH_OGL_MAX_ATTRIBS];
   9.148 -    int OGLargc;
   9.149 -
   9.150 -    dim.w=width;
   9.151 -    dim.h=height;
   9.152 -    
   9.153 -    if (oglctx!=NULL)
   9.154 -    {
   9.155 -       PhDCSetCurrent(NULL);
   9.156 -       PhDCRelease(oglctx);
   9.157 -       oglctx=NULL;
   9.158 -    }
   9.159 -
   9.160 -    OGLargc=0;
   9.161 -    if (this->gl_config.depth_size)
   9.162 -    {
   9.163 -        OGLAttrib[OGLargc++]=PHOGL_ATTRIB_DEPTH_BITS;
   9.164 -        OGLAttrib[OGLargc++]=this->gl_config.depth_size;
   9.165 -    }
   9.166 -    if (this->gl_config.stencil_size)
   9.167 -    {
   9.168 -        OGLAttrib[OGLargc++]=PHOGL_ATTRIB_STENCIL_BITS;
   9.169 -        OGLAttrib[OGLargc++]=this->gl_config.stencil_size;
   9.170 -    }
   9.171 -    OGLAttrib[OGLargc++]=PHOGL_ATTRIB_FORCE_SW;
   9.172 -    if (flags & SDL_FULLSCREEN)
   9.173 -    {
   9.174 -        OGLAttrib[OGLargc++]=PHOGL_ATTRIB_FULLSCREEN;
   9.175 -        OGLAttrib[OGLargc++]=PHOGL_ATTRIB_DIRECT;
   9.176 -        OGLAttrib[OGLargc++]=PHOGL_ATTRIB_FULLSCREEN_BEST;
   9.177 -        OGLAttrib[OGLargc++]=PHOGL_ATTRIB_FULLSCREEN_CENTER;
   9.178 -    }
   9.179 -    OGLAttrib[OGLargc++]=PHOGL_ATTRIB_NONE;
   9.180 -
   9.181 -    if (this->gl_config.double_buffer)
   9.182 -    {
   9.183 -        oglctx=PdCreateOpenGLContext(2, &dim, 0, OGLAttrib);
   9.184 -    }
   9.185 -    else
   9.186 -    {
   9.187 -        oglctx=PdCreateOpenGLContext(1, &dim, 0, OGLAttrib);
   9.188 -    }
   9.189 -
   9.190 -    if (oglctx==NULL)
   9.191 -    {
   9.192 -        SDL_SetError("ph_SetupOpenGLContext(): cannot create OpenGL context !\n");
   9.193 -        return (-1);
   9.194 -    }
   9.195 -
   9.196 -    PhDCSetCurrent(oglctx);
   9.197 -
   9.198 -    /* disable mouse for fullscreen */
   9.199 -    if (flags & SDL_FULLSCREEN)
   9.200 -    {
   9.201 -        PhRegion_t region_info;
   9.202 -
   9.203 -        region_info.cursor_type=Ph_CURSOR_NONE;
   9.204 -        region_info.rid=PtWidgetRid(window);
   9.205 -        PhRegionChange(Ph_REGION_CURSOR, 0, &region_info, NULL, NULL);
   9.206 -    }
   9.207 -
   9.208 -    PtFlush();
   9.209 -
   9.210 -    return 0;
   9.211 -}
   9.212 -
   9.213 -void ph_GL_SwapBuffers(_THIS)
   9.214 +static void ph_GL_SwapBuffers(_THIS)
   9.215  {
   9.216      PgSetRegion(PtWidgetRid(window));
   9.217      PdOpenGLContextSwapBuffers(oglctx);
   9.218  }
   9.219  
   9.220 -int ph_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value)
   9.221 +static int ph_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value)
   9.222  {
   9.223      switch (attrib)
   9.224      {
   9.225 @@ -733,44 +626,29 @@
   9.226      return 0;
   9.227  }
   9.228  
   9.229 -int ph_GL_LoadLibrary(_THIS, const char* path)
   9.230 +static int ph_GL_LoadLibrary(_THIS, const char* path)
   9.231  {
   9.232 -   /* if code compiled with HAVE_OPENGL, the library already linked */
   9.233 +   /* if code compiled with HAVE_OPENGL, that mean that library already linked */
   9.234     this->gl_config.driver_loaded = 1;
   9.235  
   9.236     return 0;
   9.237  }
   9.238  
   9.239 -void* ph_GL_GetProcAddress(_THIS, const char* proc)
   9.240 +static void* ph_GL_GetProcAddress(_THIS, const char* proc)
   9.241  {
   9.242     return NULL;
   9.243  }
   9.244  
   9.245 -#endif /* HAVE_OPENGL */
   9.246 +static int ph_GL_MakeCurrent(_THIS)
   9.247 +{
   9.248 +    PgSetRegion(PtWidgetRid(window));
   9.249  
   9.250 -static void ph_UpdateMouse(_THIS)
   9.251 -{
   9.252 -    PhCursorInfo_t phcursor;
   9.253 -    short abs_x;
   9.254 -    short abs_y;
   9.255 -
   9.256 -    /* Lock the event thread, in multi-threading environments */
   9.257 -    SDL_Lock_EventThread();
   9.258 -
   9.259 -    /* synchronizing photon mouse cursor position and SDL mouse position, if cursor appears over window. */
   9.260 -    PtGetAbsPosition(window, &abs_x, &abs_y);
   9.261 -    PhQueryCursor(PhInputGroup(NULL), &phcursor);
   9.262 -    if (((phcursor.pos.x >= abs_x) && (phcursor.pos.x <= abs_x + this->screen->w)) &&
   9.263 -        ((phcursor.pos.y >= abs_y) && (phcursor.pos.y <= abs_y + this->screen->h)))
   9.264 +    if (oglctx!=NULL)
   9.265      {
   9.266 -        SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
   9.267 -        SDL_PrivateMouseMotion(0, 0, phcursor.pos.x-abs_x, phcursor.pos.y-abs_y);
   9.268 -    }
   9.269 -    else
   9.270 -    {
   9.271 -        SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
   9.272 +        PhDCSetCurrent(oglctx);
   9.273      }
   9.274  
   9.275 -    /* Unlock the event thread, in multi-threading environments */
   9.276 -    SDL_Unlock_EventThread();
   9.277 +    return 0;
   9.278  }
   9.279 +
   9.280 +#endif /* HAVE_OPENGL */
    10.1 --- a/src/video/photon/SDL_ph_video.h	Sat Aug 30 09:09:09 2003 +0000
    10.2 +++ b/src/video/photon/SDL_ph_video.h	Sat Aug 30 17:07:59 2003 +0000
    10.3 @@ -46,9 +46,9 @@
    10.4  
    10.5  typedef struct
    10.6  {
    10.7 -	unsigned char* Y;
    10.8 -	unsigned char* V;
    10.9 -	unsigned char* U;
   10.10 +    unsigned char* Y;
   10.11 +    unsigned char* V;
   10.12 +    unsigned char* U;
   10.13  } FRAMEDATA;
   10.14  
   10.15  /* Mask values for SDL_ReallocFormat() */
   10.16 @@ -68,6 +68,8 @@
   10.17      PhImage_t *image;	                 /* used to display image       */
   10.18  #ifdef HAVE_OPENGL
   10.19      PdOpenGLContext_t* OGLContext;       /* OpenGL context              */
   10.20 +    Uint32 OGLFlags;                     /* OpenGL flags                */
   10.21 +    Uint32 OGLBPP;                       /* OpenGL bpp                  */
   10.22  #endif /* HAVE_OPENGL */
   10.23      PgColor_t savedpal[_Pg_MAX_PALETTE];
   10.24      PgColor_t syspalph[_Pg_MAX_PALETTE];
   10.25 @@ -82,8 +84,8 @@
   10.26          unsigned char*        CurrentFrameData;
   10.27          unsigned char*        FrameData0;
   10.28          unsigned char*        FrameData1;
   10.29 -        int                   current;
   10.30 -        long                  flags;
   10.31 +        Uint32                current;
   10.32 +        Uint32                flags;
   10.33      } ocimage;
   10.34  
   10.35      PgHWCaps_t graphics_card_caps;  /* Graphics card caps at the moment of start   */
   10.36 @@ -94,9 +96,9 @@
   10.37      int mouse_relative;
   10.38      WMcursor* BlankCursor;
   10.39  
   10.40 -    int depth;			/* current visual depth (not bpp)           */
   10.41 -    int desktopbpp;             /* bpp of desktop at the moment of start    */
   10.42 -    int desktoppal;             /* palette mode emulation or system         */
   10.43 +    Uint32 depth;	            /* current visual depth (not bpp)           */
   10.44 +    Uint32 desktopbpp;              /* bpp of desktop at the moment of start    */
   10.45 +    Uint32 desktoppal;              /* palette mode emulation or system         */
   10.46  
   10.47      int currently_fullscreen;
   10.48      int currently_hided;        /* 1 - window hided (minimazed), 0 - normal */
   10.49 @@ -107,7 +109,6 @@
   10.50  
   10.51  #define mode_settings        (this->hidden->mode_settings)
   10.52  #define window	             (this->hidden->Window)
   10.53 -#define oglctx               (this->hidden->OGLContext)
   10.54  #define SDL_Image            (this->hidden->image)
   10.55  #define OCImage              (this->hidden->ocimage)
   10.56  #define old_video_mode       (this->hidden->old_video_mode)
   10.57 @@ -122,9 +123,13 @@
   10.58  #define event                (this->hidden->event)
   10.59  #define current_overlay      (this->hidden->overlay)
   10.60  #define desktop_mode         (this->hidden->desktop_mode)
   10.61 -
   10.62 -/* Old variable names */
   10.63  #define mouse_relative       (this->hidden->mouse_relative)
   10.64  #define SDL_BlankCursor      (this->hidden->BlankCursor)
   10.65  
   10.66 +#ifdef HAVE_OPENGL
   10.67 +     #define oglctx               (this->hidden->OGLContext)
   10.68 +     #define oglflags             (this->hidden->OGLFlags)
   10.69 +     #define oglbpp               (this->hidden->OGLBPP)
   10.70 +#endif /* HAVE_OPENGL */
   10.71 +
   10.72  #endif /* __SDL_PH_VIDEO_H__ */
    11.1 --- a/src/video/photon/SDL_ph_wm_c.h	Sat Aug 30 09:09:09 2003 +0000
    11.2 +++ b/src/video/photon/SDL_ph_wm_c.h	Sat Aug 30 17:07:59 2003 +0000
    11.3 @@ -20,10 +20,13 @@
    11.4      slouken@libsdl.org
    11.5  */
    11.6  
    11.7 +#ifndef __SDL_PH_WM_H__
    11.8 +#define __SDL_PH_WM_H__
    11.9 +
   11.10  #ifdef SAVE_RCSID
   11.11  static char rcsid =
   11.12   "@(#) $Id$";
   11.13 -#endif
   11.14 +#endif /* SAVE_RCSID */
   11.15  
   11.16  #include "SDL_ph_video.h"
   11.17  
   11.18 @@ -35,3 +38,4 @@
   11.19  extern SDL_GrabMode ph_GrabInput(_THIS, SDL_GrabMode mode);
   11.20  extern int ph_GetWMInfo(_THIS, SDL_SysWMinfo *info);
   11.21  
   11.22 +#endif /* __SDL_PH_WM_H__ */
    12.1 --- a/src/video/photon/SDL_phyuv_c.h	Sat Aug 30 09:09:09 2003 +0000
    12.2 +++ b/src/video/photon/SDL_phyuv_c.h	Sat Aug 30 17:07:59 2003 +0000
    12.3 @@ -20,10 +20,14 @@
    12.4      slouken@libsdl.org
    12.5  */
    12.6  
    12.7 +
    12.8 +#ifndef __SDL_PH_YUV_H__
    12.9 +#define __SDL_PH_YUV_H__
   12.10 +
   12.11  #ifdef SAVE_RCSID
   12.12  static char rcsid =
   12.13   "@(#) $Id$";
   12.14 -#endif
   12.15 +#endif /* SAVE_RCSID */
   12.16  
   12.17  /* This is the photon implementation of YUV video overlays */
   12.18  
   12.19 @@ -59,3 +63,5 @@
   12.20  extern void ph_UnlockYUVOverlay(_THIS, SDL_Overlay* overlay);
   12.21  extern int ph_DisplayYUVOverlay(_THIS, SDL_Overlay* overlay, SDL_Rect* dstrect);
   12.22  extern void ph_FreeYUVOverlay(_THIS, SDL_Overlay* overlay);
   12.23 +
   12.24 +#endif /* __SDL_PH_YUV_H__ */