src/video/SDL_sysvideo.h
author Sam Lantinga <slouken@libsdl.org>
Fri, 14 Dec 2001 12:38:15 +0000
changeset 252 e8157fcb3114
parent 173 83018110dce8
child 281 c5010ab8ba35
permissions -rw-r--r--
Updated the source with the correct e-mail address
slouken@0
     1
/*
slouken@0
     2
    SDL - Simple DirectMedia Layer
slouken@0
     3
    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
slouken@0
     4
slouken@0
     5
    This library is free software; you can redistribute it and/or
slouken@0
     6
    modify it under the terms of the GNU Library General Public
slouken@0
     7
    License as published by the Free Software Foundation; either
slouken@0
     8
    version 2 of the License, or (at your option) any later version.
slouken@0
     9
slouken@0
    10
    This library is distributed in the hope that it will be useful,
slouken@0
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@0
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@0
    13
    Library General Public License for more details.
slouken@0
    14
slouken@0
    15
    You should have received a copy of the GNU Library General Public
slouken@0
    16
    License along with this library; if not, write to the Free
slouken@0
    17
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
slouken@0
    18
slouken@0
    19
    Sam Lantinga
slouken@252
    20
    slouken@libsdl.org
slouken@0
    21
*/
slouken@0
    22
slouken@0
    23
#ifdef SAVE_RCSID
slouken@0
    24
static char rcsid =
slouken@0
    25
 "@(#) $Id$";
slouken@0
    26
#endif
slouken@0
    27
slouken@0
    28
#ifndef _SDL_sysvideo_h
slouken@0
    29
#define _SDL_sysvideo_h
slouken@0
    30
slouken@0
    31
#include "SDL_mouse.h"
slouken@0
    32
#define SDL_PROTOTYPES_ONLY
slouken@0
    33
#include "SDL_syswm.h"
slouken@0
    34
#undef SDL_PROTOTYPES_ONLY
slouken@0
    35
slouken@0
    36
/* This file prototypes the video driver implementation.
slouken@0
    37
   This is designed to be easily converted to C++ in the future.
slouken@0
    38
 */
slouken@0
    39
slouken@0
    40
/* OpenGL is pretty much available on all Windows systems */
slouken@0
    41
#ifdef WIN32
slouken@0
    42
#ifndef _WIN32_WCE
slouken@0
    43
#define HAVE_OPENGL
slouken@0
    44
#endif
slouken@0
    45
#include <windows.h>
slouken@0
    46
#endif
slouken@0
    47
slouken@0
    48
#ifdef HAVE_OPENGL
slouken@0
    49
#ifdef MACOSX
slouken@0
    50
#include <OpenGL/gl.h>  /* OpenGL.framework */
slouken@0
    51
#else
slouken@0
    52
#include <GL/gl.h>
slouken@0
    53
#endif /* MACOSX */
slouken@0
    54
#endif /* HAVE_OPENGL */
slouken@0
    55
slouken@0
    56
/* The SDL video driver */
slouken@0
    57
typedef struct SDL_VideoDevice SDL_VideoDevice;
slouken@0
    58
slouken@0
    59
/* Define the SDL video driver structure */
slouken@0
    60
#define _THIS	SDL_VideoDevice *_this
slouken@0
    61
#ifndef _STATUS
slouken@0
    62
#define _STATUS	SDL_status *status
slouken@0
    63
#endif
slouken@0
    64
