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