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