Date: Fri, 15 Aug 2003 09:13:59 +0300
authorSam Lantinga <slouken@libsdl.org>
Sat, 23 Aug 2003 23:20:21 +0000
changeset 69204dd6c6d7c30
parent 691 609543e2b3a1
child 693 6c119628180d
Date: Fri, 15 Aug 2003 09:13:59 +0300
From: "Mike Gorchak"
Subject: Patches for tests and QNX6

Here more fixes for the QNX6 in sdlqnx.diff file:

- Spellchecked README.QNX (thanks to Julian Kinraid)
- Fixed bugs in fullscreen mode: window region wasn't on top by default, so \
it caused some artifacts to be appeared on the screen, prevent window conten\
ts default filler in Photon while in fullscreen mode, it damages the screen.
- Added support for the SDL_VIDEO_WINDOW_POS, SDL_VIDEO_CENTERED env variabl\
es.
- Some minor code restructurization.
BUGS
README.QNX
src/video/photon/SDL_ph_image.c
src/video/photon/SDL_ph_modes.c
src/video/photon/SDL_ph_video.c
src/video/photon/SDL_ph_video.h
     1.1 --- a/BUGS	Sat Aug 23 23:18:49 2003 +0000
     1.2 +++ b/BUGS	Sat Aug 23 23:20:21 2003 +0000
     1.3 @@ -142,7 +142,7 @@
     1.4      No console output screen. Printing to stdout do not have any effect.
     1.5  
     1.6  QNX:
     1.7 -	Fullscreen switch doesn't work correctly.
     1.8 +	Fullscreen switch doesn't work (disabled for now).
     1.9   
    1.10  
    1.11  OpenBSD:  -= NOT YET SUPPORTED =-
     2.1 --- a/README.QNX	Sat Aug 23 23:18:49 2003 +0000
     2.2 +++ b/README.QNX	Sat Aug 23 23:20:21 2003 +0000
     2.3 @@ -1,112 +1,108 @@
     2.4  README by Mike Gorchak <mike@malva.ua>, <lestat@i.com.ua>
     2.5 -Last changed at 29 Jul 2003.
     2.6 +Last changed at 12 Aug 2003.
     2.7  
     2.8 -=========================================================================
     2.9 +======================================================================
    2.10  OpenGL:
    2.11  
    2.12 -    OpenGL in window mode  works well  and  stable, in fullscreen
    2.13 -mode too, but fullscreen mode has not been heavily tested yet.
    2.14 -    If you have QNX RtP version 6.1.0 and above you must download
    2.15 -new Photon3D runtime from http://developers.qnx.com or install it
    2.16 -from public repository or from public CD, available with QNX. The
    2.17 -versions of OS before 6.1.0 are not supported.
    2.18 -    While  creating  OpenGL  context  software  renderer  mode is
    2.19 -artificially selected (QSSL  made  acceleration  only for  Voodoo
    2.20 -boards in fullscreen mode, sorry but I  don't have  this board to
    2.21 -test OpenGL - maybe it work or maybe not :)). If you want accele-
    2.22 -ration - you may remove some line in source code: find  the  file
    2.23 -SDL_ph_video.c and remove the following
    2.24 +    OpenGL works well and is stable, but fullscreen mode has not  been
    2.25 +heavily tested yet.
    2.26 +    If you have QNX RtP version 6.1.0 or above you must  download  the
    2.27 +Photon3D runtime from http://developers.qnx.com or install it from the
    2.28 +public repository or the  public CD, available  with  QNX. OS versions
    2.29 +below 6.1.0 are not supported.
    2.30 +    When creating an OpenGL context, software renderer mode is artifi-
    2.31 +cially selected (QSSL made acceleration  only  for  Voodoo  boards  in
    2.32 +fullscreen mode, sorry but I don't have this board  to  test  OpenGL -
    2.33 +maybe it works or maybe not :)). If you  want  acceleration - you  can
    2.34 +remove one line in the source code: find the  file SDL_ph_video.c  and
    2.35 +remove the following
    2.36  
    2.37      OGLAttrib[OGLargc++]=PHOGL_ATTRIB_FORCE_SW;
    2.38       
    2.39 -line in the ph_SetupOpenGLContext() function or  change  argument
    2.40 -to the PHOGL_ATTRIB_FORCE_HW or PHOGL_ATTRIB_FAVOR_HW.
    2.41 +line in the ph_SetupOpenGLContext() function or change the argument to
    2.42 +PHOGL_ATTRIB_FORCE_HW or PHOGL_ATTRIB_FAVOR_HW.
    2.43  
    2.44 -=========================================================================
    2.45 -Wheel and multibutton mouses:
    2.46 +======================================================================
    2.47 +Wheel and multi-button mouses:
    2.48  
    2.49 -    Photon emitting keyboard events (key up and down) when  moved
    2.50 -mouse wheel. But key_scan field appears valid according to flags,
    2.51 -and it contain zero. It is base method of detecting  mouse  wheel
    2.52 -events under photon. It looks like a hack, but it works for me :)
    2.53 -on different PC configurations.
    2.54 +    Photon emits  keyboard  events (key up and down)  when  the  mouse
    2.55 +wheel is moved. The key_scan field appears valid, and it contains zero.
    2.56 +That is a basic method of detecting  mouse  wheel events under Photon.
    2.57 +It looks like a hack, but it works for me :) on various PC  configura-
    2.58 +tions.
    2.59  
    2.60 -I'm tested it on:
    2.61 +I've tested it on:
    2.62  
    2.63  1. Genius Optical NetScroll/+ (1 wheel)
    2.64 -2. A4Tech Optical GreatEye WheelMouse, model: WOP-35. (2 wheels +
    2.65 -   2 additional buttons). Wheel for vertical scrolling  works  as
    2.66 -   usual, but second wheel for horizontal scrolling emitting  two
    2.67 -   consequented events up or down, so it can  provide  more  fast
    2.68 -   scrolling then the  first  wheel. Additional  buttons  doesn't
    2.69 -   emitting any events, but its look like  handled by  photon  in
    2.70 -   unusual way - like click to front, but works not with any win-
    2.71 -   dow, looks like bug-o-feature :).
    2.72 +2. A4Tech Optical  GreatEye  WheelMouse,  model: WOP-35. (2 wheels + 2
    2.73 +   additional buttons). The wheel for vertical scrolling works as usu-
    2.74 +   al, but the second wheel for horizontal scrolling emits two sequen-
    2.75 +   tial events up or down, so it can provide faster scrolling than the
    2.76 +   first wheel. Additional buttons don't emit any events, but it looks
    2.77 +   like they're handled by photon in an unusual  way - like  click  to
    2.78 +   front, but works not with any window, looks like bug-o-feature :).
    2.79  
    2.80 -=========================================================================
    2.81 +======================================================================
    2.82  CDROM handling issues:
    2.83  
    2.84 -    Access to CDROM can be provided only with 'root'  previleges.
    2.85 -I can't do anything with this fact. /dev/cd0 have  the brw-------
    2.86 -flags and root:root rights.
    2.87 +    Access to CDROM can only be  provided  with  'root'  privileges. I
    2.88 +can't do anything about that, /dev/cd0 has brw------- permissions  and
    2.89 +root:root rights.
    2.90  
    2.91 -=========================================================================
    2.92 +======================================================================
    2.93  Video Overlays:
    2.94  
    2.95 -    Overlays can flickering during the window movement, resizing,
    2.96 -etc. It happens because photon driver  updates  the  real  window
    2.97 -contents behind the overlay, then draws the temporary  chroma key
    2.98 -color over window contents. It can be done without the chroma key
    2.99 -using but it cause overlay will be  always  on top. So flickering
   2.100 -during the movement much better in that case.
   2.101 -    Double buffering code temporary disabled in the photon driver
   2.102 -code, beacuse on my GF2-MX it  cause  accidently  buffer  switch,
   2.103 -which going to the old frame showing. S3 Savage3D have  the  same
   2.104 -problem, but ATI Rage 128 has not this problem. I think it can be
   2.105 -fixed later. Current code works very fine, so maybe double buffe-
   2.106 -ring is not needed right now.
   2.107 -    Something strange appears when you tried to move window  with
   2.108 -overlay beyond the left border of the screen. Overlay  trying  to
   2.109 -stay at position x=0, but when tried to move  it  a  bit  more it
   2.110 -jumps  at  posituin  x=-60. Really  strange, looks  like  overlay
   2.111 -doesn't love the negotive coordinates.
   2.112 +    Overlays can flicker  during  window  movement,  resizing, etc. It
   2.113 +happens because the photon driver updates the real window contents be-
   2.114 +hind the overlay, then draws the temporary chroma key color  over  the
   2.115 +window contents. It can be done without using the chroma key but  that
   2.116 +causes the overlay to always be on top. So  flickering  during  window
   2.117 +movement is preferred instead.
   2.118 +    Double buffering code is temporarily disabled in the photon driver
   2.119 +code, because on my GF2-MX it can accidentally cause a buffer  switch,
   2.120 +which causes the old frame to show. S3 Savage4 has the  same  problem,
   2.121 +but ATI Rage 128 doesn't. I think it can be fixed later. Current  code
   2.122 +works very well, so maybe double buffering is not needed right now.
   2.123 +    Something strange happens when you try to move the window with the
   2.124 +overlay beyond the left border  of the screen. The  overlay  tries  to
   2.125 +stay at position x=0, but when attempting to move it  a  bit  more  it
   2.126 +jumps to position x=-60 (on GF2-MX, on ATI Rage128 this  value  a  bit
   2.127 +smaller). It's really strange, looks  like  the  overlay  doesn't like
   2.128 +negative coordinates.
   2.129  
   2.130 -=========================================================================
   2.131 +=======================================================================
   2.132  Shared library building:
   2.133  
   2.134 -    Shared  library can be  built, but before  running autogen.sh
   2.135 -script you  need  manually  delete  the  libtool  m4  stuff  from
   2.136 -the acinclude.m4 file (it comes after ESD  detection  code  up to
   2.137 -end of the file). Because libtool stuff in the  acinclude.m4 file
   2.138 -very old and doesn't know anything about the QNX. Just  remove it
   2.139 -and run autogen.sh script.
   2.140 +    A shared library can be built, but before running  the  autogen.sh
   2.141 +script you must manually delete the libtool.m4 stuff from the acinclu-
   2.142 +de.m4 file (it comes after the ESD detection code up to the end of the
   2.143 +file), because the libtool stuff in the acinclude.m4 file is very  old
   2.144 +and doesn't know anything about QNX. Just remove it and run autogen.sh.
   2.145  
   2.146 -=========================================================================
   2.147 +======================================================================
   2.148  Some building issues:
   2.149  
   2.150 -    Feel free to not pass --disable-shared option  to  configure,
   2.151 -if you read comment above about 'Shared library building'. Other-
   2.152 -wise this option is strongly  recomended, because  the sdl-config
   2.153 -script will be unfunctional.
   2.154 +    Feel free to not use the --disable-shared configure option if you'
   2.155 +ve read the above comment about 'Shared  library  building'. Otherwise
   2.156 +this  option  is  strongly  recommended, as  without it the sdl-config
   2.157 +script will be broken.
   2.158  
   2.159 -    Run configure script without x11 support, e.g.:
   2.160 +    Run the configure script without x11 support, e.g.:
   2.161  
   2.162      a) for OpenGL support:
   2.163 -    ./configure --prefix=/usr/local \
   2.164 +    ./configure --prefix=/usr       \
   2.165                  --disable-video-x11 \
   2.166                  --disable-shared
   2.167  
   2.168      b) without OpenGL support:
   2.169 -    ./configure --prefix=/usr/local \
   2.170 +    ./configure --prefix=/usr       \
   2.171                  --disable-video-x11 \
   2.172                  --disable-shared    \
   2.173                  --disable-video-opengl
   2.174  
   2.175 -    In test directory  also run  ./configure  script  without x11
   2.176 -support, e.g.:
   2.177 +    In the test directory also run the ./configure script without
   2.178 +x11 support, e.g.:
   2.179  
   2.180 -    ./configure  --with-sdl-prefix=/usr/local      \
   2.181 -                 --with-sdl-exec-prefix=/usr/local \
   2.182 -                 --prefix=/usr/local --without-x
   2.183 -
   2.184 -
   2.185 +    ./configure  --with-sdl-prefix=/usr            \
   2.186 +                 --with-sdl-exec-prefix=/usr       \
   2.187 +                 --prefix=/usr --without-x
     3.1 --- a/src/video/photon/SDL_ph_image.c	Sat Aug 23 23:18:49 2003 +0000
     3.2 +++ b/src/video/photon/SDL_ph_image.c	Sat Aug 23 23:20:21 2003 +0000
     3.3 @@ -267,6 +267,8 @@
     3.4  
     3.5      this->UpdateRects = ph_OCDCUpdate;
     3.6  
     3.7 +    PgFlush();
     3.8 +
     3.9      return 0;
    3.10  }
    3.11  
     4.1 --- a/src/video/photon/SDL_ph_modes.c	Sat Aug 23 23:18:49 2003 +0000
     4.2 +++ b/src/video/photon/SDL_ph_modes.c	Sat Aug 23 23:20:21 2003 +0000
     4.3 @@ -297,13 +297,14 @@
     4.4  
     4.5          currently_fullscreen = 1;
     4.6      }
     4.7 +    PgFlush();
     4.8  
     4.9      return 1;
    4.10  }
    4.11  
    4.12  int ph_LeaveFullScreen(_THIS)
    4.13  {
    4.14 -    PgDisplaySettings_t mymode_settings;
    4.15 +    PgDisplaySettings_t oldmode_settings;
    4.16         
    4.17      if (currently_fullscreen)
    4.18      {
    4.19 @@ -332,11 +333,11 @@
    4.20              /* Restore old video mode */
    4.21              if (old_video_mode != -1)
    4.22              {
    4.23 -                mymode_settings.mode = (unsigned short) old_video_mode;
    4.24 -                mymode_settings.refresh = (unsigned short) old_refresh_rate;
    4.25 -                mymode_settings.flags = 0;
    4.26 +                oldmode_settings.mode = (unsigned short) old_video_mode;
    4.27 +                oldmode_settings.refresh = (unsigned short) old_refresh_rate;
    4.28 +                oldmode_settings.flags = 0;
    4.29                  
    4.30 -                if (PgSetVideoMode(&mymode_settings) < 0)
    4.31 +                if (PgSetVideoMode(&oldmode_settings) < 0)
    4.32                  {
    4.33                      SDL_SetError("Ph_LeaveFullScreen(): PgSetVideoMode() function failed !\n");
    4.34                      return 0;
     5.1 --- a/src/video/photon/SDL_ph_video.c	Sat Aug 23 23:18:49 2003 +0000
     5.2 +++ b/src/video/photon/SDL_ph_video.c	Sat Aug 23 23:20:21 2003 +0000
     5.3 @@ -194,9 +194,11 @@
     5.4      PhPoint_t   pos = {0, 0};
     5.5      PhDim_t     dim = {w, h};
     5.6      int         nargs = 0;
     5.7 +    const char* windowpos;
     5.8 +    const char* iscentered;
     5.9 +    int         x, y;
    5.10  
    5.11      PtSetArg(&args[nargs++], Pt_ARG_DIM, &dim, 0);
    5.12 -    PtSetArg(&args[nargs++], Pt_ARG_FILL_COLOR, Pg_BLACK, 0);
    5.13  
    5.14      if ((flags & SDL_RESIZABLE) == SDL_RESIZABLE)
    5.15      {
    5.16 @@ -234,12 +236,36 @@
    5.17      if ((flags & SDL_FULLSCREEN) == SDL_FULLSCREEN)
    5.18      {
    5.19          PtSetArg(&args[nargs++], Pt_ARG_POS, &pos, 0);
    5.20 +        PtSetArg(&args[nargs++], Pt_ARG_BASIC_FLAGS, Pt_TRUE, Pt_BASIC_PREVENT_FILL);
    5.21          PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE, Ph_WM_FFRONT | Ph_WM_MAX);
    5.22 -        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_TRUE, Ph_WM_STATE_ISFRONT | Ph_WM_STATE_ISMAX |
    5.23 -                                                               Ph_WM_STATE_ISFOCUS | Ph_WM_STATE_ISALTKEY);
    5.24 +        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_TRUE, Ph_WM_STATE_ISFRONT | Ph_WM_STATE_ISFOCUS | Ph_WM_STATE_ISALTKEY);
    5.25      }
    5.26      else
    5.27      {
    5.28 +        windowpos = getenv("SDL_VIDEO_WINDOW_POS");
    5.29 +	iscentered = getenv("SDL_VIDEO_CENTERED");
    5.30 +
    5.31 +        if ((iscentered) || ((windowpos) && (strcmp(windowpos, "center")==0)))
    5.32 +        {
    5.33 +            pos.x = (desktop_mode.width - w)/2;
    5.34 +            pos.y = (desktop_mode.height - h)/2;
    5.35 +            PtSetArg(&args[nargs++], Pt_ARG_POS, &pos, 0);
    5.36 +	}
    5.37 +        else
    5.38 +        {
    5.39 +            if (windowpos)
    5.40 +            {
    5.41 +                if (sscanf(windowpos, "%d,%d", &x, &y) == 2 )
    5.42 +                {
    5.43 +                    pos.x=x;
    5.44 +                    pos.y=y;
    5.45 +                    PtSetArg(&args[nargs++], Pt_ARG_POS, &pos, 0);
    5.46 +                }
    5.47 +	    }
    5.48 +        }
    5.49 +
    5.50 +
    5.51 +        PtSetArg(&args[nargs++], Pt_ARG_FILL_COLOR, Pg_BLACK, 0);
    5.52          PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_FALSE, Ph_WM_STATE_ISFRONT | Ph_WM_STATE_ISMAX | Ph_WM_STATE_ISALTKEY);
    5.53          PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE, Ph_WM_HIDE);
    5.54          PtSetArg(&args[nargs++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE, Ph_WM_HIDE);
    5.55 @@ -248,6 +274,7 @@
    5.56  
    5.57      PtSetResources(window, nargs, args);
    5.58      PtRealizeWidget(window);
    5.59 +    PtWindowToFront(window);
    5.60  
    5.61      return 0;
    5.62  }
    5.63 @@ -281,7 +308,6 @@
    5.64  
    5.65  static int ph_VideoInit(_THIS, SDL_PixelFormat *vformat)
    5.66  {
    5.67 -    PgVideoModeInfo_t my_mode_info;
    5.68      PgHWCaps_t my_hwcaps;
    5.69      int i;
    5.70  
    5.71 @@ -325,7 +351,7 @@
    5.72          return -1;
    5.73      }
    5.74  
    5.75 -    if (PgGetVideoModeInfo(my_hwcaps.current_video_mode, &my_mode_info) < 0)
    5.76 +    if (PgGetVideoModeInfo(my_hwcaps.current_video_mode, &desktop_mode) < 0)
    5.77      {
    5.78          SDL_SetError("ph_VideoInit(): PgGetVideoModeInfo function failed !\n");
    5.79          this->FreeWMCursor(this, SDL_BlankCursor);
    5.80 @@ -333,9 +359,9 @@
    5.81      }
    5.82  
    5.83      /* We need to return BytesPerPixel as it in used by CreateRGBsurface */
    5.84 -    vformat->BitsPerPixel = my_mode_info.bits_per_pixel;
    5.85 -    vformat->BytesPerPixel = my_mode_info.bytes_per_scanline/my_mode_info.width;
    5.86 -    desktopbpp = my_mode_info.bits_per_pixel;
    5.87 +    vformat->BitsPerPixel = desktop_mode.bits_per_pixel;
    5.88 +    vformat->BytesPerPixel = desktop_mode.bytes_per_scanline/desktop_mode.width;
    5.89 +    desktopbpp = desktop_mode.bits_per_pixel;
    5.90      
    5.91      /* save current palette */
    5.92      if (desktopbpp==8)
    5.93 @@ -434,6 +460,7 @@
    5.94              }
    5.95  
    5.96              current->flags &= ~SDL_RESIZABLE; /* no resize for Direct Context */
    5.97 +            current->flags |= SDL_HWSURFACE;
    5.98          }
    5.99          else
   5.100          {
   5.101 @@ -488,6 +515,10 @@
   5.102      {
   5.103         PtFlush();
   5.104      }
   5.105 +    else
   5.106 +    {
   5.107 +       PgFlush();
   5.108 +    }
   5.109  
   5.110      SDL_Unlock_EventThread();
   5.111  
     6.1 --- a/src/video/photon/SDL_ph_video.h	Sat Aug 23 23:18:49 2003 +0000
     6.2 +++ b/src/video/photon/SDL_ph_video.h	Sat Aug 23 23:20:21 2003 +0000
     6.3 @@ -72,20 +72,22 @@
     6.4      PgColor_t savedpal[_Pg_MAX_PALETTE];
     6.5      PgColor_t syspalph[_Pg_MAX_PALETTE];
     6.6  
     6.7 -    struct {
     6.8 +    struct
     6.9 +    {
    6.10          PdDirectContext_t*    direct_context;
    6.11          PdOffscreenContext_t* offscreen_context;
    6.12          PdOffscreenContext_t* offscreen_backcontext;
    6.13          PhDrawContext_t*      oldDC;
    6.14          uint8_t*              dc_ptr;
    6.15 -        unsigned char* CurrentFrameData;
    6.16 -        unsigned char* FrameData0;
    6.17 -        unsigned char* FrameData1;
    6.18 -        int current;
    6.19 -        long flags;
    6.20 +        unsigned char*        CurrentFrameData;
    6.21 +        unsigned char*        FrameData0;
    6.22 +        unsigned char*        FrameData1;
    6.23 +        int                   current;
    6.24 +        long                  flags;
    6.25      } ocimage;
    6.26  
    6.27      PgHWCaps_t graphics_card_caps;  /* Graphics card caps at the moment of start   */
    6.28 +    PgVideoModeInfo_t desktop_mode; /* Current desktop video mode information      */
    6.29      int old_video_mode;             /* Stored mode before fullscreen switch        */
    6.30      int old_refresh_rate;           /* Stored refresh rate befor fullscreen switch */
    6.31  
    6.32 @@ -119,6 +121,7 @@
    6.33  #define currently_hided      (this->hidden->currently_hided)
    6.34  #define event                (this->hidden->event)
    6.35  #define current_overlay      (this->hidden->overlay)
    6.36 +#define desktop_mode         (this->hidden->desktop_mode)
    6.37  
    6.38  /* Old variable names */
    6.39  #define mouse_relative       (this->hidden->mouse_relative)