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