comparison include/SDL_video.h @ 911:04a403e4ccf5

Date: Mon, 3 May 2004 03:15:01 +0100 From: David Symmonds Subject: SDL Typedef Structs Hi, Thanks for the SDL libraries, I have been using them for about a year now and they are really brilliant. One thing that I have just found whilst using them through C++ (and needing forward declarations) is that when you typedef structs you sometimes use typedef struct Name { ... }Name; e.g. SDL_Surface and other times use typedef struct { ... }Name; e.g. SDL_Rect The first type works fine, when I define a header file I can just put 'struct Name;' at the top and use the Name throughout. However, the second type is harder to use in a header, and I haven't found a way yet, other than to include 'SDL.h' in the header file (undesirable). Would there be any harm in changing the definition of SDL_Rect and such like to the second form?
author Sam Lantinga <slouken@libsdl.org>
date Sun, 18 Jul 2004 22:57:40 +0000
parents b8d311d90021
children 5b1cb1e9140d
comparison
equal deleted inserted replaced
910:4ab6d1fd028f 911:04a403e4ccf5
45 /* Transparency definitions: These define alpha as the opacity of a surface */ 45 /* Transparency definitions: These define alpha as the opacity of a surface */
46 #define SDL_ALPHA_OPAQUE 255 46 #define SDL_ALPHA_OPAQUE 255
47 #define SDL_ALPHA_TRANSPARENT 0 47 #define SDL_ALPHA_TRANSPARENT 0
48 48
49 /* Useful data types */ 49 /* Useful data types */
50 typedef struct { 50 typedef struct SDL_Rect {
51 Sint16 x, y; 51 Sint16 x, y;
52 Uint16 w, h; 52 Uint16 w, h;
53 } SDL_Rect; 53 } SDL_Rect;
54 54
55 typedef struct { 55 typedef struct SDL_Color {
56 Uint8 r; 56 Uint8 r;
57 Uint8 g; 57 Uint8 g;
58 Uint8 b; 58 Uint8 b;
59 Uint8 unused; 59 Uint8 unused;
60 } SDL_Color; 60 } SDL_Color;
61 #define SDL_Colour SDL_Color 61 #define SDL_Colour SDL_Color
62 62
63 typedef struct { 63 typedef struct SDL_Palette {
64 int ncolors; 64 int ncolors;
65 SDL_Color *colors; 65 SDL_Color *colors;
66 } SDL_Palette; 66 } SDL_Palette;
67 67
68 /* Everything in the pixel format structure is read-only */ 68 /* Everything in the pixel format structure is read-only */
152 (surface->offset || \ 152 (surface->offset || \
153 ((surface->flags & (SDL_HWSURFACE|SDL_ASYNCBLIT|SDL_RLEACCEL)) != 0)) 153 ((surface->flags & (SDL_HWSURFACE|SDL_ASYNCBLIT|SDL_RLEACCEL)) != 0))
154 154
155 155
156 /* Useful for determining the video hardware capabilities */ 156 /* Useful for determining the video hardware capabilities */
157 typedef struct { 157 typedef struct SDL_VideoInfo {
158 Uint32 hw_available :1; /* Flag: Can you create hardware surfaces? */ 158 Uint32 hw_available :1; /* Flag: Can you create hardware surfaces? */
159 Uint32 wm_available :1; /* Flag: Can you talk to a window manager? */ 159 Uint32 wm_available :1; /* Flag: Can you talk to a window manager? */
160 Uint32 UnusedBits1 :6; 160 Uint32 UnusedBits1 :6;
161 Uint32 UnusedBits2 :1; 161 Uint32 UnusedBits2 :1;
162 Uint32 blit_hw :1; /* Flag: Accelerated blits HW --> HW */ 162 Uint32 blit_hw :1; /* Flag: Accelerated blits HW --> HW */