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