src/video/gapi/SDL_gapivideo.h
author Sam Lantinga <slouken@libsdl.org>
Sun, 02 Aug 2009 18:39:57 +0000
changeset 3227 458e53d8662c
parent 2859 99210400e8b9
permissions -rw-r--r--
Clarified API documentation
     1 /*
     2     SDL - Simple DirectMedia Layer
     3     Copyright (C) 1997-2009 Sam Lantinga
     4 
     5     This library is free software; you can redistribute it and/or
     6     modify it under the terms of the GNU Lesser General Public
     7     License as published by the Free Software Foundation; either
     8     version 2.1 of the License, or (at your option) any later version.
     9 
    10     This library is distributed in the hope that it will be useful,
    11     but WITHOUT ANY WARRANTY; without even the implied warranty of
    12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    13     Lesser General Public License for more details.
    14 
    15     You should have received a copy of the GNU Lesser General Public
    16     License along with this library; if not, write to the Free Software
    17     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    18 
    19     Sam Lantinga
    20     slouken@libsdl.org
    21 */
    22 #include "SDL_config.h"
    23 
    24 #ifndef _SDL_gapivideo_h
    25 #define _SDL_gapivideo_h
    26 
    27 #include "SDL_mouse.h"
    28 #include "SDL_mutex.h"
    29 #include "../SDL_sysvideo.h"
    30 
    31 /* From gx.h, since it's not really C compliant */
    32 
    33 struct GXDisplayProperties
    34 {
    35     DWORD cxWidth;
    36     DWORD cyHeight;             // notice lack of 'th' in the word height.
    37     long cbxPitch;              // number of bytes to move right one x pixel - can be negative.
    38     long cbyPitch;              // number of bytes to move down one y pixel - can be negative.
    39     long cBPP;                  // # of bits in each pixel
    40     DWORD ffFormat;             // format flags.
    41 };
    42 
    43 struct GXKeyList
    44 {
    45     short vkUp;                 // key for up
    46     POINT ptUp;                 // x,y position of key/button.  Not on screen but in screen coordinates.
    47     short vkDown;
    48     POINT ptDown;
    49     short vkLeft;
    50     POINT ptLeft;
    51     short vkRight;
    52     POINT ptRight;
    53     short vkA;
    54     POINT ptA;
    55     short vkB;
    56     POINT ptB;
    57     short vkC;
    58     POINT ptC;
    59     short vkStart;
    60     POINT ptStart;
    61 };
    62 
    63 typedef int (*PFNGXOpenDisplay) (HWND hWnd, DWORD dwFlags);
    64 typedef int (*PFNGXCloseDisplay) ();
    65 typedef void *(*PFNGXBeginDraw) ();
    66 typedef int (*PFNGXEndDraw) ();
    67 typedef int (*PFNGXOpenInput) ();
    68 typedef int (*PFNGXCloseInput) ();
    69 typedef struct GXDisplayProperties (*PFNGXGetDisplayProperties) ();
    70 typedef struct GXKeyList (*PFNGXGetDefaultKeys) (int iOptions);
    71 typedef int (*PFNGXSuspend) ();
    72 typedef int (*PFNGXResume) ();
    73 typedef int (*PFNGXSetViewport) (DWORD dwTop, DWORD dwHeight,
    74                                  DWORD dwReserved1, DWORD dwReserved2);
    75 typedef BOOL(*PFNGXIsDisplayDRAMBuffer) ();
    76 
    77 struct GapiFunc
    78 {
    79     PFNGXOpenDisplay GXOpenDisplay;
    80     PFNGXCloseDisplay GXCloseDisplay;
    81     PFNGXBeginDraw GXBeginDraw;
    82     PFNGXEndDraw GXEndDraw;
    83     PFNGXOpenInput GXOpenInput;
    84     PFNGXCloseInput GXCloseInput;
    85     PFNGXGetDisplayProperties GXGetDisplayProperties;
    86     PFNGXGetDefaultKeys GXGetDefaultKeys;
    87     PFNGXSuspend GXSuspend;
    88     PFNGXResume GXResume;
    89     PFNGXSetViewport GXSetViewport;
    90     PFNGXIsDisplayDRAMBuffer GXIsDisplayDRAMBuffer;
    91 };
    92 
    93 #define kfLandscape	0x8     // Screen is rotated 270 degrees
    94 #define kfPalette	0x10    // Pixel values are indexes into a palette
    95 #define kfDirect	0x20    // Pixel values contain actual level information
    96 #define kfDirect555	0x40    // 5 bits each for red, green and blue values in a pixel.
    97 #define kfDirect565	0x80    // 5 red bits, 6 green bits and 5 blue bits per pixel
    98 #define kfDirect888	0x100   // 8 bits each for red, green and blue values in a pixel.
    99 #define kfDirect444	0x200   // 4 red, 4 green, 4 blue
   100 #define kfDirectInverted 0x400
   101 
   102 #define GX_FULLSCREEN	0x01    // for OpenDisplay()
   103 #define GX_NORMALKEYS   0x02
   104 #define GX_LANDSCAPEKEYS        0x03
   105 
   106 typedef enum
   107 {
   108     SDL_ORIENTATION_UP,
   109     SDL_ORIENTATION_DOWN,
   110     SDL_ORIENTATION_LEFT,
   111     SDL_ORIENTATION_RIGHT
   112 } SDL_ScreenOrientation;
   113 
   114 /* GAPI video mode */
   115 typedef enum
   116 {
   117     GAPI_NONE = 0,
   118     GAPI_DIRECT_565,
   119     GAPI_DIRECT_555,
   120     GAPI_MONO,
   121     GAPI_PALETTE
   122 } GAPIVideoMode;
   123 
   124 /* Hidden "this" pointer for the video functions */
   125 #define _THIS	SDL_VideoDevice *this
   126 
   127 typedef unsigned short PIXEL;
   128 
   129 /* Private display data 
   130    begin with DIB private structure to allow DIB events code sharing
   131 */
   132 struct SDL_PrivateVideoData
   133 {
   134     HBITMAP screen_bmp;
   135     HPALETTE screen_pal;
   136 
   137 #define NUM_MODELISTS	4       /* 8, 16, 24, and 32 bits-per-pixel */
   138     int SDL_nummodes[NUM_MODELISTS];
   139     SDL_Rect **SDL_modelist[NUM_MODELISTS];
   140     enum SDL_ScreenOrientation userOrientation;
   141     int invert;
   142     char hiresFix;              // using hires mode without defining hires resource
   143 // --------------
   144     int useGXOpenDisplay;       /* use GXOpenDispplay */
   145     int w, h;
   146     enum SDL_ScreenOrientation gapiOrientation;
   147 
   148     void *buffer;               // may be 8, 16, 24, 32 bpp
   149     PIXEL *videoMem;
   150     BOOL needUpdate;
   151     struct GXKeyList keyList;
   152     struct GapiFunc gxFunc;
   153     struct GXDisplayProperties gxProperties;
   154     enum GAPIVideoMode videoMode;
   155     int colorscale;
   156     int dstLineStep;            // in bytes
   157     int dstPixelStep;           // in bytes
   158     int startOffset;            // in bytes
   159     int useVga;
   160     int suspended;              // do not pu anything into video memory
   161 };
   162 
   163 
   164 #define gapiBuffer this->hidden->buffer
   165 #define gapi this->hidden
   166 
   167 #endif /* _SDL_gapivideo_h */
   168 /* vi: set ts=4 sw=4 expandtab: */