comparison src/video/SDL_sysvideo.h @ 1670:eef792d31de8 SDL-1.3

Work in progress. :)
author Sam Lantinga <slouken@libsdl.org>
date Wed, 07 Jun 2006 16:10:28 +0000
parents 9857d21967bb
children 89f7510fe17a
comparison
equal deleted inserted replaced
1669:9857d21967bb 1670:eef792d31de8
37 #include "SDL_opengl.h" 37 #include "SDL_opengl.h"
38 #endif /* SDL_VIDEO_OPENGL */ 38 #endif /* SDL_VIDEO_OPENGL */
39 39
40 /* The SDL video driver */ 40 /* The SDL video driver */
41 41
42 typedef struct SDL_Window SDL_Window;
43 typedef struct SDL_Texture SDL_Texture;
44 typedef struct SDL_Renderer SDL_Renderer;
45 typedef struct SDL_RenderDriver SDL_RenderDriver;
46 typedef struct SDL_VideoDisplay SDL_VideoDisplay;
47 typedef struct SDL_VideoDevice SDL_VideoDevice;
48
49 /* Define the SDL texture structure */
50 struct SDL_Texture
51 {
52 Uint32 id;
53
54 Uint32 format; /**< The pixel format of the texture */
55 int access; /**< SDL_TextureAccess */
56 int w; /**< The width of the texture */
57 int h; /**< The height of the texture */
58
59 SDL_Renderer *renderer;
60
61 void *driverdata; /**< Driver specific texture representation */
62
63 SDL_Texture *next;
64 };
65
66 /* Define the SDL renderer structure */
67 struct SDL_Renderer
68 {
69 int (*CreateTexture) (SDL_Texture * texture);
70 int (*UpdateTexture) (SDL_Texture * texture, SDL_Rect * rect,
71 const void *pixels, int pitch);
72 int (*LockTexture) (SDL_Texture * texture, SDL_Rect * rect, int markDirty,
73 void **pixels, int *pitch);
74 void (*UnlockTexture) (SDL_Texture * texture);
75 void (*DirtyTexture) (SDL_Texture * texture, int numrects,
76 SDL_Rect * rects);
77 void (*SelectRenderTexture) (SDL_Texture * texture);
78 void (*RenderFill) (SDL_Rect * rect, Uint32 color);
79 int (*RenderCopy) (SDL_Texture * texture, SDL_Rect * srcrect,
80 SDL_Rect * dstrect, int blendMode, int scaleMode);
81 int (*RenderReadPixels) (SDL_Rect * rect, void *pixels, int pitch);
82 int (*RenderWritePixels) (SDL_Rect * rect, const void *pixels, int pitch);
83 void (*RenderPresent) (void);
84 void (*DestroyTexture) (SDL_Texture * texture);
85
86 void (*DestroyRenderer) (SDL_Renderer * renderer);
87
88 /* The current renderer info */
89 SDL_RendererInfo info;
90
91 /* The window associated with the renderer */
92 SDL_Window *window;
93
94 void *driverdata;
95 };
96
97 /* Define the SDL render driver structure */
98 struct SDL_RenderDriver
99 {
100 SDL_Renderer *(*CreateRenderer) (SDL_Window * window, Uint32 flags);
101
102 /* Info about the renderer capabilities */
103 SDL_RendererInfo info;
104 };
105
42 /* Define the SDL window structure, corresponding to toplevel windows */ 106 /* Define the SDL window structure, corresponding to toplevel windows */
43 typedef struct SDL_Window SDL_Window;
44
45 struct SDL_Window 107 struct SDL_Window
46 { 108 {
47 Uint32 id; 109 Uint32 id;
48 110
49 char *title; 111 char *title;
50 int x, y; 112 int x, y;
51 int w, h; 113 int w, h;
52 Uint32 flags; 114 Uint32 flags;
53 115
54 SDL_Surface *surface;
55 SDL_Surface *shadow;
56 Uint16 *gamma; 116 Uint16 *gamma;
117
118 SDL_Renderer *renderer;
57 119
58 void *userdata; 120 void *userdata;
59 void *driverdata; 121 void *driverdata;
60 }; 122 };
61 123
62 /* Define the SDL display structure 124 /* Define the SDL display structure
63 This corresponds to physical monitors attached to the system. 125 This corresponds to physical monitors attached to the system.
64 */ 126 */
65 typedef struct SDL_VideoDisplay 127 struct SDL_VideoDisplay
66 { 128 {
67 int num_display_modes; 129 int num_display_modes;
68 SDL_DisplayMode *display_modes; 130 SDL_DisplayMode *display_modes;
69 SDL_DisplayMode desktop_mode; 131 SDL_DisplayMode desktop_mode;
70 SDL_DisplayMode current_mode; 132 SDL_DisplayMode current_mode;
71 133
72 int max_windows; 134 int num_render_drivers;
135 SDL_RenderDriver *render_drivers;
136
73 int num_windows; 137 int num_windows;
74 SDL_Window *windows; 138 SDL_Window *windows;
75 139
140 SDL_Renderer *current_renderer;
141
142 /* The hash list of textures */
143 SDL_Texture *textures[64];
144
76 void *driverdata; 145 void *driverdata;
77 } SDL_VideoDisplay; 146 };
78
79 typedef struct SDL_VideoDevice SDL_VideoDevice;
80 147
81 /* Define the SDL video driver structure */ 148 /* Define the SDL video driver structure */
82 #define _THIS SDL_VideoDevice *_this 149 #define _THIS SDL_VideoDevice *_this
83 150
84 struct SDL_VideoDevice 151 struct SDL_VideoDevice
102 * so when the display mode is changed, all existing windows 169 * so when the display mode is changed, all existing windows
103 * should have their data updated accordingly, including the 170 * should have their data updated accordingly, including the
104 * display surfaces associated with them. 171 * display surfaces associated with them.
105 */ 172 */
106 int (*SetDisplayMode) (_THIS, const SDL_DisplayMode * mode); 173 int (*SetDisplayMode) (_THIS, const SDL_DisplayMode * mode);
174
175 /* Sets the color entries { firstcolor .. (firstcolor+ncolors-1) }
176 of the physical palette to those in 'colors'. The return value
177 is 0 if all entries could be set properly or -1 otherwise.
178 */
179 int (*SetDisplayColors) (_THIS, int firstcolor, int ncolors,
180 SDL_Color * colors);
107 181
108 /* * * */ 182 /* * * */
109 /* Window functions 183 /* Window functions
110 */ 184 */
111 int (*CreateWindow) (_THIS, SDL_Window * window); 185 int (*CreateWindow) (_THIS, SDL_Window * window);
120 void (*MinimizeWindow) (_THIS, SDL_Window * window); 194 void (*MinimizeWindow) (_THIS, SDL_Window * window);
121 void (*RestoreWindow) (_THIS, SDL_Window * window); 195 void (*RestoreWindow) (_THIS, SDL_Window * window);
122 void (*SetWindowGrab) (_THIS, SDL_Window * window); 196 void (*SetWindowGrab) (_THIS, SDL_Window * window);
123 void (*DestroyWindow) (_THIS, SDL_Window * window); 197 void (*DestroyWindow) (_THIS, SDL_Window * window);
124 198
125 void (*CreateWindowSurface) (_THIS, SDL_Window * window, Uint32 flags);
126 void (*UpdateWindowSurface) (_THIS, SDL_Window * window, int numrects,
127 SDL_Rect * rects);
128 void (*FlipWindowSurface) (_THIS, SDL_Window * window);
129
130 /* Sets the color entries { firstcolor .. (firstcolor+ncolors-1) }
131 of the physical palette to those in 'colors'. If the device is
132 using a software palette (SDL_HWPALETTE not set), then the
133 changes are reflected in the logical palette of the screen
134 as well.
135 The return value is 1 if all entries could be set properly
136 or 0 otherwise.
137 */
138 int (*SetWindowColors) (_THIS, SDL_Window * window,
139 int firstcolor, int ncolors, SDL_Color * colors);
140
141 /* Get some platform dependent window information */ 199 /* Get some platform dependent window information */
142 SDL_bool(*GetWindowWMInfo) (_THIS, SDL_Window * window, 200 SDL_bool(*GetWindowWMInfo) (_THIS, SDL_Window * window,
143 SDL_SysWMinfo * info); 201 SDL_SysWMinfo * info);
144 202
145 /* Create a YUV video surface (possibly overlay) of the given 203 /* Create a YUV video surface (possibly overlay) of the given
154 */ 212 */
155 void (*VideoQuit) (_THIS); 213 void (*VideoQuit) (_THIS);
156 214
157 /* * * */ 215 /* * * */
158 /* Hardware acceleration functions */ 216 /* Hardware acceleration functions */
159
160 /* Information about the video hardware */
161 SDL_VideoInfo info;
162 217
163 /* The pixel format used when SDL_CreateRGBSurface creates SDL_HWSURFACEs with alpha */ 218 /* The pixel format used when SDL_CreateRGBSurface creates SDL_HWSURFACEs with alpha */
164 SDL_PixelFormat *displayformatalphapixel; 219 SDL_PixelFormat *displayformatalphapixel;
165 220
166 /* Allocates a surface in video memory */ 221 /* Allocates a surface in video memory */
240 /* Cursor manager functions */ 295 /* Cursor manager functions */
241 296
242 /* Free a window manager cursor 297 /* Free a window manager cursor
243 This function can be NULL if CreateWMCursor is also NULL. 298 This function can be NULL if CreateWMCursor is also NULL.
244 */ 299 */
245 void (*FreeWMCursor) (_THIS, WMcursor * cursor); 300 void (*FreeCursor) (_THIS, SDL_Cursor * cursor);
246 301
247 /* If not NULL, create a black/white window manager cursor */ 302 /* If not NULL, create a black/white window manager cursor */
248 WMcursor *(*CreateWMCursor) (_THIS, 303 SDL_Cursor *(*CreateCursor) (_THIS,
249 Uint8 * data, Uint8 * mask, int w, int h, 304 Uint8 * data, Uint8 * mask, int w, int h,
250 int hot_x, int hot_y); 305 int hot_x, int hot_y);
251 306
252 /* Show the specified cursor, or hide if cursor is NULL */ 307 /* Show the specified cursor, or hide if cursor is NULL */
253 int (*ShowWMCursor) (_THIS, WMcursor * cursor); 308 int (*ShowCursor) (_THIS, SDL_Cursor * cursor);
254 309
255 /* Warp the window manager cursor to (x,y) 310 /* Warp the window manager cursor to (x,y)
256 If NULL, a mouse motion event is posted internally. 311 If NULL, a mouse motion event is posted internally.
257 */ 312 */
258 void (*WarpWMCursor) (_THIS, Uint16 x, Uint16 y); 313 void (*WarpCursor) (_THIS, SDL_WindowID windowID, int x, int y);
259 314
260 /* If not NULL, this is called when a mouse motion event occurs */ 315 /* If not NULL, this is called when a mouse motion event occurs */
261 void (*MoveWMCursor) (_THIS, int x, int y); 316 void (*MoveCursor) (_THIS, int x, int y);
262 317
263 /* Determine whether the mouse should be in relative mode or not. 318 /* Determine whether the mouse should be in relative mode or not.
264 This function is called when the input grab state or cursor 319 This function is called when the input grab state or cursor
265 visibility state changes. 320 visibility state changes.
266 If the cursor is not visible, and the input is grabbed, the 321 If the cursor is not visible, and the input is grabbed, the
281 /* * * */ 336 /* * * */
282 /* Data common to all drivers */ 337 /* Data common to all drivers */
283 int num_displays; 338 int num_displays;
284 SDL_VideoDisplay *displays; 339 SDL_VideoDisplay *displays;
285 int current_display; 340 int current_display;
286 Uint32 next_window_id; 341 Uint32 next_object_id;
287 342
288 /* Driver information flags */ 343 /* Driver information flags */
289 344
290 /* * * */ 345 /* * * */
291 /* Data used by the GL drivers */ 346 /* Data used by the GL drivers */
426 extern VideoBootStrap glSDL_bootstrap; 481 extern VideoBootStrap glSDL_bootstrap;
427 #endif 482 #endif
428 483
429 #define SDL_CurrentDisplay (_this->displays[_this->current_display]) 484 #define SDL_CurrentDisplay (_this->displays[_this->current_display])
430 #define SDL_CurrentWindow (SDL_CurrentDisplay.windows[0]) 485 #define SDL_CurrentWindow (SDL_CurrentDisplay.windows[0])
431 #define SDL_VideoSurface ((_this && SDL_CurrentDisplay.num_windows > 0) ? SDL_CurrentWindow.surface : NULL)
432 #define SDL_ShadowSurface ((_this && SDL_CurrentDisplay.num_windows > 0) ? SDL_CurrentWindow.shadow : NULL)
433 #define SDL_PublicSurface (SDL_ShadowSurface ? SDL_ShadowSurface : SDL_VideoSurface)
434 486
435 extern SDL_VideoDevice *SDL_GetVideoDevice(); 487 extern SDL_VideoDevice *SDL_GetVideoDevice();
436 extern void SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode); 488 extern void SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode);
437 extern void SDL_AddVideoDisplay(const SDL_VideoDisplay * display); 489 extern void SDL_AddVideoDisplay(const SDL_VideoDisplay * display);
438 extern void SDL_AddDisplayMode(int display, const SDL_DisplayMode * mode); 490 extern void SDL_AddDisplayMode(int displayIndex,
439 extern SDL_Window *SDL_GetWindowFromSurface(SDL_Surface * surface); 491 const SDL_DisplayMode * mode);
492 extern void SDL_AddRenderDriver(int displayIndex,
493 const SDL_RenderDriver * driver);
440 494
441 #endif /* _SDL_sysvideo_h */ 495 #endif /* _SDL_sysvideo_h */
442 496
443 /* vi: set ts=4 sw=4 expandtab: */ 497 /* vi: set ts=4 sw=4 expandtab: */