struct SDL_VideoDevice {
slouken@0
    65
	/* * * */
slouken@47
    66
	/* The name of this video driver */
slouken@0
    67
	const char *name;
slouken@0
    68
slouken@0
    69
	/* * * */
slouken@0
    70
	/* Initialization/Query functions */
slouken@0
    71
slouken@0
    72
	/* Initialize the native video subsystem, filling 'vformat' with the 
slouken@0
    73
	   "best" display pixel format, returning 0 or -1 if there's an error.
slouken@0
    74
	 */
slouken@0
    75
	int (*VideoInit)(_THIS, SDL_PixelFormat *vformat);
slouken@0
    76
slouken@0
    77
	/* List the available video modes for the given pixel format, sorted
slouken@0
    78
	   from largest to smallest.
slouken@0
    79
	 */
slouken@0
    80
	SDL_Rect **(*ListModes)(_THIS, SDL_PixelFormat *format, Uint32 flags);
slouken@0
    81
slouken@0
    82
	/* Set the requested video mode, returning a surface which will be
slouken@0
    83
	   set to the SDL_VideoSurface.  The width and height will already
slouken@0
    84
	   be verified by ListModes(), and the video subsystem is free to
slouken@0
    85
	   set the mode to a supported bit depth different from the one
slouken@0
    86
	   specified -- the desired bpp will be emulated with a shadow
slouken@0
    87
	   surface if necessary.  If a new mode is returned, this function
slouken@0
    88
	   should take care of cleaning up the current mode.
slouken@0
    89
	 */
slouken@0
    90
	SDL_Surface *(*SetVideoMode)(_THIS, SDL_Surface *current,
slouken@0
    91
				int width, int height, int bpp, Uint32 flags);
slouken@0
    92
slouken@0
    93
	/* Toggle the fullscreen mode */
slouken@0
    94
	int (*ToggleFullScreen)(_THIS, int on);
slouken@0
    95
slouken@0
    96
	/* This is called after the video mode has been set, to get the
slouken@0
    97
	   initial mouse state.  It should queue events as necessary to
slouken@0
    98
	   properly represent the current mouse focus and position.
slouken@0
    99
	 */
slouken@0
   100
	void (*UpdateMouse)(_THIS);
slouken@0
   101
slouken@0
   102
	/* Create a YUV video surface (possibly overlay) of the given
slouken@0
   103
	   format.  The hardware should be able to perform at least 2x
slouken@0
   104
	   scaling on display.
slouken@0
   105
	 */
slouken@0
   106
	SDL_Overlay *(*CreateYUVOverlay)(_THIS, int width, int height,
slouken@0
   107
	                                 Uint32 format, SDL_Surface *display);
slouken@0
   108
slouken@0
   109
        /* Sets the color entries { firstcolor .. (firstcolor+ncolors-1) }
slouken@0
   110
	   of the physical palette to those in 'colors'. If the device is
slouken@0
   111
	   using a software palette (SDL_HWPALETTE not set), then the
slouken@0
   112
	   changes are reflected in the logical palette of the screen
slouken@0
   113
	   as well.
slouken@0
   114
	   The return value is 1 if all entries could be set properly
slouken@0
   115
	   or 0 otherwise.
slouken@0
   116
	*/
slouken@0
   117
	int (*SetColors)(_THIS, int firstcolor, int ncolors,
slouken@0
   118
			 SDL_Color *colors);
slouken@0
   119
slouken@0
   120
	/* This pointer should exist in the native video subsystem and should
slouken@0
   121
	   point to an appropriate update function for the current video mode
slouken@0
   122
	 */
slouken@0
   123
	void (*UpdateRects)(_THIS, int numrects, SDL_Rect *rects);
slouken@0
   124
slouken@0
   125
	/* Reverse the effects VideoInit() -- called if VideoInit() fails
slouken@0
   126
	   or if the application is shutting down the video subsystem.
slouken@0
   127
	*/
slouken@0
   128
	void (*VideoQuit)(_THIS);
slouken@0
   129
slouken@0
   130
	/* * * */
slouken@0
   131
	/* Hardware acceleration functions */
slouken@0
   132
slouken@0
   133
	/* Information about the video hardware */
slouken@0
   134
	SDL_VideoInfo info;
slouken@0
   135
slouken@0
   136
	/* Allocates a surface in video memory */
slouken@0
   137
	int (*AllocHWSurface)(_THIS, SDL_Surface *surface);
slouken@0
   138
slouken@0
   139
	/* Sets the hardware accelerated blit function, if any, based
slouken@0
   140
	   on the current flags of the surface (colorkey, alpha, etc.)
slouken@0
   141
	 */
slouken@0
   142
	int (*CheckHWBlit)(_THIS, SDL_Surface *src, SDL_Surface *dst);
slouken@0
   143
slouken@0
   144
	/* Fills a surface rectangle with the given color */
slouken@0
   145
	int (*FillHWRect)(_THIS, SDL_Surface *dst, SDL_Rect *rect, Uint32 color);
slouken@0
   146
slouken@0
   147
	/* Sets video mem colorkey and accelerated blit function */
slouken@0
   148
	int (*SetHWColorKey)(_THIS, SDL_Surface *surface, Uint32 key);
slouken@0
   149
slouken@0
   150
	/* Sets per surface hardware alpha value */
slouken@0
   151
	int (*SetHWAlpha)(_THIS, SDL_Surface *surface, Uint8 value);
slouken@0
   152
slouken@0
   153
	/* Returns a readable/writable surface */
slouken@0
   154
	int (*LockHWSurface)(_THIS, SDL_Surface *surface);
slouken@0
   155
	void (*UnlockHWSurface)(_THIS, SDL_Surface *surface);
slouken@0
   156
slouken@0
   157
	/* Performs hardware flipping */
slouken@0
   158
	int (*FlipHWSurface)(_THIS, SDL_Surface *surface);
slouken@0
   159
slouken@0
   160
	/* Frees a previously allocated video surface */
slouken@0
   161
	void (*FreeHWSurface)(_THIS, SDL_Surface *surface);
slouken@0
   162
slouken@0
   163
	/* * * */
slouken@0
   164
	/* Gamma support */
slouken@0
   165
slouken@0
   166
	Uint16 *gamma;
slouken@0
   167
slouken@0
   168
	/* Set the gamma correction directly (emulated with gamma ramps) */
slouken@0
   169
	int (*SetGamma)(_THIS, float red, float green, float blue);
slouken@0
   170
slouken@0
   171
	/* Get the gamma correction directly (emulated with gamma ramps) */
slouken@0
   172
	int (*GetGamma)(_THIS, float *red, float *green, float *blue);
slouken@0
   173
slouken@0
   174
	/* Set the gamma ramp */
slouken@0
   175
	int (*SetGammaRamp)(_THIS, Uint16 *ramp);
slouken@0
   176
slouken@0
   177
	/* Get the gamma ramp */
slouken@0
   178
	int (*GetGammaRamp)(_THIS, Uint16 *ramp);
slouken@0
   179
slouken@0
   180
	/* * * */
slouken@0
   181
	/* OpenGL support */
slouken@0
   182
slouken@0
   183
	/* Sets the dll to use for OpenGL and loads it */
slouken@0
   184
	int (*GL_LoadLibrary)(_THIS, const char *path);
slouken@0
   185
slouken@0
   186
	/* Retrieves the address of a function in the gl library */
slouken@0
   187
	void* (*GL_GetProcAddress)(_THIS, const char *proc);
slouken@0
   188
slouken@0
   189
        /* Get attribute information from the windowing system. */
slouken@0
   190
        int (*GL_GetAttribute)(_THIS, SDL_GLattr attrib, int* value);
slouken@0
   191
slouken@0
   192
        /* Make the context associated with this driver current */
slouken@0
   193
        int (*GL_MakeCurrent)(_THIS);
slouken@0
   194
slouken@0
   195
	/* Swap the current buffers in double buffer mode. */
slouken@0
   196
	void (*GL_SwapBuffers)(_THIS);
slouken@0
   197
slouken@0
   198
  	/* OpenGL functions for SDL_OPENGLBLIT */
slouken@0
   199
#ifdef HAVE_OPENGL
slouken@0
   200
#ifndef WIN32
slouken@0
   201
#define WINAPI
slouken@0
   202
#endif
slouken@0
   203
#define SDL_PROC(ret,func,params) ret (WINAPI *func) params;
slouken@0
   204
#include "SDL_glfuncs.h"
slouken@0
   205
#undef SDL_PROC
slouken@0
   206
slouken@0
   207
	/* Texture id */
slouken@0
   208
	GLuint texture;
slouken@0
   209
#endif
slouken@0
   210
	int is_32bit;
slouken@0
   211
 
slouken@0
   212
	/* * * */
slouken@0
   213
	/* Window manager functions */
slouken@0
   214
slouken@0
   215
	/* Set the title and icon text */
slouken@0
   216
	void (*SetCaption)(_THIS, const char *title, const char *icon);
slouken@0
   217
slouken@0
   218
	/* Set the window icon image */
slouken@0
   219
	void (*SetIcon)(_THIS, SDL_Surface *icon, Uint8 *mask);
slouken@0
   220
slouken@0
   221
	/* Iconify the window.
slouken@0
   222
	   This function returns 1 if there is a window manager and the
slouken@0
   223
	   window was actually iconified, it returns 0 otherwise.
slouken@0
   224
	*/
slouken@0
   225
	int (*IconifyWindow)(_THIS);
slouken@0
   226
slouken@0
   227
	/* Grab or ungrab keyboard and mouse input */
slouken@0
   228
	SDL_GrabMode (*GrabInput)(_THIS, SDL_GrabMode mode);
slouken@0
   229
slouken@0
   230
	/* Get some platform dependent window information */
slouken@0
   231
	int (*GetWMInfo)(_THIS, SDL_SysWMinfo *info);
slouken@0
   232
slouken@0
   233
	/* * * */
slouken@0
   234
	/* Cursor manager functions */
slouken@0
   235
slouken@0
   236
	/* Free a window manager cursor
slouken@0
   237
	   This function can be NULL if CreateWMCursor is also NULL.
slouken@0
   238
	 */
slouken@0
   239
	void (*FreeWMCursor)(_THIS, WMcursor *cursor);
slouken@0
   240
slouken@0
   241
	/* If not NULL, create a black/white window manager cursor */
slouken@0
   242
	WMcursor *(*CreateWMCursor)(_THIS,
slouken@0
   243
		Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y);
slouken@0
   244
slouken@0
   245
	/* Show the specified cursor, or hide if cursor is NULL */
slouken@0
   246
	int (*ShowWMCursor)(_THIS, WMcursor *cursor);
slouken@0
   247
slouken@0
   248
	/* Warp the window manager cursor to (x,y)
slouken@0
   249
	   If NULL, a mouse motion event is posted internally.
slouken@0
   250
	 */
slouken@0
   251
	void (*WarpWMCursor)(_THIS, Uint16 x, Uint16 y);
slouken@0
   252
slouken@0
   253
	/* If not NULL, this is called when a mouse motion event occurs */
slouken@0
   254
	void (*MoveWMCursor)(_THIS, int x, int y);
slouken@0
   255
slouken@0
   256
	/* Determine whether the mouse should be in relative mode or not.
slouken@0
   257
	   This function is called when the input grab state or cursor
slouken@0
   258
	   visibility state changes.
slouken@0
   259
	   If the cursor is not visible, and the input is grabbed, the
slouken@0
   260
	   driver can place the mouse in relative mode, which may result
slouken@0
   261
	   in higher accuracy sampling of the pointer motion.
slouken@0
   262
	*/
slouken@0
   263
	void (*CheckMouseMode)(_THIS);
slouken@0
   264
slouken@0
   265
	/* * * */
slouken@0
   266
	/* Event manager functions */
slouken@0
   267
slouken@0
   268
	/* Initialize keyboard mapping for this driver */
slouken@0
   269
	void (*InitOSKeymap)(_THIS);
slouken@0
   270
slouken@0
   271
	/* Handle any queued OS events */
slouken@0
   272
	void (*PumpEvents)(_THIS);
slouken@0
   273
slouken@0
   274
	/* * * */
slouken@0
   275
	/* Data common to all drivers */
slouken@0
   276
	SDL_Surface *screen;
slouken@0
   277
	SDL_Surface *shadow;
slouken@0
   278
	SDL_Surface *visible;
slouken@0
   279
        SDL_Palette *physpal;	/* physical palette, if != logical palette */
slouken@0
   280
        SDL_Color *gammacols;	/* gamma-corrected colours, or NULL */
slouken@0
   281
	char *wm_title;
slouken@0
   282
	char *wm_icon;
slouken@0
   283
	int offset_x;
slouken@0
   284
	int offset_y;
slouken@0
   285
	SDL_GrabMode input_grab;
slouken@0
   286
slouken@0
   287
	/* Driver information flags */
slouken@0
   288
	int handles_any_size;	/* Driver handles any size video mode */
slouken@0
   289
slouken@0
   290
	/* * * */
slouken@0
   291
	/* Data used by the GL drivers */
slouken@0
   292
	struct {
slouken@0
   293
		int red_size;
slouken@0
   294
		int green_size;
slouken@0
   295
		int blue_size;
slouken@0
   296
		int alpha_size;
slouken@0
   297
		int depth_size;
slouken@0
   298
	        int buffer_size;
slouken@0
   299
		int stencil_size;
slouken@0
   300
		int double_buffer;
slouken@0
   301
                int accum_red_size;
slouken@0
   302
                int accum_green_size;
slouken@0
   303
                int accum_blue_size;
slouken@0
   304
                int accum_alpha_size;
slouken@0
   305
		int driver_loaded;
slouken@0
   306
		char driver_path[256];
slouken@0
   307
		void* dll_handle;
slouken@0
   308
	} gl_config;
slouken@0
   309
slouken@0
   310
	/* * * */
slouken@0
   311
	/* Data private to this driver */
slouken@0
   312
	struct SDL_PrivateVideoData *hidden;
slouken@0
   313
	struct SDL_PrivateGLData *gl_data;
slouken@0
   314
slouken@0
   315
	/* * * */
slouken@0
   316
	/* The function used to dispose of this structure */
slouken@0
   317
	void (*free)(_THIS);
slouken@0
   318
};
slouken@0
   319
