问题
I've just started learning SDL2 in Linux. I am reading the very first tutorial from LazyFoo and I see have that code:
//The window we'll be rendering to
SDL_Window* window = NULL;
Where can I find the definition of SDL_Window
in order to read about it ?
回答1:
This structure isn't exposed to user side; SDL_video.h
file contains forward declaration of it:
typedef struct SDL_Window SDL_Window;
Forward declaration means you can only use it as pointer type because actual data layout is hidden from you.
Actual type struct SDL_Window
is currently declared in src/video/SDL_sysvideo.h
(in SDL Source Code:, not in 'Development Libraries:') as:
struct SDL_Window
{
const void *magic;
Uint32 id;
char *title;
SDL_Surface *icon;
int x, y;
int w, h;
int min_w, min_h;
int max_w, max_h;
Uint32 flags;
Uint32 last_fullscreen_flags;
/* Stored position and size for windowed mode */
SDL_Rect windowed;
SDL_DisplayMode fullscreen_mode;
float brightness;
Uint16 *gamma;
Uint16 *saved_gamma; /* (just offset into gamma) */
SDL_Surface *surface;
SDL_bool surface_valid;
SDL_bool is_hiding;
SDL_bool is_destroying;
SDL_WindowShaper *shaper;
SDL_HitTest hit_test;
void *hit_test_data;
SDL_WindowUserData *data;
void *driverdata;
SDL_Window *prev;
SDL_Window *next;
};
However, if you're not developing/debugging SDL, this information is pretty much useless, and, most importantly, can change in any future release. Also most interesting part - pointer to SDL_WindowUserData
- is platform-specific and varies between different OSes and SDL videodrivers.
You should use SDL2 video API instead.
来源:https://stackoverflow.com/questions/32246738/where-can-i-find-the-definition-of-sdl-window