mirror of
https://github.com/joel16/SDL2.git
synced 2024-12-13 14:07:38 +00:00
In general, fill in pointers to structures, rather than return them.
--HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402014
This commit is contained in:
parent
ade506e8d5
commit
a90680c736
@ -237,7 +237,8 @@ extern DECLSPEC int SDLCALL SDL_GetNumAudioDevices(int iscapture);
|
||||
* Must be a value between 0 and (number of audio devices-1).
|
||||
* Only valid after a successfully initializing the audio subsystem.
|
||||
*/
|
||||
extern DECLSPEC const char *SDLCALL SDL_GetAudioDevice(int index, int iscapture);
|
||||
extern DECLSPEC const char *SDLCALL SDL_GetAudioDevice(int index,
|
||||
int iscapture);
|
||||
|
||||
|
||||
/*
|
||||
@ -245,11 +246,14 @@ extern DECLSPEC const char *SDLCALL SDL_GetAudioDevice(int index, int iscapture)
|
||||
* equivalent to SDL_OpenAudio(). Returns 0 on error, a valid device ID
|
||||
* on success.
|
||||
*/
|
||||
extern DECLSPEC SDL_AudioDeviceID SDLCALL SDL_OpenAudioDevice(
|
||||
const char * device,
|
||||
int iscapture,
|
||||
const SDL_AudioSpec * desired,
|
||||
SDL_AudioSpec * obtained);
|
||||
extern DECLSPEC SDL_AudioDeviceID SDLCALL SDL_OpenAudioDevice(const char
|
||||
*device,
|
||||
int iscapture,
|
||||
const
|
||||
SDL_AudioSpec *
|
||||
desired,
|
||||
SDL_AudioSpec *
|
||||
obtained);
|
||||
|
||||
|
||||
|
||||
@ -264,8 +268,8 @@ typedef enum
|
||||
} SDL_audiostatus;
|
||||
extern DECLSPEC SDL_audiostatus SDLCALL SDL_GetAudioStatus(void);
|
||||
|
||||
extern DECLSPEC SDL_audiostatus SDLCALL SDL_GetAudioDeviceStatus(
|
||||
SDL_AudioDeviceID dev);
|
||||
extern DECLSPEC SDL_audiostatus SDLCALL
|
||||
SDL_GetAudioDeviceStatus(SDL_AudioDeviceID dev);
|
||||
|
||||
/*
|
||||
* This function pauses and unpauses the audio callback processing.
|
||||
@ -352,7 +356,8 @@ extern DECLSPEC void SDLCALL SDL_MixAudio(Uint8 * dst, const Uint8 * src,
|
||||
* using the format of audio device 1. Thus it can be used when no audio
|
||||
* device is open at all.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_MixAudioFormat(Uint8 * dst, const Uint8 * src,
|
||||
extern DECLSPEC void SDLCALL SDL_MixAudioFormat(Uint8 * dst,
|
||||
const Uint8 * src,
|
||||
SDL_AudioFormat format,
|
||||
Uint32 len, int volume);
|
||||
|
||||
|
@ -432,7 +432,7 @@ extern DECLSPEC int SDLCALL SDL_GetCurrentVideoDisplay(void);
|
||||
extern DECLSPEC int SDLCALL SDL_GetNumDisplayModes(void);
|
||||
|
||||
/**
|
||||
* \fn const SDL_DisplayMode *SDL_GetDisplayMode(int index)
|
||||
* \fn int SDL_GetDisplayMode(int index, SDL_DisplayMode *mode)
|
||||
*
|
||||
* \brief Retrieve information about a specific display mode.
|
||||
*
|
||||
@ -444,23 +444,22 @@ extern DECLSPEC int SDLCALL SDL_GetNumDisplayModes(void);
|
||||
*
|
||||
* \sa SDL_GetNumDisplayModes()
|
||||
*/
|
||||
extern DECLSPEC const SDL_DisplayMode *SDLCALL SDL_GetDisplayMode(int index);
|
||||
extern DECLSPEC int SDLCALL SDL_GetDisplayMode(int index,
|
||||
SDL_DisplayMode * mode);
|
||||
|
||||
/**
|
||||
* \fn const SDL_DisplayMode *SDL_GetDesktopDisplayMode(void)
|
||||
* \fn int SDL_GetDesktopDisplayMode(SDL_DisplayMode *mode)
|
||||
*
|
||||
* \brief Retrieve information about the desktop display mode for the current display.
|
||||
*/
|
||||
extern DECLSPEC const SDL_DisplayMode *SDLCALL
|
||||
SDL_GetDesktopDisplayMode(void);
|
||||
extern DECLSPEC int SDLCALL SDL_GetDesktopDisplayMode(SDL_DisplayMode * mode);
|
||||
|
||||
/**
|
||||
* \fn const SDL_DisplayMode *SDL_GetCurrentDisplayMode(void)
|
||||
* \fn int SDL_GetCurrentDisplayMode(SDL_DisplayMode *mode)
|
||||
*
|
||||
* \brief Retrieve information about the current display mode.
|
||||
*/
|
||||
extern DECLSPEC const SDL_DisplayMode *SDLCALL
|
||||
SDL_GetCurrentDisplayMode(void);
|
||||
extern DECLSPEC int SDLCALL SDL_GetCurrentDisplayMode(SDL_DisplayMode * mode);
|
||||
|
||||
/**
|
||||
* \fn SDL_DisplayMode *SDL_GetClosestDisplayMode(const SDL_DisplayMode *mode, SDL_DisplayMode *closest)
|
||||
@ -499,13 +498,13 @@ extern DECLSPEC int SDLCALL SDL_SetFullscreenDisplayMode(const SDL_DisplayMode
|
||||
* mode);
|
||||
|
||||
/**
|
||||
* \fn const SDL_DisplayMode *SDL_GetFullscreenDisplayMode(void)
|
||||
* \fn int SDL_GetFullscreenDisplayMode(SDL_DisplayMode *mode)
|
||||
*
|
||||
* \brief Query the display mode used when a fullscreen window is visible
|
||||
* on the currently selected display.
|
||||
*/
|
||||
extern DECLSPEC const SDL_DisplayMode *SDLCALL
|
||||
SDL_GetFullscreenDisplayMode(void);
|
||||
extern DECLSPEC int SDLCALL SDL_GetFullscreenDisplayMode(SDL_DisplayMode *
|
||||
mode);
|
||||
|
||||
/**
|
||||
* \fn int SDL_SetDisplayPalette(const SDL_Color *colors, int firstcolor, int ncolors)
|
||||
|
@ -65,14 +65,15 @@ const SDL_VideoInfo *
|
||||
SDL_GetVideoInfo(void)
|
||||
{
|
||||
static SDL_VideoInfo info;
|
||||
SDL_DisplayMode mode;
|
||||
|
||||
/* Memory leak, compatibility code, who cares? */
|
||||
if (!info.vfmt && SDL_GetDesktopDisplayMode()) {
|
||||
if (!info.vfmt && SDL_GetDesktopDisplayMode(&mode) == 0) {
|
||||
int bpp;
|
||||
Uint32 Rmask, Gmask, Bmask, Amask;
|
||||
|
||||
SDL_PixelFormatEnumToMasks(SDL_GetDesktopDisplayMode()->format, &bpp,
|
||||
&Rmask, &Gmask, &Bmask, &Amask);
|
||||
SDL_PixelFormatEnumToMasks(mode.format, &bpp, &Rmask, &Gmask, &Bmask,
|
||||
&Amask);
|
||||
info.vfmt = SDL_AllocFormat(bpp, Rmask, Gmask, Bmask, Amask);
|
||||
}
|
||||
return &info;
|
||||
@ -88,17 +89,20 @@ SDL_VideoModeOK(int width, int height, int bpp, Uint32 flags)
|
||||
}
|
||||
|
||||
if (!(flags & SDL_FULLSCREEN)) {
|
||||
return SDL_BITSPERPIXEL(SDL_GetDesktopDisplayMode()->format);
|
||||
SDL_DisplayMode mode;
|
||||
SDL_GetDesktopDisplayMode(&mode);
|
||||
return SDL_BITSPERPIXEL(mode.format);
|
||||
}
|
||||
|
||||
for (i = 0; i < SDL_GetNumDisplayModes(); ++i) {
|
||||
const SDL_DisplayMode *mode = SDL_GetDisplayMode(i);
|
||||
if (!mode->w || !mode->h || (width == mode->w && height == mode->h)) {
|
||||
if (!mode->format) {
|
||||
SDL_DisplayMode mode;
|
||||
SDL_GetDisplayMode(i, &mode);
|
||||
if (!mode.w || !mode.h || (width == mode.w && height == mode.h)) {
|
||||
if (!mode.format) {
|
||||
return bpp;
|
||||
}
|
||||
if (SDL_BITSPERPIXEL(mode->format) >= (Uint32) bpp) {
|
||||
actual_bpp = SDL_BITSPERPIXEL(mode->format);
|
||||
if (SDL_BITSPERPIXEL(mode.format) >= (Uint32) bpp) {
|
||||
actual_bpp = SDL_BITSPERPIXEL(mode.format);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -123,15 +127,16 @@ SDL_ListModes(SDL_PixelFormat * format, Uint32 flags)
|
||||
nmodes = 0;
|
||||
modes = NULL;
|
||||
for (i = 0; i < SDL_GetNumDisplayModes(); ++i) {
|
||||
const SDL_DisplayMode *mode = SDL_GetDisplayMode(i);
|
||||
if (!mode->w || !mode->h) {
|
||||
SDL_DisplayMode mode;
|
||||
SDL_GetDisplayMode(i, &mode);
|
||||
if (!mode.w || !mode.h) {
|
||||
return (SDL_Rect **) (-1);
|
||||
}
|
||||
if (SDL_BITSPERPIXEL(mode->format) != format->BitsPerPixel) {
|
||||
if (SDL_BITSPERPIXEL(mode.format) != format->BitsPerPixel) {
|
||||
continue;
|
||||
}
|
||||
if (nmodes > 0 && modes[nmodes - 1]->w == mode->w
|
||||
&& modes[nmodes - 1]->h == mode->h) {
|
||||
if (nmodes > 0 && modes[nmodes - 1]->w == mode.w
|
||||
&& modes[nmodes - 1]->h == mode.h) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -145,8 +150,8 @@ SDL_ListModes(SDL_PixelFormat * format, Uint32 flags)
|
||||
}
|
||||
modes[nmodes]->x = 0;
|
||||
modes[nmodes]->y = 0;
|
||||
modes[nmodes]->w = mode->w;
|
||||
modes[nmodes]->h = mode->h;
|
||||
modes[nmodes]->w = mode.w;
|
||||
modes[nmodes]->h = mode.h;
|
||||
++nmodes;
|
||||
}
|
||||
if (modes) {
|
||||
@ -300,16 +305,17 @@ GetEnvironmentWindowPosition(int w, int h, int *x, int *y)
|
||||
}
|
||||
}
|
||||
if (center) {
|
||||
const SDL_DisplayMode *current = SDL_GetDesktopDisplayMode();
|
||||
*x = (current->w - w) / 2;
|
||||
*y = (current->h - h) / 2;
|
||||
SDL_DisplayMode mode;
|
||||
SDL_GetDesktopDisplayMode(&mode);
|
||||
*x = (mode.w - w) / 2;
|
||||
*y = (mode.h - h) / 2;
|
||||
}
|
||||
}
|
||||
|
||||
SDL_Surface *
|
||||
SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags)
|
||||
{
|
||||
const SDL_DisplayMode *desktop_mode;
|
||||
SDL_DisplayMode desktop_mode;
|
||||
SDL_DisplayMode mode;
|
||||
int window_x = SDL_WINDOWPOS_UNDEFINED;
|
||||
int window_y = SDL_WINDOWPOS_UNDEFINED;
|
||||
@ -390,8 +396,8 @@ SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags)
|
||||
}
|
||||
|
||||
/* Set up the desired display mode */
|
||||
desktop_mode = SDL_GetDesktopDisplayMode();
|
||||
desktop_format = desktop_mode->format;
|
||||
SDL_GetDesktopDisplayMode(&desktop_mode);
|
||||
desktop_format = desktop_mode.format;
|
||||
if (desktop_format && ((flags & SDL_ANYFORMAT)
|
||||
|| (bpp == SDL_BITSPERPIXEL(desktop_format)))) {
|
||||
desired_format = desktop_format;
|
||||
|
@ -422,33 +422,44 @@ SDL_GetNumDisplayModes()
|
||||
return 0;
|
||||
}
|
||||
|
||||
const SDL_DisplayMode *
|
||||
SDL_GetDisplayMode(int index)
|
||||
int
|
||||
SDL_GetDisplayMode(int index, SDL_DisplayMode * mode)
|
||||
{
|
||||
if (index < 0 || index >= SDL_GetNumDisplayModes()) {
|
||||
SDL_SetError("index must be in the range of 0 - %d",
|
||||
SDL_GetNumDisplayModes() - 1);
|
||||
return NULL;
|
||||
return -1;
|
||||
}
|
||||
return &SDL_CurrentDisplay.display_modes[index];
|
||||
if (mode) {
|
||||
*mode = SDL_CurrentDisplay.display_modes[index];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
const SDL_DisplayMode *
|
||||
SDL_GetDesktopDisplayMode(void)
|
||||
int
|
||||
SDL_GetDesktopDisplayMode(SDL_DisplayMode * mode)
|
||||
{
|
||||
if (_this) {
|
||||
return &SDL_CurrentDisplay.desktop_mode;
|
||||
if (!_this) {
|
||||
SDL_UninitializedVideo();
|
||||
return -1;
|
||||
}
|
||||
return NULL;
|
||||
if (mode) {
|
||||
*mode = SDL_CurrentDisplay.desktop_mode;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
const SDL_DisplayMode *
|
||||
SDL_GetCurrentDisplayMode(void)
|
||||
int
|
||||
SDL_GetCurrentDisplayMode(SDL_DisplayMode * mode)
|
||||
{
|
||||
if (_this) {
|
||||
return &SDL_CurrentDisplay.current_mode;
|
||||
if (!_this) {
|
||||
SDL_UninitializedVideo();
|
||||
return -1;
|
||||
}
|
||||
return NULL;
|
||||
if (mode) {
|
||||
*mode = SDL_CurrentDisplay.current_mode;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
SDL_DisplayMode *
|
||||
@ -549,6 +560,7 @@ SDL_SetDisplayMode(const SDL_DisplayMode * mode)
|
||||
{
|
||||
SDL_VideoDisplay *display;
|
||||
SDL_DisplayMode display_mode;
|
||||
SDL_DisplayMode current_mode;
|
||||
int i, ncolors;
|
||||
|
||||
if (!_this) {
|
||||
@ -556,10 +568,10 @@ SDL_SetDisplayMode(const SDL_DisplayMode * mode)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!mode) {
|
||||
mode = SDL_GetDesktopDisplayMode();
|
||||
}
|
||||
display = &SDL_CurrentDisplay;
|
||||
if (!mode) {
|
||||
mode = &display->desktop_mode;
|
||||
}
|
||||
display_mode = *mode;
|
||||
|
||||
/* Default to the current mode */
|
||||
@ -584,9 +596,8 @@ SDL_SetDisplayMode(const SDL_DisplayMode * mode)
|
||||
}
|
||||
|
||||
/* See if there's anything left to do */
|
||||
if (SDL_memcmp
|
||||
(&display_mode, SDL_GetCurrentDisplayMode(),
|
||||
sizeof(display_mode)) == 0) {
|
||||
SDL_GetCurrentDisplayMode(¤t_mode);
|
||||
if (SDL_memcmp(&display_mode, ¤t_mode, sizeof(display_mode)) == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -659,13 +670,17 @@ SDL_SetFullscreenDisplayMode(const SDL_DisplayMode * mode)
|
||||
return 0;
|
||||
}
|
||||
|
||||
const SDL_DisplayMode *
|
||||
SDL_GetFullscreenDisplayMode(void)
|
||||
int
|
||||
SDL_GetFullscreenDisplayMode(SDL_DisplayMode * mode)
|
||||
{
|
||||
if (_this) {
|
||||
return SDL_CurrentDisplay.fullscreen_mode;
|
||||
if (!_this) {
|
||||
SDL_UninitializedVideo();
|
||||
return -1;
|
||||
}
|
||||
return NULL;
|
||||
if (mode) {
|
||||
*mode = *SDL_CurrentDisplay.fullscreen_mode;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -25,7 +25,7 @@
|
||||
#define _SDL_cocoakeyboard_h
|
||||
|
||||
extern void Cocoa_InitKeyboard(_THIS);
|
||||
extern void Cocoa_HandleKeyEvent(_THIS, NSEvent *event);
|
||||
extern void Cocoa_HandleKeyEvent(_THIS, NSEvent * event);
|
||||
extern void Cocoa_QuitKeyboard(_THIS);
|
||||
|
||||
#endif /* _SDL_cocoakeyboard_h */
|
||||
|
@ -545,7 +545,7 @@ CommonInit(CommonState * state)
|
||||
}
|
||||
|
||||
if (state->verbose & VERBOSE_MODES) {
|
||||
const SDL_DisplayMode *mode;
|
||||
SDL_DisplayMode mode;
|
||||
int bpp;
|
||||
Uint32 Rmask, Gmask, Bmask, Amask;
|
||||
|
||||
@ -555,12 +555,12 @@ CommonInit(CommonState * state)
|
||||
fprintf(stderr, "Display %d:\n", i);
|
||||
SDL_SelectVideoDisplay(i);
|
||||
|
||||
mode = SDL_GetDesktopDisplayMode();
|
||||
SDL_PixelFormatEnumToMasks(mode->format, &bpp, &Rmask, &Gmask,
|
||||
SDL_GetDesktopDisplayMode(&mode);
|
||||
SDL_PixelFormatEnumToMasks(mode.format, &bpp, &Rmask, &Gmask,
|
||||
&Bmask, &Amask);
|
||||
fprintf(stderr,
|
||||
" Current mode: %dx%d@%dHz, %d bits-per-pixel\n",
|
||||
mode->w, mode->h, mode->refresh_rate, bpp);
|
||||
mode.w, mode.h, mode.refresh_rate, bpp);
|
||||
if (Rmask || Gmask || Bmask) {
|
||||
fprintf(stderr, " Red Mask = 0x%.8x\n", Rmask);
|
||||
fprintf(stderr, " Green Mask = 0x%.8x\n", Gmask);
|
||||
@ -576,12 +576,12 @@ CommonInit(CommonState * state)
|
||||
} else {
|
||||
fprintf(stderr, " Fullscreen video modes:\n");
|
||||
for (j = 0; j < m; ++j) {
|
||||
mode = SDL_GetDisplayMode(j);
|
||||
SDL_PixelFormatEnumToMasks(mode->format, &bpp, &Rmask,
|
||||
SDL_GetDisplayMode(j, &mode);
|
||||
SDL_PixelFormatEnumToMasks(mode.format, &bpp, &Rmask,
|
||||
&Gmask, &Bmask, &Amask);
|
||||
fprintf(stderr,
|
||||
" Mode %d: %dx%d@%dHz, %d bits-per-pixel\n",
|
||||
j, mode->w, mode->h, mode->refresh_rate, bpp);
|
||||
j, mode.w, mode.h, mode.refresh_rate, bpp);
|
||||
if (Rmask || Gmask || Bmask) {
|
||||
fprintf(stderr, " Red Mask = 0x%.8x\n",
|
||||
Rmask);
|
||||
|
@ -165,6 +165,7 @@ main(int argc, char *argv[])
|
||||
int fsaa, accel;
|
||||
int value;
|
||||
int i, done;
|
||||
SDL_DisplayMode mode;
|
||||
SDL_Event event;
|
||||
Uint32 then, now, frames;
|
||||
|
||||
@ -235,8 +236,8 @@ main(int argc, char *argv[])
|
||||
SDL_GL_SetSwapInterval(0);
|
||||
}
|
||||
|
||||
printf("Screen BPP: %d\n",
|
||||
SDL_BITSPERPIXEL(SDL_GetCurrentDisplayMode()->format));
|
||||
SDL_GetCurrentDisplayMode(&mode);
|
||||
printf("Screen BPP: %d\n", SDL_BITSPERPIXEL(mode.format));
|
||||
printf("\n");
|
||||
printf("Vendor : %s\n", glGetString(GL_VENDOR));
|
||||
printf("Renderer : %s\n", glGetString(GL_RENDERER));
|
||||
|
@ -419,7 +419,7 @@ main(int argc, char *argv[])
|
||||
const SDL_VideoInfo *info;
|
||||
int i, d, n;
|
||||
const char *driver;
|
||||
const SDL_DisplayMode *mode;
|
||||
SDL_DisplayMode mode;
|
||||
int bpp;
|
||||
Uint32 Rmask, Gmask, Bmask, Amask;
|
||||
int nmodes;
|
||||
@ -452,11 +452,11 @@ main(int argc, char *argv[])
|
||||
printf("Display %d:\n", d);
|
||||
SDL_SelectVideoDisplay(d);
|
||||
|
||||
mode = SDL_GetDesktopDisplayMode();
|
||||
SDL_PixelFormatEnumToMasks(mode->format, &bpp, &Rmask, &Gmask, &Bmask,
|
||||
SDL_GetDesktopDisplayMode(&mode);
|
||||
SDL_PixelFormatEnumToMasks(mode.format, &bpp, &Rmask, &Gmask, &Bmask,
|
||||
&Amask);
|
||||
printf(" Current mode: %dx%d@%dHz, %d bits-per-pixel\n", mode->w,
|
||||
mode->h, mode->refresh_rate, bpp);
|
||||
printf(" Current mode: %dx%d@%dHz, %d bits-per-pixel\n", mode.w,
|
||||
mode.h, mode.refresh_rate, bpp);
|
||||
if (Rmask || Gmask || Bmask) {
|
||||
printf(" Red Mask = 0x%.8x\n", Rmask);
|
||||
printf(" Green Mask = 0x%.8x\n", Gmask);
|
||||
@ -472,11 +472,11 @@ main(int argc, char *argv[])
|
||||
} else {
|
||||
printf(" Fullscreen video modes:\n");
|
||||
for (i = 0; i < nmodes; ++i) {
|
||||
mode = SDL_GetDisplayMode(i);
|
||||
SDL_PixelFormatEnumToMasks(mode->format, &bpp, &Rmask,
|
||||
SDL_GetDisplayMode(i, &mode);
|
||||
SDL_PixelFormatEnumToMasks(mode.format, &bpp, &Rmask,
|
||||
&Gmask, &Bmask, &Amask);
|
||||
printf(" Mode %d: %dx%d@%dHz, %d bits-per-pixel\n", i,
|
||||
mode->w, mode->h, mode->refresh_rate, bpp);
|
||||
mode.w, mode.h, mode.refresh_rate, bpp);
|
||||
if (Rmask || Gmask || Bmask) {
|
||||
printf(" Red Mask = 0x%.8x\n", Rmask);
|
||||
printf(" Green Mask = 0x%.8x\n", Gmask);
|
||||
|
Loading…
Reference in New Issue
Block a user