#undef _THIS
slouken@0
   320
slouken@0
   321
typedef struct VideoBootStrap {
slouken@0
   322
	const char *name;
slouken@0
   323
	const char *desc;
slouken@0
   324
	int (*available)(void);
slouken@0
   325
	SDL_VideoDevice *(*create)(int devindex);
slouken@0
   326
} VideoBootStrap;
slouken@0
   327
slouken@0
   328
#ifdef ENABLE_X11
slouken@0
   329
extern VideoBootStrap X11_bootstrap;
slouken@0
   330
#endif
slouken@0
   331
#ifdef ENABLE_DGA
slouken@0
   332
extern VideoBootStrap DGA_bootstrap;
slouken@0
   333
#endif
slouken@30
   334
#ifdef ENABLE_NANOX
slouken@30
   335
extern VideoBootStrap NX_bootstrap;
slouken@30
   336
#endif
slouken@0
   337
#ifdef ENABLE_FBCON
slouken@0
   338
extern VideoBootStrap FBCON_bootstrap;
slouken@0
   339
#endif
slouken@167
   340
#ifdef ENABLE_DIRECTFB
slouken@167
   341
extern VideoBootStrap DirectFB_bootstrap;
slouken@167
   342
#endif
slouken@0
   343
#ifdef ENABLE_PS2GS
slouken@0
   344
extern VideoBootStrap PS2GS_bootstrap;
slouken@0
   345
#endif
slouken@0
   346
#ifdef ENABLE_GGI
slouken@0
   347
extern VideoBootStrap GGI_bootstrap;
slouken@0
   348
#endif
slouken@75
   349
#ifdef ENABLE_VGL
slouken@75
   350
extern VideoBootStrap VGL_bootstrap;
slouken@75
   351
#endif
slouken@0
   352
#ifdef ENABLE_SVGALIB
slouken@0
   353
extern VideoBootStrap SVGALIB_bootstrap;
slouken@0
   354
#endif
slouken@0
   355
#ifdef ENABLE_AALIB
slouken@0
   356
extern VideoBootStrap AALIB_bootstrap;
slouken@0
   357
#endif
slouken@0
   358
#ifdef ENABLE_WINDIB
slouken@0
   359
extern VideoBootStrap WINDIB_bootstrap;
slouken@0
   360
#endif
slouken@0
   361
#ifdef ENABLE_DIRECTX
slouken@0
   362
extern VideoBootStrap DIRECTX_bootstrap;
slouken@0
   363
#endif
slouken@0
   364
#ifdef ENABLE_BWINDOW
slouken@0
   365
extern VideoBootStrap BWINDOW_bootstrap;
slouken@0
   366
#endif
slouken@0
   367
/* MacOS X gets the proper defines from configure */
slouken@0
   368
#if defined(macintosh) && !defined(MACOSX)
slouken@0
   369
#define ENABLE_TOOLBOX
slouken@0
   370
#if !TARGET_API_MAC_CARBON
slouken@0
   371
#define ENABLE_DRAWSPROCKET
slouken@0
   372
#endif
slouken@0
   373
#endif
slouken@0
   374
#ifdef ENABLE_TOOLBOX
slouken@0
   375
extern VideoBootStrap TOOLBOX_bootstrap;
slouken@0
   376
#endif
slouken@0
   377
#ifdef ENABLE_DRAWSPROCKET
slouken@0
   378
extern VideoBootStrap DSp_bootstrap;
slouken@0
   379
#endif
slouken@47
   380
#ifdef ENABLE_QUARTZ
slouken@47
   381
extern VideoBootStrap QZ_bootstrap;
slouken@47
   382
#endif
slouken@0
   383
#ifdef ENABLE_CYBERGRAPHICS
slouken@0
   384
extern VideoBootStrap CGX_bootstrap;
slouken@0
   385
#endif
slouken@173
   386
#ifdef ENABLE_PHOTON
slouken@173
   387
extern VideoBootStrap ph_bootstrap;
slouken@173
   388
#endif
slouken@173
   389
#ifdef ENABLE_EPOC
slouken@173
   390
extern VideoBootStrap EPOC_bootstrap;
slouken@173
   391
#endif
slouken@173
   392
#ifdef ENABLE_DUMMYVIDEO
slouken@173
   393
extern VideoBootStrap DUMMY_bootstrap;
slouken@173
   394
#endif
slouken@0
   395
/* This is the current video device */
slouken@0
   396
extern SDL_VideoDevice *current_video;
slouken@0
   397
slouken@0
   398
#define SDL_VideoSurface	(current_video->screen)
slouken@0
   399
#define SDL_ShadowSurface	(current_video->shadow)
slouken@0
   400
#define SDL_PublicSurface	(current_video->visible)
slouken@0
   401
slouken@0
   402
#endif /* _SDL_sysvideo_h */