Use SDL_bool instead an int return code in the SDL API

Most SDL functions used to indicate success or failure using an int return code. These functions have been changed to return SDL_bool.

Here is a coccinelle patch to change code that previously compared the return value to 0 and changes it to a boolean test:
@ bool_return_type  @
identifier func =~ "^(SDL_AddEventWatch|SDL_AddHintCallback|SDL_AddSurfaceAlternateImage|SDL_AddVulkanRenderSemaphores|SDL_BindAudioStream|SDL_BindAudioStreams|SDL_BlitSurface|SDL_BlitSurface9Grid|SDL_BlitSurfaceScaled|SDL_BlitSurfaceTiled|SDL_BlitSurfaceTiledWithScale|SDL_BlitSurfaceUnchecked|SDL_BlitSurfaceUncheckedScaled|SDL_CaptureMouse|SDL_ClearAudioStream|SDL_ClearClipboardData|SDL_ClearComposition|SDL_ClearError|SDL_ClearProperty|SDL_ClearSurface|SDL_CloseIO|SDL_CloseStorage|SDL_ConvertAudioSamples|SDL_ConvertEventToRenderCoordinates|SDL_ConvertPixels|SDL_ConvertPixelsAndColorspace|SDL_CopyFile|SDL_CopyProperties|SDL_CopyStorageFile|SDL_CreateDirectory|SDL_CreateStorageDirectory|SDL_CreateWindowAndRenderer|SDL_DateTimeToTime|SDL_DestroyWindowSurface|SDL_DetachVirtualJoystick|SDL_DisableScreenSaver|SDL_EnableScreenSaver|SDL_EnumerateDirectory|SDL_EnumerateProperties|SDL_EnumerateStorageDirectory|SDL_FillSurfaceRect|SDL_FillSurfaceRects|SDL_FlashWindow|SDL_FlipSurface|SDL_FlushAudioStream|SDL_FlushRenderer|SDL_GL_DestroyContext|SDL_GL_GetAttribute|SDL_GL_GetSwapInterval|SDL_GL_LoadLibrary|SDL_GL_MakeCurrent|SDL_GL_SetAttribute|SDL_GL_SetSwapInterval|SDL_GL_SwapWindow|SDL_GetAudioDeviceFormat|SDL_GetAudioStreamFormat|SDL_GetCameraFormat|SDL_GetClosestFullscreenDisplayMode|SDL_GetCurrentRenderOutputSize|SDL_GetCurrentTime|SDL_GetDXGIOutputInfo|SDL_GetDateTimeLocalePreferences|SDL_GetDisplayBounds|SDL_GetDisplayUsableBounds|SDL_GetGDKDefaultUser|SDL_GetGDKTaskQueue|SDL_GetGamepadSensorData|SDL_GetGamepadTouchpadFinger|SDL_GetHapticEffectStatus|SDL_GetJoystickBall|SDL_GetMasksForPixelFormat|SDL_GetPathInfo|SDL_GetRectUnion|SDL_GetRectUnionFloat|SDL_GetRenderClipRect|SDL_GetRenderColorScale|SDL_GetRenderDrawBlendMode|SDL_GetRenderDrawColor|SDL_GetRenderDrawColorFloat|SDL_GetRenderLogicalPresentation|SDL_GetRenderLogicalPresentationRect|SDL_GetRenderOutputSize|SDL_GetRenderSafeArea|SDL_GetRenderScale|SDL_GetRenderVSync|SDL_GetRenderViewport|SDL_GetSensorData|SDL_GetStorageFileSize|SDL_GetStoragePathInfo|SDL_GetSurfaceAlphaMod|SDL_GetSurfaceBlendMode|SDL_GetSurfaceClipRect|SDL_GetSurfaceColorKey|SDL_GetSurfaceColorMod|SDL_GetTextInputArea|SDL_GetTextureAlphaMod|SDL_GetTextureAlphaModFloat|SDL_GetTextureBlendMode|SDL_GetTextureColorMod|SDL_GetTextureColorModFloat|SDL_GetTextureScaleMode|SDL_GetTextureSize|SDL_GetWindowAspectRatio|SDL_GetWindowBordersSize|SDL_GetWindowMaximumSize|SDL_GetWindowMinimumSize|SDL_GetWindowPosition|SDL_GetWindowRelativeMouseMode|SDL_GetWindowSafeArea|SDL_GetWindowSize|SDL_GetWindowSizeInPixels|SDL_GetWindowSurfaceVSync|SDL_HideCursor|SDL_HideWindow|SDL_Init|SDL_InitHapticRumble|SDL_InitSubSystem|SDL_LoadWAV|SDL_LoadWAV_IO|SDL_LockAudioStream|SDL_LockProperties|SDL_LockSurface|SDL_LockTexture|SDL_LockTextureToSurface|SDL_MaximizeWindow|SDL_MinimizeWindow|SDL_MixAudio|SDL_OpenURL|SDL_OutOfMemory|SDL_PauseAudioDevice|SDL_PauseAudioStreamDevice|SDL_PauseHaptic|SDL_PlayHapticRumble|SDL_PremultiplyAlpha|SDL_PremultiplySurfaceAlpha|SDL_PushEvent|SDL_PutAudioStreamData|SDL_RaiseWindow|SDL_ReadStorageFile|SDL_ReadSurfacePixel|SDL_ReadSurfacePixelFloat|SDL_RegisterApp|SDL_ReloadGamepadMappings|SDL_RemovePath|SDL_RemoveStoragePath|SDL_RemoveTimer|SDL_RenamePath|SDL_RenameStoragePath|SDL_RenderClear|SDL_RenderCoordinatesFromWindow|SDL_RenderCoordinatesToWindow|SDL_RenderFillRect|SDL_RenderFillRects|SDL_RenderGeometry|SDL_RenderGeometryRaw|SDL_RenderLine|SDL_RenderLines|SDL_RenderPoint|SDL_RenderPoints|SDL_RenderPresent|SDL_RenderRect|SDL_RenderRects|SDL_RenderTexture|SDL_RenderTexture9Grid|SDL_RenderTextureRotated|SDL_RenderTextureTiled|SDL_RequestAndroidPermission|SDL_RestoreWindow|SDL_ResumeAudioDevice|SDL_ResumeAudioStreamDevice|SDL_ResumeHaptic|SDL_RumbleGamepad|SDL_RumbleGamepadTriggers|SDL_RumbleJoystick|SDL_RumbleJoystickTriggers|SDL_RunHapticEffect|SDL_SaveBMP|SDL_SaveBMP_IO|SDL_SendAndroidMessage|SDL_SendGamepadEffect|SDL_SendJoystickEffect|SDL_SendJoystickVirtualSensorData|SDL_SetAppMetadata|SDL_SetAppMetadataProperty|SDL_SetAudioDeviceGain|SDL_SetAudioPostmixCallback|SDL_SetAudioStreamFormat|SDL_SetAudioStreamFrequencyRatio|SDL_SetAudioStreamGain|SDL_SetAudioStreamGetCallback|SDL_SetAudioStreamInputChannelMap|SDL_SetAudioStreamOutputChannelMap|SDL_SetAudioStreamPutCallback|SDL_SetBooleanProperty|SDL_SetClipboardData|SDL_SetClipboardText|SDL_SetCursor|SDL_SetFloatProperty|SDL_SetGamepadLED|SDL_SetGamepadMapping|SDL_SetGamepadPlayerIndex|SDL_SetGamepadSensorEnabled|SDL_SetHapticAutocenter|SDL_SetHapticGain|SDL_SetJoystickLED|SDL_SetJoystickPlayerIndex|SDL_SetJoystickVirtualAxis|SDL_SetJoystickVirtualBall|SDL_SetJoystickVirtualButton|SDL_SetJoystickVirtualHat|SDL_SetJoystickVirtualTouchpad|SDL_SetLinuxThreadPriority|SDL_SetLinuxThreadPriorityAndPolicy|SDL_SetLogPriorityPrefix|SDL_SetMemoryFunctions|SDL_SetNumberProperty|SDL_SetPaletteColors|SDL_SetPointerProperty|SDL_SetPointerPropertyWithCleanup|SDL_SetPrimarySelectionText|SDL_SetRenderClipRect|SDL_SetRenderColorScale|SDL_SetRenderDrawBlendMode|SDL_SetRenderDrawColor|SDL_SetRenderDrawColorFloat|SDL_SetRenderLogicalPresentation|SDL_SetRenderScale|SDL_SetRenderTarget|SDL_SetRenderVSync|SDL_SetRenderViewport|SDL_SetScancodeName|SDL_SetStringProperty|SDL_SetSurfaceAlphaMod|SDL_SetSurfaceBlendMode|SDL_SetSurfaceColorKey|SDL_SetSurfaceColorMod|SDL_SetSurfaceColorspace|SDL_SetSurfacePalette|SDL_SetSurfaceRLE|SDL_SetTLS|SDL_SetTextInputArea|SDL_SetTextureAlphaMod|SDL_SetTextureAlphaModFloat|SDL_SetTextureBlendMode|SDL_SetTextureColorMod|SDL_SetTextureColorModFloat|SDL_SetTextureScaleMode|SDL_SetThreadPriority|SDL_SetWindowAlwaysOnTop|SDL_SetWindowAspectRatio|SDL_SetWindowBordered|SDL_SetWindowFocusable|SDL_SetWindowFullscreen|SDL_SetWindowFullscreenMode|SDL_SetWindowHitTest|SDL_SetWindowIcon|SDL_SetWindowKeyboardGrab|SDL_SetWindowMaximumSize|SDL_SetWindowMinimumSize|SDL_SetWindowModalFor|SDL_SetWindowMouseGrab|SDL_SetWindowMouseRect|SDL_SetWindowOpacity|SDL_SetWindowPosition|SDL_SetWindowRelativeMouseMode|SDL_SetWindowResizable|SDL_SetWindowShape|SDL_SetWindowSize|SDL_SetWindowSurfaceVSync|SDL_SetWindowTitle|SDL_SetiOSAnimationCallback|SDL_ShowAndroidToast|SDL_ShowCursor|SDL_ShowMessageBox|SDL_ShowSimpleMessageBox|SDL_ShowWindow|SDL_ShowWindowSystemMenu|SDL_StartTextInput|SDL_StartTextInputWithProperties|SDL_StopHapticEffect|SDL_StopHapticEffects|SDL_StopHapticRumble|SDL_StopTextInput|SDL_SyncWindow|SDL_TimeToDateTime|SDL_TryLockMutex|SDL_TryLockRWLockForReading|SDL_TryLockRWLockForWriting|SDL_TryWaitSemaphore|SDL_UnlockAudioStream|SDL_UpdateHapticEffect|SDL_UpdateNVTexture|SDL_UpdateTexture|SDL_UpdateWindowSurface|SDL_UpdateWindowSurfaceRects|SDL_UpdateYUVTexture|SDL_Vulkan_CreateSurface|SDL_Vulkan_LoadLibrary|SDL_WaitConditionTimeout|SDL_WaitSemaphoreTimeout|SDL_WarpMouseGlobal|SDL_WriteStorageFile|SDL_WriteSurfacePixel|SDL_WriteSurfacePixelFloat)$";
@@
(
  func(
  ...
  )
- == 0
|
- func(
+ !func(
  ...
  )
- < 0
|
- func(
+ !func(
  ...
  )
- != 0
|
- func(
+ !func(
  ...
  )
- == -1
)
This commit is contained in:
Sam Lantinga
2024-08-22 17:33:49 -07:00
parent d9a5ed75b9
commit 9ff3446f03
726 changed files with 11062 additions and 11472 deletions

View File

@@ -1223,7 +1223,7 @@ void RenderGamepadDisplay(GamepadDisplay *ctx, SDL_Gamepad *gamepad)
Uint8 state;
float finger_x, finger_y, finger_pressure;
if (SDL_GetGamepadTouchpadFinger(gamepad, 0, i, &state, &finger_x, &finger_y, &finger_pressure) < 0) {
if (!SDL_GetGamepadTouchpadFinger(gamepad, 0, i, &state, &finger_x, &finger_y, &finger_pressure)) {
continue;
}
@@ -2688,12 +2688,12 @@ SDL_bool MappingHasBindings(const char *mapping)
SDL_bool MappingHasName(const char *mapping)
{
MappingParts parts;
SDL_bool retval;
SDL_bool result;
SplitMapping(mapping, &parts);
retval = parts.name ? SDL_TRUE : SDL_FALSE;
result = parts.name ? SDL_TRUE : SDL_FALSE;
FreeMappingParts(&parts);
return retval;
return result;
}
char *GetMappingName(const char *mapping)

View File

@@ -80,7 +80,7 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
}
/* Load the SDL library */
if (SDL_Init(SDL_INIT_AUDIO | SDL_INIT_EVENTS) < 0) {
if (!SDL_Init(SDL_INIT_AUDIO | SDL_INIT_EVENTS)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
return SDL_APP_FAILURE;
}
@@ -93,7 +93,7 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
}
/* Load the wave file into memory */
if (SDL_LoadWAV(filename, &wave.spec, &wave.sound, &wave.soundlen) < 0) {
if (!SDL_LoadWAV(filename, &wave.spec, &wave.sound, &wave.soundlen)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", filename, SDL_GetError());
SDL_free(filename);
return SDL_APP_FAILURE;

View File

@@ -152,14 +152,14 @@ static void SetDefaultTitleBar(void)
static Thing *FindThingAtPoint(const float x, const float y)
{
const SDL_FPoint pt = { x, y };
Thing *retval = NULL;
Thing *result = NULL;
Thing *i;
for (i = things; i; i = i->next) {
if ((i != dragging_thing) && SDL_PointInRectFloat(&pt, &i->rect)) {
retval = i; /* keep going, though, because things drawn on top are later in the list. */
result = i; /* keep going, though, because things drawn on top are later in the list. */
}
}
return retval;
return result;
}
static Thing *UpdateMouseOver(const float x, const float y)
@@ -667,7 +667,7 @@ static Thing *LoadWavThing(const char *fname, float x, float y)
fname = path;
}
if (SDL_LoadWAV(fname, &spec, &buf, &buflen) == 0) {
if (SDL_LoadWAV(fname, &spec, &buf, &buflen)) {
static const ThingType can_be_dropped_onto[] = { THING_TRASHCAN, THING_NULL };
char *titlebar = NULL;
const char *nodirs = SDL_strrchr(fname, '/');

View File

@@ -88,7 +88,7 @@ static void iteration(void)
/* !!! FIXME: laziness, this used to loop the audio, but we'll just play it once for now on each connect. */
SDL_PutAudioStreamData(stream, sound, soundlen);
SDL_FlushAudioStream(stream);
SDL_ResumeAudioDevice(SDL_GetAudioStreamDevice(stream));
SDL_ResumeAudioStreamDevice(stream);
/* !!! FIXME: this is leaking the stream for now. We'll wire it up to a dictionary or whatever later. */
}
}
@@ -146,7 +146,7 @@ int main(int argc, char *argv[])
}
/* Load the SDL library */
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0) {
if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
return 1;
}
@@ -167,7 +167,7 @@ int main(int argc, char *argv[])
}
/* Load the wave file into memory */
if (SDL_LoadWAV(filename, &spec, &sound, &soundlen) < 0) {
if (!SDL_LoadWAV(filename, &spec, &sound, &soundlen)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", filename, SDL_GetError());
quit(1);
}

View File

@@ -37,7 +37,7 @@ print_devices(SDL_bool recording)
SDL_Log(" %d Error: %s\n", i, SDL_GetError());
}
if (SDL_GetAudioDeviceFormat(devices[i], &spec, &frames) == 0) {
if (SDL_GetAudioDeviceFormat(devices[i], &spec, &frames)) {
SDL_Log(" Sample Rate: %d\n", spec.freq);
SDL_Log(" Channels: %d\n", spec.channels);
SDL_Log(" SDL_AudioFormat: %X\n", spec.format);
@@ -72,7 +72,7 @@ int main(int argc, char **argv)
}
/* Load the SDL library */
if (SDL_Init(SDL_INIT_AUDIO) < 0) {
if (!SDL_Init(SDL_INIT_AUDIO)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
return 1;
}
@@ -94,24 +94,24 @@ int main(int argc, char **argv)
print_devices(SDL_FALSE);
print_devices(SDL_TRUE);
if (SDL_GetAudioDeviceFormat(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, &spec, &frames) < 0) {
SDL_Log("Error when calling SDL_GetAudioDeviceFormat(default playback): %s\n", SDL_GetError());
} else {
if (SDL_GetAudioDeviceFormat(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, &spec, &frames)) {
SDL_Log("Default Playback Device:\n");
SDL_Log("Sample Rate: %d\n", spec.freq);
SDL_Log("Channels: %d\n", spec.channels);
SDL_Log("SDL_AudioFormat: %X\n", spec.format);
SDL_Log("Buffer Size: %d frames\n", frames);
} else {
SDL_Log("Error when calling SDL_GetAudioDeviceFormat(default playback): %s\n", SDL_GetError());
}
if (SDL_GetAudioDeviceFormat(SDL_AUDIO_DEVICE_DEFAULT_RECORDING, &spec, &frames) < 0) {
SDL_Log("Error when calling SDL_GetAudioDeviceFormat(default recording): %s\n", SDL_GetError());
} else {
if (SDL_GetAudioDeviceFormat(SDL_AUDIO_DEVICE_DEFAULT_RECORDING, &spec, &frames)) {
SDL_Log("Default Recording Device:\n");
SDL_Log("Sample Rate: %d\n", spec.freq);
SDL_Log("Channels: %d\n", spec.channels);
SDL_Log("SDL_AudioFormat: %X\n", spec.format);
SDL_Log("Buffer Size: %d frames\n", frames);
} else {
SDL_Log("Error when calling SDL_GetAudioDeviceFormat(default recording): %s\n", SDL_GetError());
}
SDL_Quit();

View File

@@ -64,12 +64,12 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char **argv)
}
/* Load the SDL library */
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0) {
if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
return SDL_APP_SUCCESS;
}
if (SDL_CreateWindowAndRenderer("testaudiorecording", 320, 240, 0, &window, &renderer) < 0) {
if (!SDL_CreateWindowAndRenderer("testaudiorecording", 320, 240, 0, &window, &renderer)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create SDL window and renderer: %s\n", SDL_GetError());
return SDL_APP_SUCCESS;
}
@@ -113,7 +113,7 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char **argv)
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create an audio stream for playback: %s!\n", SDL_GetError());
SDL_free(devices);
return SDL_APP_FAILURE;
} else if (SDL_BindAudioStream(device, stream_out) < 0) {
} else if (!SDL_BindAudioStream(device, stream_out)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't bind an audio stream for playback: %s!\n", SDL_GetError());
SDL_free(devices);
return SDL_APP_FAILURE;
@@ -137,7 +137,7 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char **argv)
if (!stream_in) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create an audio stream for recording: %s!\n", SDL_GetError());
return SDL_APP_FAILURE;
} else if (SDL_BindAudioStream(device, stream_in) < 0) {
} else if (!SDL_BindAudioStream(device, stream_in)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't bind an audio stream for recording: %s!\n", SDL_GetError());
return SDL_APP_FAILURE;
}
@@ -159,15 +159,15 @@ SDL_AppResult SDL_AppEvent(void *appstate, const SDL_Event *event)
}
} else if (event->type == SDL_EVENT_MOUSE_BUTTON_DOWN) {
if (event->button.button == 1) {
SDL_PauseAudioDevice(SDL_GetAudioStreamDevice(stream_out));
SDL_PauseAudioStreamDevice(stream_out);
SDL_FlushAudioStream(stream_out); /* so no samples are held back for resampling purposes. */
SDL_ResumeAudioDevice(SDL_GetAudioStreamDevice(stream_in));
SDL_ResumeAudioStreamDevice(stream_in);
}
} else if (event->type == SDL_EVENT_MOUSE_BUTTON_UP) {
if (event->button.button == 1) {
SDL_PauseAudioDevice(SDL_GetAudioStreamDevice(stream_in));
SDL_PauseAudioStreamDevice(stream_in);
SDL_FlushAudioStream(stream_in); /* so no samples are held back for resampling purposes. */
SDL_ResumeAudioDevice(SDL_GetAudioStreamDevice(stream_out));
SDL_ResumeAudioStreamDevice(stream_out);
}
}
return SDL_APP_CONTINUE;
@@ -190,7 +190,7 @@ SDL_AppResult SDL_AppIterate(void *appstate)
if (br < 0) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to read from input audio stream: %s\n", SDL_GetError());
return SDL_APP_FAILURE;
} else if (SDL_PutAudioStreamData(stream_out, buf, br) < 0) {
} else if (!SDL_PutAudioStreamData(stream_out, buf, br)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to write to output audio stream: %s\n", SDL_GetError());
return SDL_APP_FAILURE;
}

View File

@@ -106,7 +106,7 @@ static void queue_audio(void)
{
Uint8* new_data = NULL;
int new_len = 0;
int retval = 0;
SDL_bool result = SDL_TRUE;
SDL_AudioSpec new_spec;
SDL_zero(new_spec);
@@ -117,20 +117,20 @@ static void queue_audio(void)
SDL_Log("Converting audio from %i to %i", spec.freq, new_spec.freq);
/* You shouldn't actually use SDL_ConvertAudioSamples like this (just put the data straight into the stream and let it handle conversion) */
retval = retval ? retval : SDL_ConvertAudioSamples(&spec, audio_buf, audio_len, &new_spec, &new_data, &new_len);
retval = retval ? retval : SDL_SetAudioStreamFormat(stream, &new_spec, NULL);
retval = retval ? retval : SDL_PutAudioStreamData(stream, new_data, new_len);
result = result && SDL_ConvertAudioSamples(&spec, audio_buf, audio_len, &new_spec, &new_data, &new_len);
result = result && SDL_SetAudioStreamFormat(stream, &new_spec, NULL);
result = result && SDL_PutAudioStreamData(stream, new_data, new_len);
if (auto_flush) {
retval = retval ? retval : SDL_FlushAudioStream(stream);
result = result && SDL_FlushAudioStream(stream);
}
SDL_free(new_data);
if (retval) {
SDL_Log("Failed to queue audio: %s", SDL_GetError());
} else {
if (result) {
SDL_Log("Queued audio");
} else {
SDL_Log("Failed to queue audio: %s", SDL_GetError());
}
}
@@ -139,7 +139,7 @@ static void skip_audio(float amount)
float speed;
SDL_AudioSpec dst_spec;
int num_bytes;
int retval = 0;
int result = 0;
void* buf = NULL;
SDL_LockAudioStream(stream);
@@ -153,7 +153,7 @@ static void skip_audio(float amount)
buf = SDL_malloc(num_bytes);
if (buf) {
retval = SDL_GetAudioStreamData(stream, buf, num_bytes);
result = SDL_GetAudioStreamData(stream, buf, num_bytes);
SDL_free(buf);
}
@@ -161,7 +161,7 @@ static void skip_audio(float amount)
SDL_UnlockAudioStream(stream);
if (retval >= 0) {
if (result >= 0) {
SDL_Log("Skipped %.2f seconds", amount);
} else {
SDL_Log("Failed to skip: %s", SDL_GetError());
@@ -285,7 +285,7 @@ static void loop(void)
SDL_SetAudioStreamFrequencyRatio(stream, sliders[0].value);
}
if (SDL_GetAudioStreamFormat(stream, &src_spec, &dst_spec) == 0) {
if (SDL_GetAudioStreamFormat(stream, &src_spec, &dst_spec)) {
available_bytes = SDL_GetAudioStreamAvailable(stream);
available_seconds = (float)available_bytes / (float)(SDL_AUDIO_FRAMESIZE(dst_spec) * dst_spec.freq);
@@ -369,7 +369,6 @@ int main(int argc, char *argv[])
{
char *filename = NULL;
int i;
int rc;
/* Initialize test framework */
state = SDLTest_CommonCreateState(argv, SDL_INIT_AUDIO | SDL_INIT_VIDEO);
@@ -409,9 +408,7 @@ int main(int argc, char *argv[])
FONT_CHARACTER_SIZE = 16;
filename = GetResourceFilename(filename, "sample.wav");
rc = SDL_LoadWAV(filename, &spec, &audio_buf, &audio_len);
if (rc < 0) {
if (!SDL_LoadWAV(filename, &spec, &audio_buf, &audio_len)) {
SDL_Log("Failed to load '%s': %s", filename, SDL_GetError());
SDL_free(filename);
SDL_Quit();

View File

@@ -22,10 +22,10 @@
static void audioSetUp(void *arg)
{
/* Start SDL audio subsystem */
int ret = SDL_InitSubSystem(SDL_INIT_AUDIO);
SDL_bool ret = SDL_InitSubSystem(SDL_INIT_AUDIO);
SDLTest_AssertPass("Call to SDL_InitSubSystem(SDL_INIT_AUDIO)");
SDLTest_AssertCheck(ret == 0, "Check result from SDL_InitSubSystem(SDL_INIT_AUDIO)");
if (ret != 0) {
SDLTest_AssertCheck(ret == SDL_TRUE, "Check result from SDL_InitSubSystem(SDL_INIT_AUDIO)");
if (!ret) {
SDLTest_LogError("%s", SDL_GetError());
}
}
@@ -111,7 +111,7 @@ static int audio_initQuitAudio(void *arg)
SDL_SetHint(SDL_HINT_AUDIO_DRIVER, audioDriver);
result = SDL_InitSubSystem(SDL_INIT_AUDIO);
SDLTest_AssertPass("Call to SDL_InitSubSystem(SDL_INIT_AUDIO) with driver='%s'", audioDriver);
SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0 got: %d", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Validate result value; expected: SDL_TRUE got: %d", result);
/* Call Quit */
SDL_QuitSubSystem(SDL_INIT_AUDIO);
@@ -125,7 +125,7 @@ static int audio_initQuitAudio(void *arg)
SDL_SetHint(SDL_HINT_AUDIO_DRIVER, audioDriver);
result = SDL_InitSubSystem(SDL_INIT_AUDIO);
SDLTest_AssertPass("Call to SDL_AudioInit(NULL)");
SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0 got: %d", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Validate result value; expected: SDL_TRUE got: %d", result);
/* Call Quit */
SDL_QuitSubSystem(SDL_INIT_AUDIO);
@@ -178,7 +178,7 @@ static int audio_initOpenCloseQuitAudio(void *arg)
SDL_SetHint(SDL_HINT_AUDIO_DRIVER, audioDriver);
result = SDL_InitSubSystem(SDL_INIT_AUDIO);
SDLTest_AssertPass("Call to SDL_InitSubSystem(SDL_INIT_AUDIO) with driver='%s'", audioDriver);
SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0 got: %d", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Validate result value; expected: SDL_TRUE got: %d", result);
/* Set spec */
SDL_zero(desired);
@@ -269,7 +269,7 @@ static int audio_pauseUnpauseAudio(void *arg)
SDL_SetHint(SDL_HINT_AUDIO_DRIVER, audioDriver);
result = SDL_InitSubSystem(SDL_INIT_AUDIO);
SDLTest_AssertPass("Call to SDL_InitSubSystem(SDL_INIT_AUDIO) with driver='%s'", audioDriver);
SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0 got: %d", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Validate result value; expected: SDL_TRUE got: %d", result);
/* Set spec */
SDL_zero(desired);
@@ -826,8 +826,8 @@ static int audio_convertAudio(void *arg)
SDLTest_AssertCheck(0 == real_dst_len, "Verify available (pre-put); expected: %i; got: %i", 0, real_dst_len);
/* Run the audio converter */
if (SDL_PutAudioStreamData(stream, src_buf, src_len) < 0 ||
SDL_FlushAudioStream(stream) < 0) {
if (!SDL_PutAudioStreamData(stream, src_buf, src_len) ||
!SDL_FlushAudioStream(stream)) {
return TEST_ABORTED;
}
@@ -894,8 +894,8 @@ static int put_audio_data_split(SDL_AudioStream* stream, const void* buf, int le
int frame_size;
int ret = SDL_GetAudioStreamFormat(stream, &spec, NULL);
if (ret != 0) {
return ret;
if (!ret) {
return -1;
}
frame_size = SDL_AUDIO_FRAMESIZE(spec);
@@ -905,8 +905,8 @@ static int put_audio_data_split(SDL_AudioStream* stream, const void* buf, int le
n = SDL_min(n, len);
ret = SDL_PutAudioStreamData(stream, buf, n);
if (ret != 0) {
return ret;
if (!ret) {
return -1;
}
buf = ((const Uint8*) buf) + n;
@@ -923,8 +923,8 @@ static int get_audio_data_split(SDL_AudioStream* stream, void* buf, int len) {
int ret = SDL_GetAudioStreamFormat(stream, NULL, &spec);
int total = 0;
if (ret != 0) {
return ret;
if (!ret) {
return -1;
}
frame_size = SDL_AUDIO_FRAMESIZE(spec);
@@ -936,7 +936,7 @@ static int get_audio_data_split(SDL_AudioStream* stream, void* buf, int len) {
ret = SDL_GetAudioStreamData(stream, buf, n);
if (ret <= 0) {
return total ? total : ret;
return total ? total : -1;
}
buf = ((Uint8*) buf) + ret;
@@ -955,8 +955,8 @@ static int convert_audio_chunks(SDL_AudioStream* stream, const void* src, int sr
int total_in = 0, total_out = 0;
int ret = SDL_GetAudioStreamFormat(stream, &src_spec, &dst_spec);
if (ret) {
return ret;
if (!ret) {
return -1;
}
src_frame_size = SDL_AUDIO_FRAMESIZE(src_spec);
@@ -981,8 +981,8 @@ static int convert_audio_chunks(SDL_AudioStream* stream, const void* src, int sr
if (total_in == srclen) {
ret = SDL_FlushAudioStream(stream);
if (ret) {
return total_out ? total_out : ret;
if (!ret) {
return total_out ? total_out : -1;
}
}
}
@@ -1245,8 +1245,8 @@ static int audio_convertAccuracy(void *arg)
tmp_data = NULL;
tmp_len = 0;
ret = SDL_ConvertAudioSamples(&src_spec, (const Uint8*) src_data, src_len, &tmp_spec, &tmp_data, &tmp_len);
SDLTest_AssertCheck(ret == 0, "Expected SDL_ConvertAudioSamples(F32->%s) to succeed", format_name);
if (ret != 0) {
SDLTest_AssertCheck(ret == SDL_TRUE, "Expected SDL_ConvertAudioSamples(F32->%s) to succeed", format_name);
if (!ret) {
SDL_free(src_data);
return TEST_ABORTED;
}
@@ -1254,8 +1254,8 @@ static int audio_convertAccuracy(void *arg)
dst_data = NULL;
dst_len = 0;
ret = SDL_ConvertAudioSamples(&tmp_spec, tmp_data, tmp_len, &src_spec, &dst_data, &dst_len);
SDLTest_AssertCheck(ret == 0, "Expected SDL_ConvertAudioSamples(%s->F32) to succeed", format_name);
if (ret != 0) {
SDLTest_AssertCheck(ret == SDL_TRUE, "Expected SDL_ConvertAudioSamples(%s->F32) to succeed", format_name);
if (!ret) {
SDL_free(tmp_data);
SDL_free(src_data);
return TEST_ABORTED;
@@ -1297,7 +1297,7 @@ static int audio_formatChange(void *arg)
SDL_AudioSpec spec1, spec2, spec3;
int frames_1, frames_2, frames_3;
int length_1, length_2, length_3;
int retval = 0;
int result = 0;
int status = TEST_ABORTED;
float* buffer_1 = NULL;
float* buffer_2 = NULL;
@@ -1362,53 +1362,53 @@ static int audio_formatChange(void *arg)
goto cleanup;
}
retval = SDL_SetAudioStreamFormat(stream, &spec1, &spec3);
if (!SDLTest_AssertCheck(retval == 0, "Expected SDL_SetAudioStreamFormat(spec1, spec3) to succeed")) {
result = SDL_SetAudioStreamFormat(stream, &spec1, &spec3);
if (!SDLTest_AssertCheck(result == SDL_TRUE, "Expected SDL_SetAudioStreamFormat(spec1, spec3) to succeed")) {
goto cleanup;
}
retval = SDL_GetAudioStreamAvailable(stream);
if (!SDLTest_AssertCheck(retval == 0, "Expected SDL_GetAudioStreamAvailable return 0")) {
result = SDL_GetAudioStreamAvailable(stream);
if (!SDLTest_AssertCheck(result == 0, "Expected SDL_GetAudioStreamAvailable return 0")) {
goto cleanup;
}
retval = SDL_PutAudioStreamData(stream, buffer_1, length_1);
if (!SDLTest_AssertCheck(retval == 0, "Expected SDL_PutAudioStreamData(buffer_1) to succeed")) {
result = SDL_PutAudioStreamData(stream, buffer_1, length_1);
if (!SDLTest_AssertCheck(result == SDL_TRUE, "Expected SDL_PutAudioStreamData(buffer_1) to succeed")) {
goto cleanup;
}
retval = SDL_FlushAudioStream(stream);
if (!SDLTest_AssertCheck(retval == 0, "Expected SDL_FlushAudioStream to succeed")) {
result = SDL_FlushAudioStream(stream);
if (!SDLTest_AssertCheck(result == SDL_TRUE, "Expected SDL_FlushAudioStream to succeed")) {
goto cleanup;
}
retval = SDL_SetAudioStreamFormat(stream, &spec2, &spec3);
if (!SDLTest_AssertCheck(retval == 0, "Expected SDL_SetAudioStreamFormat(spec2, spec3) to succeed")) {
result = SDL_SetAudioStreamFormat(stream, &spec2, &spec3);
if (!SDLTest_AssertCheck(result == SDL_TRUE, "Expected SDL_SetAudioStreamFormat(spec2, spec3) to succeed")) {
goto cleanup;
}
retval = SDL_PutAudioStreamData(stream, buffer_2, length_2);
if (!SDLTest_AssertCheck(retval == 0, "Expected SDL_PutAudioStreamData(buffer_1) to succeed")) {
result = SDL_PutAudioStreamData(stream, buffer_2, length_2);
if (!SDLTest_AssertCheck(result == SDL_TRUE, "Expected SDL_PutAudioStreamData(buffer_1) to succeed")) {
goto cleanup;
}
retval = SDL_FlushAudioStream(stream);
if (!SDLTest_AssertCheck(retval == 0, "Expected SDL_FlushAudioStream to succeed")) {
result = SDL_FlushAudioStream(stream);
if (!SDLTest_AssertCheck(result == SDL_TRUE, "Expected SDL_FlushAudioStream to succeed")) {
goto cleanup;
}
retval = SDL_GetAudioStreamAvailable(stream);
if (!SDLTest_AssertCheck(retval == length_3, "Expected SDL_GetAudioStreamAvailable to return %i, got %i", length_3, retval)) {
result = SDL_GetAudioStreamAvailable(stream);
if (!SDLTest_AssertCheck(result == length_3, "Expected SDL_GetAudioStreamAvailable to return %i, got %i", length_3, result)) {
goto cleanup;
}
retval = SDL_GetAudioStreamData(stream, buffer_3, length_3);
if (!SDLTest_AssertCheck(retval == length_3, "Expected SDL_GetAudioStreamData to return %i, got %i", length_3, retval)) {
result = SDL_GetAudioStreamData(stream, buffer_3, length_3);
if (!SDLTest_AssertCheck(result == length_3, "Expected SDL_GetAudioStreamData to return %i, got %i", length_3, result)) {
goto cleanup;
}
retval = SDL_GetAudioStreamAvailable(stream);
if (!SDLTest_AssertCheck(retval == 0, "Expected SDL_GetAudioStreamAvailable to return 0")) {
result = SDL_GetAudioStreamAvailable(stream);
if (!SDLTest_AssertCheck(result == 0, "Expected SDL_GetAudioStreamAvailable to return 0")) {
goto cleanup;
}

View File

@@ -105,16 +105,16 @@ static int clipboard_testClipboardDataFunctions(void *arg)
/* Test clearing clipboard data */
result = SDL_ClearClipboardData();
SDLTest_AssertCheck(
result == 0,
"Validate SDL_ClearClipboardData result, expected 0, got %i",
result == SDL_TRUE,
"Validate SDL_ClearClipboardData result, expected SDL_TRUE, got %i",
result);
/* Test clearing clipboard data when it's already clear */
last_clipboard_update_count = clipboard_update_count;
result = SDL_ClearClipboardData();
SDLTest_AssertCheck(
result == 0,
"Validate SDL_ClearClipboardData result, expected 0, got %i",
result == SDL_TRUE,
"Validate SDL_ClearClipboardData result, expected SDL_TRUE, got %i",
result);
SDLTest_AssertCheck(
clipboard_update_count == last_clipboard_update_count,
@@ -125,8 +125,8 @@ static int clipboard_testClipboardDataFunctions(void *arg)
last_clipboard_update_count = clipboard_update_count;
result = SDL_SetClipboardData(NULL, NULL, NULL, test_mime_types, SDL_arraysize(test_mime_types));
SDLTest_AssertCheck(
result == -1,
"Validate SDL_SetClipboardData(invalid) result, expected -1, got %i",
result == SDL_FALSE,
"Validate SDL_SetClipboardData(invalid) result, expected SDL_FALSE, got %i",
result);
SDLTest_AssertCheck(
clipboard_update_count == last_clipboard_update_count,
@@ -136,8 +136,8 @@ static int clipboard_testClipboardDataFunctions(void *arg)
last_clipboard_update_count = clipboard_update_count;
result = SDL_SetClipboardData(ClipboardDataCallback, ClipboardCleanupCallback, NULL, NULL, 0);
SDLTest_AssertCheck(
result == -1,
"Validate SDL_SetClipboardData(invalid) result, expected -1, got %i",
result == SDL_FALSE,
"Validate SDL_SetClipboardData(invalid) result, expected SDL_FALSE, got %i",
result);
SDLTest_AssertCheck(
clipboard_update_count == last_clipboard_update_count,
@@ -150,8 +150,8 @@ static int clipboard_testClipboardDataFunctions(void *arg)
last_clipboard_cleanup_count = clipboard_cleanup_count;
result = SDL_SetClipboardData(ClipboardDataCallback, ClipboardCleanupCallback, &test_data1, test_mime_types, SDL_arraysize(test_mime_types));
SDLTest_AssertCheck(
result == 0,
"Validate SDL_SetClipboardData(test_data1) result, expected 0, got %i",
result == SDL_TRUE,
"Validate SDL_SetClipboardData(test_data1) result, expected SDL_TRUE, got %i",
result);
SDLTest_AssertCheck(
clipboard_update_count == last_clipboard_update_count + 1,
@@ -262,8 +262,8 @@ static int clipboard_testClipboardDataFunctions(void *arg)
last_clipboard_cleanup_count = clipboard_cleanup_count;
result = SDL_SetClipboardData(ClipboardDataCallback, ClipboardCleanupCallback, &test_data2, test_mime_types, SDL_arraysize(test_mime_types));
SDLTest_AssertCheck(
result == 0,
"Validate SDL_SetClipboardData(test_data2) result, expected 0, got %i",
result == SDL_TRUE,
"Validate SDL_SetClipboardData(test_data2) result, expected SDL_TRUE, got %i",
result);
SDLTest_AssertCheck(
clipboard_update_count == last_clipboard_update_count + 1,
@@ -365,8 +365,8 @@ static int clipboard_testClipboardDataFunctions(void *arg)
last_clipboard_cleanup_count = clipboard_cleanup_count;
result = SDL_ClearClipboardData();
SDLTest_AssertCheck(
result == 0,
"Validate SDL_ClearClipboardData result, expected 0, got %i",
result == SDL_TRUE,
"Validate SDL_ClearClipboardData result, expected SDL_TRUE, got %i",
result);
SDLTest_AssertCheck(
clipboard_update_count == last_clipboard_update_count + 1,
@@ -415,8 +415,8 @@ static int clipboard_testClipboardTextFunctions(void *arg)
last_clipboard_update_count = clipboard_update_count;
intResult = SDL_SetClipboardText(NULL);
SDLTest_AssertCheck(
intResult == 0,
"Verify result from SDL_SetClipboardText(NULL), expected 0, got %i",
intResult == SDL_TRUE,
"Verify result from SDL_SetClipboardText(NULL), expected SDL_TRUE, got %i",
intResult);
charResult = SDL_GetClipboardText();
SDLTest_AssertCheck(
@@ -439,8 +439,8 @@ static int clipboard_testClipboardTextFunctions(void *arg)
last_clipboard_update_count = clipboard_update_count;
intResult = SDL_SetClipboardText(text);
SDLTest_AssertCheck(
intResult == 0,
"Verify result from SDL_SetClipboardText(%s), expected 0, got %i", text,
intResult == SDL_TRUE,
"Verify result from SDL_SetClipboardText(%s), expected SDL_TRUE, got %i", text,
intResult);
SDLTest_AssertCheck(
SDL_strcmp(textRef, text) == 0,
@@ -465,8 +465,8 @@ static int clipboard_testClipboardTextFunctions(void *arg)
/* Reset clipboard text */
intResult = SDL_SetClipboardText(NULL);
SDLTest_AssertCheck(
intResult == 0,
"Verify result from SDL_SetClipboardText(NULL), expected 0, got %i",
intResult == SDL_TRUE,
"Verify result from SDL_SetClipboardText(NULL), expected SDL_TRUE, got %i",
intResult);
/* Cleanup */
@@ -499,8 +499,8 @@ static int clipboard_testPrimarySelectionTextFunctions(void *arg)
last_clipboard_update_count = clipboard_update_count;
intResult = SDL_SetPrimarySelectionText(NULL);
SDLTest_AssertCheck(
intResult == 0,
"Verify result from SDL_SetPrimarySelectionText(NULL), expected 0, got %i",
intResult == SDL_TRUE,
"Verify result from SDL_SetPrimarySelectionText(NULL), expected SDL_TRUE, got %i",
intResult);
charResult = SDL_GetPrimarySelectionText();
SDLTest_AssertCheck(
@@ -522,8 +522,8 @@ static int clipboard_testPrimarySelectionTextFunctions(void *arg)
last_clipboard_update_count = clipboard_update_count;
intResult = SDL_SetPrimarySelectionText(text);
SDLTest_AssertCheck(
intResult == 0,
"Verify result from SDL_SetPrimarySelectionText(%s), expected 0, got %i", text,
intResult == SDL_TRUE,
"Verify result from SDL_SetPrimarySelectionText(%s), expected SDL_TRUE, got %i", text,
intResult);
SDLTest_AssertCheck(
SDL_strcmp(textRef, text) == 0,
@@ -548,8 +548,8 @@ static int clipboard_testPrimarySelectionTextFunctions(void *arg)
/* Reset primary selection */
intResult = SDL_SetPrimarySelectionText(NULL);
SDLTest_AssertCheck(
intResult == 0,
"Verify result from SDL_SetPrimarySelectionText(NULL), expected 0, got %i",
intResult == SDL_TRUE,
"Verify result from SDL_SetPrimarySelectionText(NULL), expected SDL_TRUE, got %i",
intResult);
/* Cleanup */

View File

@@ -275,7 +275,7 @@ static int iostrm_testMem(void *arg)
/* Close */
result = SDL_CloseIO(rw);
SDLTest_AssertPass("Call to SDL_CloseIO() succeeded");
SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Verify result value is SDL_TRUE; got: %d", result);
return TEST_COMPLETED;
}
@@ -307,7 +307,7 @@ static int iostrm_testConstMem(void *arg)
/* Close handle */
result = SDL_CloseIO(rw);
SDLTest_AssertPass("Call to SDL_CloseIO() succeeded");
SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Verify result value is SDL_TRUE; got: %d", result);
return TEST_COMPLETED;
}
@@ -356,7 +356,7 @@ static int iostrm_testDynamicMem(void *arg)
/* Close */
result = SDL_CloseIO(rw);
SDLTest_AssertPass("Call to SDL_CloseIO() succeeded");
SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Verify result value is SDL_TRUE; got: %d", result);
return TEST_COMPLETED;
}
@@ -388,7 +388,7 @@ static int iostrm_testFileRead(void *arg)
/* Close handle */
result = SDL_CloseIO(rw);
SDLTest_AssertPass("Call to SDL_CloseIO() succeeded");
SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Verify result value is SDL_TRUE; got: %d", result);
return TEST_COMPLETED;
}
@@ -420,7 +420,7 @@ static int iostrm_testFileWrite(void *arg)
/* Close handle */
result = SDL_CloseIO(rw);
SDLTest_AssertPass("Call to SDL_CloseIO() succeeded");
SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Verify result value is SDL_TRUE; got: %d", result);
return TEST_COMPLETED;
}
@@ -486,7 +486,7 @@ static int iostrm_testCompareRWFromMemWithRWFromFile(void *arg)
SDLTest_AssertPass("Call to SDL_SeekIO(mem,SEEK_END)");
result = SDL_CloseIO(iostrm_mem);
SDLTest_AssertPass("Call to SDL_CloseIO(mem)");
SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Verify result value is SDL_TRUE; got: %d", result);
/* Read/see from file */
iostrm_file = SDL_IOFromFile(IOStreamAlphabetFilename, "r");
@@ -497,7 +497,7 @@ static int iostrm_testCompareRWFromMemWithRWFromFile(void *arg)
SDLTest_AssertPass("Call to SDL_SeekIO(file,SEEK_END)");
result = SDL_CloseIO(iostrm_file);
SDLTest_AssertPass("Call to SDL_CloseIO(file)");
SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Verify result value is SDL_TRUE; got: %d", result);
/* Compare */
SDLTest_AssertCheck(rv_mem == rv_file, "Verify returned read blocks matches for mem and file reads; got: rv_mem=%d rv_file=%d", (int)rv_mem, (int)rv_file);
@@ -641,7 +641,7 @@ static int iostrm_testFileWriteReadEndian(void *arg)
/* Close handle */
cresult = SDL_CloseIO(rw);
SDLTest_AssertPass("Call to SDL_CloseIO() succeeded");
SDLTest_AssertCheck(cresult == 0, "Verify result value is 0; got: %d", cresult);
SDLTest_AssertCheck(cresult == SDL_TRUE, "Verify result value is SDL_TRUE; got: %d", cresult);
}
return TEST_COMPLETED;

View File

@@ -23,7 +23,7 @@ static int TestVirtualJoystick(void *arg)
SDL_Gamepad *gamepad = NULL;
SDL_JoystickID device_id;
SDLTest_AssertCheck(SDL_InitSubSystem(SDL_INIT_GAMEPAD) == 0, "SDL_InitSubSystem(SDL_INIT_GAMEPAD)");
SDLTest_AssertCheck(SDL_InitSubSystem(SDL_INIT_GAMEPAD), "SDL_InitSubSystem(SDL_INIT_GAMEPAD)");
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");
@@ -86,11 +86,11 @@ static int TestVirtualJoystick(void *arg)
SDLTest_AssertCheck(nbuttons == desc.nbuttons, "SDL_GetNumJoystickButtons() -> %d (expected %d)", nbuttons, desc.nbuttons);
}
SDLTest_AssertCheck(SDL_SetJoystickVirtualButton(joystick, SDL_GAMEPAD_BUTTON_SOUTH, SDL_PRESSED) == 0, "SDL_SetJoystickVirtualButton(SDL_GAMEPAD_BUTTON_SOUTH, SDL_PRESSED)");
SDLTest_AssertCheck(SDL_SetJoystickVirtualButton(joystick, SDL_GAMEPAD_BUTTON_SOUTH, SDL_PRESSED), "SDL_SetJoystickVirtualButton(SDL_GAMEPAD_BUTTON_SOUTH, SDL_PRESSED)");
SDL_UpdateJoysticks();
SDLTest_AssertCheck(SDL_GetJoystickButton(joystick, SDL_GAMEPAD_BUTTON_SOUTH) == SDL_PRESSED, "SDL_GetJoystickButton(SDL_GAMEPAD_BUTTON_SOUTH) == SDL_PRESSED");
SDLTest_AssertCheck(SDL_SetJoystickVirtualButton(joystick, SDL_GAMEPAD_BUTTON_SOUTH, SDL_RELEASED) == 0, "SDL_SetJoystickVirtualButton(SDL_GAMEPAD_BUTTON_SOUTH, SDL_RELEASED)");
SDLTest_AssertCheck(SDL_SetJoystickVirtualButton(joystick, SDL_GAMEPAD_BUTTON_SOUTH, SDL_RELEASED), "SDL_SetJoystickVirtualButton(SDL_GAMEPAD_BUTTON_SOUTH, SDL_RELEASED)");
SDL_UpdateJoysticks();
SDLTest_AssertCheck(SDL_GetJoystickButton(joystick, SDL_GAMEPAD_BUTTON_SOUTH) == SDL_RELEASED, "SDL_GetJoystickButton(SDL_GAMEPAD_BUTTON_SOUTH) == SDL_RELEASED");
@@ -124,11 +124,11 @@ static int TestVirtualJoystick(void *arg)
SDLTest_AssertCheck(SDL_GetGamepadButtonLabel(gamepad, SDL_GAMEPAD_BUTTON_SOUTH) == SDL_GAMEPAD_BUTTON_LABEL_A, "SDL_GetGamepadButtonLabel(SDL_GAMEPAD_BUTTON_SOUTH) == SDL_GAMEPAD_BUTTON_LABEL_A");
/* Set the south button and verify that the gamepad responds */
SDLTest_AssertCheck(SDL_SetJoystickVirtualButton(joystick, SDL_GAMEPAD_BUTTON_SOUTH, SDL_PRESSED) == 0, "SDL_SetJoystickVirtualButton(SDL_GAMEPAD_BUTTON_SOUTH, SDL_PRESSED) == 0");
SDLTest_AssertCheck(SDL_SetJoystickVirtualButton(joystick, SDL_GAMEPAD_BUTTON_SOUTH, SDL_PRESSED), "SDL_SetJoystickVirtualButton(SDL_GAMEPAD_BUTTON_SOUTH, SDL_PRESSED)");
SDL_UpdateJoysticks();
SDLTest_AssertCheck(SDL_GetGamepadButton(gamepad, SDL_GAMEPAD_BUTTON_SOUTH) == SDL_PRESSED, "SDL_GetGamepadButton(SDL_GAMEPAD_BUTTON_SOUTH) == SDL_PRESSED");
SDLTest_AssertCheck(SDL_SetJoystickVirtualButton(joystick, SDL_GAMEPAD_BUTTON_SOUTH, SDL_RELEASED) == 0, "SDL_SetJoystickVirtualButton(SDL_GAMEPAD_BUTTON_SOUTH, SDL_RELEASED) == 0");
SDLTest_AssertCheck(SDL_SetJoystickVirtualButton(joystick, SDL_GAMEPAD_BUTTON_SOUTH, SDL_RELEASED), "SDL_SetJoystickVirtualButton(SDL_GAMEPAD_BUTTON_SOUTH, SDL_RELEASED)");
SDL_UpdateJoysticks();
SDLTest_AssertCheck(SDL_GetGamepadButton(gamepad, SDL_GAMEPAD_BUTTON_SOUTH) == SDL_RELEASED, "SDL_GetGamepadButton(SDL_GAMEPAD_BUTTON_SOUTH) == SDL_RELEASED");
@@ -141,11 +141,11 @@ static int TestVirtualJoystick(void *arg)
SDLTest_AssertCheck(SDL_GetGamepadButtonLabel(gamepad, SDL_GAMEPAD_BUTTON_SOUTH) == SDL_GAMEPAD_BUTTON_LABEL_B, "SDL_GetGamepadButtonLabel(SDL_GAMEPAD_BUTTON_SOUTH) == SDL_GAMEPAD_BUTTON_LABEL_B");
/* Set the south button and verify that the gamepad responds */
SDLTest_AssertCheck(SDL_SetJoystickVirtualButton(joystick, SDL_GAMEPAD_BUTTON_SOUTH, SDL_PRESSED) == 0, "SDL_SetJoystickVirtualButton(SDL_GAMEPAD_BUTTON_SOUTH, SDL_PRESSED) == 0");
SDLTest_AssertCheck(SDL_SetJoystickVirtualButton(joystick, SDL_GAMEPAD_BUTTON_SOUTH, SDL_PRESSED), "SDL_SetJoystickVirtualButton(SDL_GAMEPAD_BUTTON_SOUTH, SDL_PRESSED)");
SDL_UpdateJoysticks();
SDLTest_AssertCheck(SDL_GetGamepadButton(gamepad, SDL_GAMEPAD_BUTTON_SOUTH) == SDL_PRESSED, "SDL_GetGamepadButton(SDL_GAMEPAD_BUTTON_SOUTH) == SDL_PRESSED");
SDLTest_AssertCheck(SDL_SetJoystickVirtualButton(joystick, SDL_GAMEPAD_BUTTON_SOUTH, SDL_RELEASED) == 0, "SDL_SetJoystickVirtualButton(SDL_GAMEPAD_BUTTON_SOUTH, SDL_RELEASED) == 0");
SDLTest_AssertCheck(SDL_SetJoystickVirtualButton(joystick, SDL_GAMEPAD_BUTTON_SOUTH, SDL_RELEASED), "SDL_SetJoystickVirtualButton(SDL_GAMEPAD_BUTTON_SOUTH, SDL_RELEASED)");
SDL_UpdateJoysticks();
SDLTest_AssertCheck(SDL_GetGamepadButton(gamepad, SDL_GAMEPAD_BUTTON_SOUTH) == SDL_RELEASED, "SDL_GetGamepadButton(SDL_GAMEPAD_BUTTON_SOUTH) == SDL_RELEASED");
@@ -158,11 +158,11 @@ static int TestVirtualJoystick(void *arg)
SDLTest_AssertCheck(SDL_GetGamepadButtonLabel(gamepad, SDL_GAMEPAD_BUTTON_SOUTH) == SDL_GAMEPAD_BUTTON_LABEL_CROSS, "SDL_GetGamepadButtonLabel(SDL_GAMEPAD_BUTTON_SOUTH) == SDL_GAMEPAD_BUTTON_LABEL_CROSS");
/* Set the south button and verify that the gamepad responds */
SDLTest_AssertCheck(SDL_SetJoystickVirtualButton(joystick, SDL_GAMEPAD_BUTTON_SOUTH, SDL_PRESSED) == 0, "SDL_SetJoystickVirtualButton(SDL_GAMEPAD_BUTTON_SOUTH, SDL_PRESSED) == 0");
SDLTest_AssertCheck(SDL_SetJoystickVirtualButton(joystick, SDL_GAMEPAD_BUTTON_SOUTH, SDL_PRESSED), "SDL_SetJoystickVirtualButton(SDL_GAMEPAD_BUTTON_SOUTH, SDL_PRESSED)");
SDL_UpdateJoysticks();
SDLTest_AssertCheck(SDL_GetGamepadButton(gamepad, SDL_GAMEPAD_BUTTON_SOUTH) == SDL_PRESSED, "SDL_GetGamepadButton(SDL_GAMEPAD_BUTTON_SOUTH) == SDL_PRESSED");
SDLTest_AssertCheck(SDL_SetJoystickVirtualButton(joystick, SDL_GAMEPAD_BUTTON_SOUTH, SDL_RELEASED) == 0, "SDL_SetJoystickVirtualButton(SDL_GAMEPAD_BUTTON_SOUTH, SDL_RELEASED) == 0");
SDLTest_AssertCheck(SDL_SetJoystickVirtualButton(joystick, SDL_GAMEPAD_BUTTON_SOUTH, SDL_RELEASED), "SDL_SetJoystickVirtualButton(SDL_GAMEPAD_BUTTON_SOUTH, SDL_RELEASED)");
SDL_UpdateJoysticks();
SDLTest_AssertCheck(SDL_GetGamepadButton(gamepad, SDL_GAMEPAD_BUTTON_SOUTH) == SDL_RELEASED, "SDL_GetGamepadButton(SDL_GAMEPAD_BUTTON_SOUTH) == SDL_RELEASED");
@@ -171,7 +171,7 @@ static int TestVirtualJoystick(void *arg)
SDL_CloseJoystick(joystick);
}
SDLTest_AssertCheck(SDL_DetachVirtualJoystick(device_id) == 0, "SDL_DetachVirtualJoystick()");
SDLTest_AssertCheck(SDL_DetachVirtualJoystick(device_id), "SDL_DetachVirtualJoystick()");
}
SDLTest_AssertCheck(!SDL_IsJoystickVirtual(device_id), "!SDL_IsJoystickVirtual()");

View File

@@ -26,7 +26,7 @@ static int main_testInitQuitSubSystem(void *arg)
int subsystem = subsystems[i];
SDLTest_AssertCheck((SDL_WasInit(subsystem) & subsystem) == 0, "SDL_WasInit(%x) before init should be false", subsystem);
SDLTest_AssertCheck(SDL_InitSubSystem(subsystem) == 0, "SDL_InitSubSystem(%x)", subsystem);
SDLTest_AssertCheck(SDL_InitSubSystem(subsystem), "SDL_InitSubSystem(%x)", subsystem);
initialized_system = SDL_WasInit(subsystem);
SDLTest_AssertCheck((initialized_system & subsystem) != 0, "SDL_WasInit(%x) should be true (%x)", subsystem, initialized_system);
@@ -46,7 +46,7 @@ static int main_testImpliedJoystickInit(void *arg)
/* First initialize the controller */
SDLTest_AssertCheck((SDL_WasInit(joy_and_controller) & joy_and_controller) == 0, "SDL_WasInit() before init should be false for joystick & controller");
SDLTest_AssertCheck(SDL_InitSubSystem(SDL_INIT_GAMEPAD) == 0, "SDL_InitSubSystem(SDL_INIT_GAMEPAD)");
SDLTest_AssertCheck(SDL_InitSubSystem(SDL_INIT_GAMEPAD), "SDL_InitSubSystem(SDL_INIT_GAMEPAD)");
/* Then make sure this implicitly initialized the joystick subsystem */
initialized_system = SDL_WasInit(joy_and_controller);
@@ -67,8 +67,8 @@ static int main_testImpliedJoystickQuit(void *arg)
/* First initialize the controller and the joystick (explicitly) */
SDLTest_AssertCheck((SDL_WasInit(joy_and_controller) & joy_and_controller) == 0, "SDL_WasInit() before init should be false for joystick & controller");
SDLTest_AssertCheck(SDL_InitSubSystem(SDL_INIT_JOYSTICK) == 0, "SDL_InitSubSystem(SDL_INIT_JOYSTICK)");
SDLTest_AssertCheck(SDL_InitSubSystem(SDL_INIT_GAMEPAD) == 0, "SDL_InitSubSystem(SDL_INIT_GAMEPAD)");
SDLTest_AssertCheck(SDL_InitSubSystem(SDL_INIT_JOYSTICK), "SDL_InitSubSystem(SDL_INIT_JOYSTICK)");
SDLTest_AssertCheck(SDL_InitSubSystem(SDL_INIT_GAMEPAD), "SDL_InitSubSystem(SDL_INIT_GAMEPAD)");
/* Then make sure they're both initialized properly */
initialized_system = SDL_WasInit(joy_and_controller);
@@ -101,13 +101,13 @@ main_testSetError(void *arg)
SDLTest_AssertPass("SDL_SetError(NULL)");
result = SDL_SetError(NULL);
SDLTest_AssertCheck(result == -1, "SDL_SetError(NULL) -> %d (expected %d)", result, -1);
SDLTest_AssertCheck(result == SDL_FALSE, "SDL_SetError(NULL) -> %d (expected %d)", result, SDL_FALSE);
error = SDL_GetError();
SDLTest_AssertCheck(SDL_strcmp(error, "") == 0, "SDL_GetError() -> \"%s\" (expected \"%s\")", error, "");
SDLTest_AssertPass("SDL_SetError(\"\")");
result = SDL_SetError("");
SDLTest_AssertCheck(result == -1, "SDL_SetError(\"\") -> %d (expected %d)", result, -1);
SDLTest_AssertCheck(result == SDL_FALSE, "SDL_SetError(\"\") -> %d (expected %d)", result, SDL_FALSE);
error = SDL_GetError();
SDLTest_AssertCheck(SDL_strcmp(error, "") == 0, "SDL_GetError() -> \"%s\" (expected \"%s\")", error, "");
@@ -118,7 +118,7 @@ main_testSetError(void *arg)
error_input[i] = '\0';
SDLTest_AssertPass("SDL_SetError(\"abc...\")");
result = SDL_SetError("%s", error_input);
SDLTest_AssertCheck(result == -1, "SDL_SetError(\"abc...\") -> %d (expected %d)", result, -1);
SDLTest_AssertCheck(result == SDL_FALSE, "SDL_SetError(\"abc...\") -> %d (expected %d)", result, SDL_FALSE);
error = SDL_GetError();
#ifdef SDL_THREADS_DISABLED

View File

@@ -402,7 +402,7 @@ static int mouse_getSetRelativeMouseMode(void *arg)
/* Disable - should always be supported */
result = SDL_SetWindowRelativeMouseMode(window, SDL_FALSE);
SDLTest_AssertPass("Call to SDL_SetWindowRelativeMouseMode(window, FALSE)");
SDLTest_AssertCheck(result == 0, "Validate result value from SDL_SetWindowRelativeMouseMode, expected: 0, got: %i", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Validate result value from SDL_SetWindowRelativeMouseMode, expected: SDL_TRUE, got: %i", result);
currentState = SDL_GetWindowRelativeMouseMode(window);
SDLTest_AssertPass("Call to SDL_GetWindowRelativeMouseMode(window)");
SDLTest_AssertCheck(currentState == SDL_FALSE, "Validate current state is FALSE, got: %i", currentState);
@@ -414,7 +414,7 @@ static int mouse_getSetRelativeMouseMode(void *arg)
result = SDL_SetWindowRelativeMouseMode(window, SDL_TRUE);
SDLTest_AssertPass("Call to SDL_SetWindowRelativeMouseMode(window, TRUE)");
if (result != -1) {
SDLTest_AssertCheck(result == 0, "Validate result value from SDL_SetWindowRelativeMouseMode, expected: 0, got: %i", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Validate result value from SDL_SetWindowRelativeMouseMode, expected: SDL_TRUE, got: %i", result);
currentState = SDL_GetWindowRelativeMouseMode(window);
SDLTest_AssertPass("Call to SDL_GetWindowRelativeMouseMode(window)");
SDLTest_AssertCheck(currentState == SDL_TRUE, "Validate current state is TRUE, got: %i", currentState);
@@ -424,7 +424,7 @@ static int mouse_getSetRelativeMouseMode(void *arg)
/* Disable to check E->D transition */
result = SDL_SetWindowRelativeMouseMode(window, SDL_FALSE);
SDLTest_AssertPass("Call to SDL_SetWindowRelativeMouseMode(window, FALSE)");
SDLTest_AssertCheck(result == 0, "Validate result value from SDL_SetWindowRelativeMouseMode, expected: 0, got: %i", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Validate result value from SDL_SetWindowRelativeMouseMode, expected: SDL_TRUE, got: %i", result);
currentState = SDL_GetWindowRelativeMouseMode(window);
SDLTest_AssertPass("Call to SDL_GetWindowRelativeMouseMode(window)");
SDLTest_AssertCheck(currentState == SDL_FALSE, "Validate current state is FALSE, got: %i", currentState);

View File

@@ -223,7 +223,7 @@ static int platform_testGetVersion(void *arg)
*/
static int platform_testDefaultInit(void *arg)
{
int ret;
SDL_bool ret;
int subsystem;
subsystem = SDL_WasInit(0);
@@ -232,8 +232,8 @@ static int platform_testDefaultInit(void *arg)
subsystem);
ret = SDL_Init(0);
SDLTest_AssertCheck(ret == 0,
"SDL_Init(0): returned %i, expected 0, error: %s",
SDLTest_AssertCheck(ret == SDL_TRUE,
"SDL_Init(0): returned %i, expected SDL_TRUE, error: %s",
ret,
SDL_GetError());
@@ -268,7 +268,7 @@ static int platform_testGetSetClearError(void *arg)
result = SDL_SetError("%s", testError);
SDLTest_AssertPass("SDL_SetError()");
SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result);
SDLTest_AssertCheck(result == SDL_FALSE, "SDL_SetError: expected SDL_FALSE, got: %i", result);
lastError = SDL_GetError();
SDLTest_AssertCheck(lastError != NULL,
"SDL_GetError() != NULL");
@@ -304,7 +304,7 @@ static int platform_testSetErrorEmptyInput(void *arg)
result = SDL_SetError("%s", testError);
SDLTest_AssertPass("SDL_SetError()");
SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result);
SDLTest_AssertCheck(result == SDL_FALSE, "SDL_SetError: expected SDL_FALSE, got: %i", result);
lastError = SDL_GetError();
SDLTest_AssertCheck(lastError != NULL,
"SDL_GetError() != NULL");
@@ -351,7 +351,7 @@ static int platform_testSetErrorInvalidInput(void *arg)
/* Check for no-op */
result = SDL_SetError("%s", invalidError);
SDLTest_AssertPass("SDL_SetError()");
SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result);
SDLTest_AssertCheck(result == SDL_FALSE, "SDL_SetError: expected SDL_FALSE, got: %i", result);
lastError = SDL_GetError();
SDLTest_AssertCheck(lastError != NULL,
"SDL_GetError() != NULL");
@@ -365,12 +365,12 @@ static int platform_testSetErrorInvalidInput(void *arg)
/* Set */
result = SDL_SetError("%s", probeError);
SDLTest_AssertPass("SDL_SetError('%s')", probeError);
SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result);
SDLTest_AssertCheck(result == SDL_FALSE, "SDL_SetError: expected SDL_FALSE, got: %i", result);
/* Check for no-op */
result = SDL_SetError("%s", invalidError);
SDLTest_AssertPass("SDL_SetError(NULL)");
SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result);
SDLTest_AssertCheck(result == SDL_FALSE, "SDL_SetError: expected SDL_FALSE, got: %i", result);
lastError = SDL_GetError();
SDLTest_AssertCheck(lastError != NULL,
"SDL_GetError() != NULL");
@@ -388,7 +388,7 @@ static int platform_testSetErrorInvalidInput(void *arg)
/* Set and check */
result = SDL_SetError("%s", probeError);
SDLTest_AssertPass("SDL_SetError()");
SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result);
SDLTest_AssertCheck(result == SDL_FALSE, "SDL_SetError: expected SDL_FALSE, got: %i", result);
lastError = SDL_GetError();
SDLTest_AssertCheck(lastError != NULL,
"SDL_GetError() != NULL");

View File

@@ -45,7 +45,7 @@ static int properties_testBasic(void *arg)
SDL_snprintf(expected_value, SDL_arraysize(expected_value), "%c", 'a' + i);
result = SDL_SetPointerProperty(props, key, expected_value);
SDLTest_AssertPass("Call to SDL_SetPointerProperty()");
SDLTest_AssertCheck(result == 0,
SDLTest_AssertCheck(result == SDL_TRUE,
"Verify property value was set, got: %d", result);
value = SDL_GetPointerProperty(props, key, NULL);
SDLTest_AssertPass("Call to SDL_GetPointerProperty()");
@@ -62,7 +62,7 @@ static int properties_testBasic(void *arg)
SDL_snprintf(key, SDL_arraysize(key), "%c", 'a' + i);
result = SDL_SetPointerProperty(props, key, NULL);
SDLTest_AssertPass("Call to SDL_SetPointerProperty(NULL)");
SDLTest_AssertCheck(result == 0,
SDLTest_AssertCheck(result == SDL_TRUE,
"Verify property value was set, got: %d", result);
value = SDL_GetPointerProperty(props, key, NULL);
SDLTest_AssertPass("Call to SDL_GetPointerProperty()");
@@ -238,18 +238,18 @@ static int properties_testCopy(void *arg)
SDLTest_AssertPass("Call to SDL_CopyProperties(a, 0)");
result = SDL_CopyProperties(a, 0);
SDLTest_AssertCheck(result == -1,
"SDL_CopyProperties() result, got %d, expected -1", result);
SDLTest_AssertCheck(result == SDL_FALSE,
"SDL_CopyProperties() result, got %d, expected SDL_FALSE", result);
SDLTest_AssertPass("Call to SDL_CopyProperties(0, b)");
result = SDL_CopyProperties(0, b);
SDLTest_AssertCheck(result == -1,
"SDL_CopyProperties() result, got %d, expected -1", result);
SDLTest_AssertCheck(result == SDL_FALSE,
"SDL_CopyProperties() result, got %d, expected SDL_FALSE", result);
SDLTest_AssertPass("Call to SDL_CopyProperties(a, b)");
result = SDL_CopyProperties(a, b);
SDLTest_AssertCheck(result == 0,
"SDL_CopyProperties() result, got %d, expected 0", result);
SDLTest_AssertCheck(result == SDL_TRUE,
"SDL_CopyProperties() result, got %d, expected SDL_TRUE", result);
SDL_DestroyProperties(a);

View File

@@ -22,9 +22,9 @@
#define CHECK_FUNC(FUNC, PARAMS) \
{ \
int result = FUNC PARAMS; \
if (result != 0) { \
SDLTest_AssertCheck(result == 0, "Validate result from %s, expected: 0, got: %i, %s", #FUNC, result, SDL_GetError()); \
SDL_bool result = FUNC PARAMS; \
if (!result) { \
SDLTest_AssertCheck(result, "Validate result from %s, expected: SDL_TRUE, got: SDL_FALSE, %s", #FUNC, SDL_GetError()); \
} \
}
@@ -38,8 +38,8 @@ static int clearScreen(void);
static void compare(SDL_Surface *reference, int allowable_error);
static void compare2x(SDL_Surface *reference, int allowable_error);
static SDL_Texture *loadTestFace(void);
static int hasDrawColor(void);
static int isSupported(int code);
static SDL_bool isSupported(int code);
static SDL_bool hasDrawColor(void);
/**
* Create software renderer for tests
@@ -145,12 +145,12 @@ static int render_testPrimitives(void *arg)
for (y = 0; y < 3; y++) {
for (x = y % 2; x < TESTRENDER_SCREEN_W; x += 2) {
ret = SDL_SetRenderDrawColor(renderer, (Uint8)(x * y), (Uint8)(x * y / 2), (Uint8)(x * y / 3), SDL_ALPHA_OPAQUE);
if (ret != 0) {
if (!ret) {
checkFailCount1++;
}
ret = SDL_RenderPoint(renderer, (float)x, (float)y);
if (ret != 0) {
if (!ret) {
checkFailCount2++;
}
}
@@ -271,7 +271,7 @@ static int render_testBlit(void *arg)
rect.x = i;
rect.y = j;
ret = SDL_RenderTexture(renderer, tface, NULL, &rect);
if (ret != 0) {
if (!ret) {
checkFailCount1++;
}
}
@@ -323,7 +323,7 @@ static int render_testBlitTiled(void *arg)
rect.w = (float)TESTRENDER_SCREEN_W;
rect.h = (float)TESTRENDER_SCREEN_H;
ret = SDL_RenderTextureTiled(renderer, tface, NULL, 1.0f, &rect);
SDLTest_AssertCheck(ret == 0, "Validate results from call to SDL_RenderTextureTiled, expected: 0, got: %i", ret);
SDLTest_AssertCheck(ret == SDL_TRUE, "Validate results from call to SDL_RenderTextureTiled, expected: SDL_TRUE, got: %i", ret);
/* See if it's the same */
referenceSurface = SDLTest_ImageBlitTiled();
@@ -344,12 +344,12 @@ static int render_testBlitTiled(void *arg)
rect.w = (float)TESTRENDER_SCREEN_W * 2;
rect.h = (float)TESTRENDER_SCREEN_H * 2;
ret = SDL_RenderTextureTiled(renderer, tface, NULL, 2.0f, &rect);
SDLTest_AssertCheck(ret == 0, "Validate results from call to SDL_RenderTextureTiled, expected: 0, got: %i", ret);
SDLTest_AssertCheck(ret == SDL_TRUE, "Validate results from call to SDL_RenderTextureTiled, expected: SDL_TRUE, got: %i", ret);
/* See if it's the same */
referenceSurface2x = SDL_CreateSurface(referenceSurface->w * 2, referenceSurface->h * 2, referenceSurface->format);
SDL_BlitSurfaceScaled(referenceSurface, NULL, referenceSurface2x, NULL, SDL_SCALEMODE_NEAREST);
SDLTest_AssertCheck(ret == 0, "Validate results from call to SDL_BlitSurfaceScaled, expected: 0, got: %i", ret);
SDLTest_AssertCheck(ret == SDL_TRUE, "Validate results from call to SDL_BlitSurfaceScaled, expected: 0, got: %i", ret);
compare2x(referenceSurface2x, ALLOWABLE_ERROR_OPAQUE);
/* Make current */
@@ -458,7 +458,7 @@ static int render_testBlit9Grid(void *arg)
texture = SDL_CreateTextureFromSurface(renderer, source);
SDLTest_AssertCheck(texture != NULL, "Verify source texture is not NULL");
ret = SDL_SetTextureScaleMode(texture, SDL_SCALEMODE_NEAREST);
SDLTest_AssertCheck(ret == 0, "Validate results from call to SDL_SetTextureScaleMode, expected: 0, got: %i", ret);
SDLTest_AssertCheck(ret == SDL_TRUE, "Validate results from call to SDL_SetTextureScaleMode, expected: SDL_TRUE, got: %i", ret);
/* 9-grid blit - 1.0 scale */
{
@@ -478,7 +478,7 @@ static int render_testBlit9Grid(void *arg)
rect.w = (float)TESTRENDER_SCREEN_W;
rect.h = (float)TESTRENDER_SCREEN_H;
ret = SDL_RenderTexture9Grid(renderer, texture, NULL, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, &rect);
SDLTest_AssertCheck(ret == 0, "Validate results from call to SDL_RenderTexture9Grid, expected: 0, got: %i", ret);
SDLTest_AssertCheck(ret == SDL_TRUE, "Validate results from call to SDL_RenderTexture9Grid, expected: SDL_TRUE, got: %i", ret);
/* See if it's the same */
compare(referenceSurface, ALLOWABLE_ERROR_OPAQUE);
@@ -505,7 +505,7 @@ static int render_testBlit9Grid(void *arg)
rect.w = (float)TESTRENDER_SCREEN_W;
rect.h = (float)TESTRENDER_SCREEN_H;
ret = SDL_RenderTexture9Grid(renderer, texture, NULL, 1.0f, 1.0f, 1.0f, 1.0f, 2.0f, &rect);
SDLTest_AssertCheck(ret == 0, "Validate results from call to SDL_RenderTexture9Grid, expected: 0, got: %i", ret);
SDLTest_AssertCheck(ret == SDL_TRUE, "Validate results from call to SDL_RenderTexture9Grid, expected: SDL_TRUE, got: %i", ret);
/* See if it's the same */
compare(referenceSurface, ALLOWABLE_ERROR_OPAQUE);
@@ -554,7 +554,7 @@ static int render_testBlit9Grid(void *arg)
texture = SDL_CreateTextureFromSurface(renderer, source);
SDLTest_AssertCheck(texture != NULL, "Verify source texture is not NULL");
ret = SDL_SetTextureScaleMode(texture, SDL_SCALEMODE_NEAREST);
SDLTest_AssertCheck(ret == 0, "Validate results from call to SDL_SetTextureScaleMode, expected: 0, got: %i", ret);
SDLTest_AssertCheck(ret == SDL_TRUE, "Validate results from call to SDL_SetTextureScaleMode, expected: SDL_TRUE, got: %i", ret);
/* complex 9-grid blit - 1.0 scale */
{
@@ -574,7 +574,7 @@ static int render_testBlit9Grid(void *arg)
rect.w = (float)TESTRENDER_SCREEN_W;
rect.h = (float)TESTRENDER_SCREEN_H;
ret = SDL_RenderTexture9Grid(renderer, texture, NULL, 1.0f, 2.0f, 1.0f, 2.0f, 1.0f, &rect);
SDLTest_AssertCheck(ret == 0, "Validate results from call to SDL_RenderTexture9Grid, expected: 0, got: %i", ret);
SDLTest_AssertCheck(ret == SDL_TRUE, "Validate results from call to SDL_RenderTexture9Grid, expected: SDL_TRUE, got: %i", ret);
/* See if it's the same */
compare(referenceSurface, ALLOWABLE_ERROR_OPAQUE);
@@ -601,7 +601,7 @@ static int render_testBlit9Grid(void *arg)
rect.w = (float)TESTRENDER_SCREEN_W;
rect.h = (float)TESTRENDER_SCREEN_H;
ret = SDL_RenderTexture9Grid(renderer, texture, NULL, 1.0f, 2.0f, 1.0f, 2.0f, 2.0f, &rect);
SDLTest_AssertCheck(ret == 0, "Validate results from call to SDL_RenderTexture9Grid, expected: 0, got: %i", ret);
SDLTest_AssertCheck(ret == SDL_TRUE, "Validate results from call to SDL_RenderTexture9Grid, expected: SDL_TRUE, got: %i", ret);
/* See if it's the same */
compare(referenceSurface, ALLOWABLE_ERROR_OPAQUE);
@@ -660,7 +660,7 @@ static int render_testBlitColor(void *arg)
for (i = 0; i <= ni; i += 4) {
/* Set color mod. */
ret = SDL_SetTextureColorMod(tface, (Uint8)((255 / nj) * j), (Uint8)((255 / ni) * i), (Uint8)((255 / nj) * j));
if (ret != 0) {
if (!ret) {
checkFailCount1++;
}
@@ -668,7 +668,7 @@ static int render_testBlitColor(void *arg)
rect.x = (float)i;
rect.y = (float)j;
ret = SDL_RenderTexture(renderer, tface, NULL, &rect);
if (ret != 0) {
if (!ret) {
checkFailCount2++;
}
}
@@ -730,7 +730,7 @@ static void testBlendModeOperation(TestRenderOperation op, int mode, SDL_PixelFo
if (SDL_ISPIXELFORMAT_ALPHA(dst_format)) {
SDL_BlendMode blendMode = SDL_BLENDMODE_NONE;
ret = SDL_GetTextureBlendMode(dst, &blendMode);
SDLTest_AssertCheck(ret == 0, "Verify result from SDL_GetTextureBlendMode(), expected: 0, got: %i", ret);
SDLTest_AssertCheck(ret == SDL_TRUE, "Verify result from SDL_GetTextureBlendMode(), expected: SDL_TRUE, got: %i", ret);
SDLTest_AssertCheck(blendMode == SDL_BLENDMODE_BLEND, "Verify alpha texture blend mode, expected %d, got %" SDL_PRIu32, SDL_BLENDMODE_BLEND, blendMode);
}
@@ -742,10 +742,10 @@ static void testBlendModeOperation(TestRenderOperation op, int mode, SDL_PixelFo
dstA = 255;
}
ret = SDL_SetRenderDrawColor(renderer, dstR, dstG, dstB, dstA);
SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetRenderDrawColor(), expected: 0, got: %i", ret);
SDLTest_AssertCheck(ret == SDL_TRUE, "Verify result from SDL_SetRenderDrawColor(), expected: SDL_TRUE, got: %i", ret);
ret = SDL_RenderClear(renderer);
SDLTest_AssertPass("Call to SDL_RenderClear()");
SDLTest_AssertCheck(ret == 0, "Verify result from SDL_RenderClear, expected: 0, got: %i", ret);
SDLTest_AssertCheck(ret == SDL_TRUE, "Verify result from SDL_RenderClear, expected: SDL_TRUE, got: %i", ret);
if (op == TEST_RENDER_COPY_XRGB || op == TEST_RENDER_COPY_ARGB) {
Uint8 pixels[4];
@@ -771,26 +771,26 @@ static void testBlendModeOperation(TestRenderOperation op, int mode, SDL_PixelFo
if (mode >= 0) {
ret = SDL_SetTextureBlendMode(src, (SDL_BlendMode)mode);
SDLTest_AssertPass("Call to SDL_SetTextureBlendMode()");
SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetTextureBlendMode(..., %i), expected: 0, got: %i", mode, ret);
SDLTest_AssertCheck(ret == SDL_TRUE, "Verify result from SDL_SetTextureBlendMode(..., %i), expected: SDL_TRUE, got: %i", mode, ret);
} else {
ret = SDL_SetTextureBlendMode(src, SDL_BLENDMODE_BLEND);
SDLTest_AssertPass("Call to SDL_SetTextureBlendMode()");
SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetTextureBlendMode(..., %i), expected: 0, got: %i", mode, ret);
SDLTest_AssertCheck(ret == SDL_TRUE, "Verify result from SDL_SetTextureBlendMode(..., %i), expected: SDL_TRUE, got: %i", mode, ret);
}
} else {
/* Set draw color */
ret = SDL_SetRenderDrawColor(renderer, srcR, srcG, srcB, srcA);
SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetRenderDrawColor(), expected: 0, got: %i", ret);
SDLTest_AssertCheck(ret == SDL_TRUE, "Verify result from SDL_SetRenderDrawColor(), expected: SDL_TRUE, got: %i", ret);
/* Set blend mode. */
if (mode >= 0) {
ret = SDL_SetRenderDrawBlendMode(renderer, (SDL_BlendMode)mode);
SDLTest_AssertPass("Call to SDL_SetRenderDrawBlendMode()");
SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetRenderDrawBlendMode(..., %i), expected: 0, got: %i", mode, ret);
SDLTest_AssertCheck(ret == SDL_TRUE, "Verify result from SDL_SetRenderDrawBlendMode(..., %i), expected: SDL_TRUE, got: %i", mode, ret);
} else {
ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND);
SDLTest_AssertPass("Call to SDL_SetRenderDrawBlendMode()");
SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetRenderDrawBlendMode(..., %i), expected: 0, got: %i", mode, ret);
SDLTest_AssertCheck(ret == SDL_TRUE, "Verify result from SDL_SetRenderDrawBlendMode(..., %i), expected: SDL_TRUE, got: %i", mode, ret);
}
}
@@ -800,7 +800,7 @@ static void testBlendModeOperation(TestRenderOperation op, int mode, SDL_PixelFo
case -1:
mode_name = "color modulation";
ret = SDL_SetTextureColorMod(src, srcR, srcG, srcB);
SDLTest_AssertCheck(ret == 0, "Validate results from calls to SDL_SetTextureColorMod, expected: 0, got: %i", ret);
SDLTest_AssertCheck(ret == SDL_TRUE, "Validate results from calls to SDL_SetTextureColorMod, expected: SDL_TRUE, got: %i", ret);
expectedR = (Uint8)SDL_roundf(SDL_clamp((FLOAT(srcR) * FLOAT(srcR)) * FLOAT(srcA) + FLOAT(dstR) * (1.0f - FLOAT(srcA)), 0.0f, 1.0f) * 255.0f);
expectedG = (Uint8)SDL_roundf(SDL_clamp((FLOAT(srcG) * FLOAT(srcG)) * FLOAT(srcA) + FLOAT(dstG) * (1.0f - FLOAT(srcA)), 0.0f, 1.0f) * 255.0f);
expectedB = (Uint8)SDL_roundf(SDL_clamp((FLOAT(srcB) * FLOAT(srcB)) * FLOAT(srcA) + FLOAT(dstB) * (1.0f - FLOAT(srcA)), 0.0f, 1.0f) * 255.0f);
@@ -809,7 +809,7 @@ static void testBlendModeOperation(TestRenderOperation op, int mode, SDL_PixelFo
case -2:
mode_name = "alpha modulation";
ret = SDL_SetTextureAlphaMod(src, srcA);
SDLTest_AssertCheck(ret == 0, "Validate results from calls to SDL_SetTextureAlphaMod, expected: 0, got: %i", ret);
SDLTest_AssertCheck(ret == SDL_TRUE, "Validate results from calls to SDL_SetTextureAlphaMod, expected: SDL_TRUE, got: %i", ret);
expectedR = (Uint8)SDL_roundf(SDL_clamp(FLOAT(srcR) * (FLOAT(srcA) * FLOAT(srcA)) + FLOAT(dstR) * (1.0f - (FLOAT(srcA) * FLOAT(srcA))), 0.0f, 1.0f) * 255.0f);
expectedG = (Uint8)SDL_roundf(SDL_clamp(FLOAT(srcG) * (FLOAT(srcA) * FLOAT(srcA)) + FLOAT(dstG) * (1.0f - (FLOAT(srcA) * FLOAT(srcA))), 0.0f, 1.0f) * 255.0f);
expectedB = (Uint8)SDL_roundf(SDL_clamp(FLOAT(srcB) * (FLOAT(srcA) * FLOAT(srcA)) + FLOAT(dstB) * (1.0f - (FLOAT(srcA) * FLOAT(srcA))), 0.0f, 1.0f) * 255.0f);
@@ -873,23 +873,23 @@ static void testBlendModeOperation(TestRenderOperation op, int mode, SDL_PixelFo
case TEST_RENDER_POINT:
operation = "render point";
ret = SDL_RenderPoint(renderer, 0.0f, 0.0f);
SDLTest_AssertCheck(ret == 0, "Validate results from calls to SDL_RenderPoint, expected: 0, got: %i", ret);
SDLTest_AssertCheck(ret == SDL_TRUE, "Validate results from calls to SDL_RenderPoint, expected: 0, got: %i", ret);
break;
case TEST_RENDER_LINE:
operation = "render line";
ret = SDL_RenderLine(renderer, 0.0f, 0.0f, 2.0f, 2.0f);
SDLTest_AssertCheck(ret == 0, "Validate results from calls to SDL_RenderLine, expected: 0, got: %i", ret);
SDLTest_AssertCheck(ret == SDL_TRUE, "Validate results from calls to SDL_RenderLine, expected: SDL_TRUE, got: %i", ret);
break;
case TEST_RENDER_RECT:
operation = "render rect";
ret = SDL_RenderFillRect(renderer, NULL);
SDLTest_AssertCheck(ret == 0, "Validate results from calls to SDL_RenderFillRect, expected: 0, got: %i", ret);
SDLTest_AssertCheck(ret == SDL_TRUE, "Validate results from calls to SDL_RenderFillRect, expected: 0, got: %i", ret);
break;
case TEST_RENDER_COPY_XRGB:
case TEST_RENDER_COPY_ARGB:
operation = (op == TEST_RENDER_COPY_XRGB) ? "render XRGB" : "render ARGB";
ret = SDL_RenderTexture(renderer, src, NULL, NULL);
SDLTest_AssertCheck(ret == 0, "Validate results from calls to SDL_RenderTexture, expected: 0, got: %i", ret);
SDLTest_AssertCheck(ret == SDL_TRUE, "Validate results from calls to SDL_RenderTexture, expected: SDL_TRUE, got: %i", ret);
break;
default:
SDLTest_LogError("Invalid blending operation: %d", op);
@@ -1251,10 +1251,9 @@ static int render_testLogicalSize(void *arg)
/**
* Checks to see if functionality is supported. Helper function.
*/
static int
isSupported(int code)
static SDL_bool isSupported(int code)
{
return code == 0;
return (code != SDL_FALSE);
}
/**
@@ -1263,8 +1262,7 @@ isSupported(int code)
* \sa SDL_SetRenderDrawColor
* \sa SDL_GetRenderDrawColor
*/
static int
hasDrawColor(void)
static SDL_bool hasDrawColor(void)
{
int ret, fail;
Uint8 r, g, b, a;
@@ -1289,13 +1287,13 @@ hasDrawColor(void)
/* Something failed, consider not available. */
if (fail) {
return 0;
return SDL_FALSE;
}
/* Not set properly, consider failed. */
else if ((r != 100) || (g != 100) || (b != 100) || (a != 100)) {
return 0;
return SDL_FALSE;
}
return 1;
return SDL_TRUE;
}
/**
@@ -1417,18 +1415,18 @@ clearScreen(void)
/* Set color. */
ret = SDL_SetRenderDrawColor(renderer, 0, 0, 0, SDL_ALPHA_OPAQUE);
SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawColor, expected: 0, got: %i", ret);
SDLTest_AssertCheck(ret == SDL_TRUE, "Validate result from SDL_SetRenderDrawColor, expected: SDL_TRUE, got: %i", ret);
/* Clear screen. */
ret = SDL_RenderClear(renderer);
SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderClear, expected: 0, got: %i", ret);
SDLTest_AssertCheck(ret == SDL_TRUE, "Validate result from SDL_RenderClear, expected: SDL_TRUE, got: %i", ret);
/* Set defaults. */
ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE);
SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawBlendMode, expected: 0, got: %i", ret);
SDLTest_AssertCheck(ret == SDL_TRUE, "Validate result from SDL_SetRenderDrawBlendMode, expected: SDL_TRUE, got: %i", ret);
ret = SDL_SetRenderDrawColor(renderer, 255, 255, 255, SDL_ALPHA_OPAQUE);
SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawColor, expected: 0, got: %i", ret);
SDLTest_AssertCheck(ret == SDL_TRUE, "Validate result from SDL_SetRenderDrawColor, expected: SDL_TRUE, got: %i", ret);
return 0;
}

View File

@@ -25,9 +25,9 @@
#define CHECK_FUNC(FUNC, PARAMS) \
{ \
int result = FUNC PARAMS; \
if (result != 0) { \
SDLTest_AssertCheck(result == 0, "Validate result from %s, expected: 0, got: %i, %s", #FUNC, result, SDL_GetError()); \
SDL_bool result = FUNC PARAMS; \
if (!result) { \
SDLTest_AssertCheck(result, "Validate result from %s, expected: SDL_TRUE, got: SDL_FALSE, %s", #FUNC, SDL_GetError()); \
} \
}
@@ -53,14 +53,14 @@ static void surfaceSetUp(void *arg)
if (testSurface != NULL) {
/* Disable blend mode for target surface */
result = SDL_SetSurfaceBlendMode(testSurface, blendMode);
SDLTest_AssertCheck(result == 0, "Validate result from SDL_SetSurfaceBlendMode, expected: 0, got: %i", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Validate result from SDL_SetSurfaceBlendMode, expected: SDL_TRUE, got: %i", result);
result = SDL_GetSurfaceBlendMode(testSurface, &currentBlendMode);
SDLTest_AssertCheck(result == 0, "Validate result from SDL_GetSurfaceBlendMode, expected: 0, got: %i", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Validate result from SDL_GetSurfaceBlendMode, expected: SDL_TRUE, got: %i", result);
SDLTest_AssertCheck(currentBlendMode == blendMode, "Validate blendMode, expected: %" SDL_PRIu32 ", got: %" SDL_PRIu32, blendMode, currentBlendMode);
/* Clear the target surface */
result = SDL_FillSurfaceRect(testSurface, NULL, SDL_MapSurfaceRGBA(testSurface, 0, 0, 0, 255));
SDLTest_AssertCheck(result == 0, "Validate result from SDL_FillSurfaceRect, expected: 0, got: %i", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Validate result from SDL_FillSurfaceRect, expected: SDL_TRUE, got: %i", result);
}
}
@@ -133,7 +133,7 @@ static void testBlitBlendModeWithFormats(int mode, SDL_PixelFormat src_format, S
}
ret = SDL_FillSurfaceRect(dst, NULL, color);
SDLTest_AssertPass("Call to SDL_FillSurfaceRect()");
SDLTest_AssertCheck(ret == 0, "Verify result from SDL_FillSurfaceRect, expected: 0, got: %i", ret);
SDLTest_AssertCheck(ret == SDL_TRUE, "Verify result from SDL_FillSurfaceRect, expected: SDL_TRUE, got: %i", ret);
SDL_GetRGBA(color, SDL_GetPixelFormatDetails(dst->format), SDL_GetSurfacePalette(dst), &dstR, &dstG, &dstB, &dstA);
/* Create src surface */
@@ -153,35 +153,35 @@ static void testBlitBlendModeWithFormats(int mode, SDL_PixelFormat src_format, S
/* Reset alpha modulation */
ret = SDL_SetSurfaceAlphaMod(src, 255);
SDLTest_AssertPass("Call to SDL_SetSurfaceAlphaMod()");
SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetSurfaceAlphaMod(), expected: 0, got: %i", ret);
SDLTest_AssertCheck(ret == SDL_TRUE, "Verify result from SDL_SetSurfaceAlphaMod(), expected: SDL_TRUE, got: %i", ret);
/* Reset color modulation */
ret = SDL_SetSurfaceColorMod(src, 255, 255, 255);
SDLTest_AssertPass("Call to SDL_SetSurfaceColorMod()");
SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetSurfaceColorMod(), expected: 0, got: %i", ret);
SDLTest_AssertCheck(ret == SDL_TRUE, "Verify result from SDL_SetSurfaceColorMod(), expected: SDL_TRUE, got: %i", ret);
/* Reset color key */
ret = SDL_SetSurfaceColorKey(src, SDL_FALSE, 0);
SDLTest_AssertPass("Call to SDL_SetSurfaceColorKey()");
SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetSurfaceColorKey(), expected: 0, got: %i", ret);
SDLTest_AssertCheck(ret == SDL_TRUE, "Verify result from SDL_SetSurfaceColorKey(), expected: SDL_TRUE, got: %i", ret);
/* Clear surface. */
color = SDL_MapSurfaceRGBA(src, srcR, srcG, srcB, srcA);
SDLTest_AssertPass("Call to SDL_MapSurfaceRGBA()");
ret = SDL_FillSurfaceRect(src, NULL, color);
SDLTest_AssertPass("Call to SDL_FillSurfaceRect()");
SDLTest_AssertCheck(ret == 0, "Verify result from SDL_FillSurfaceRect, expected: 0, got: %i", ret);
SDLTest_AssertCheck(ret == SDL_TRUE, "Verify result from SDL_FillSurfaceRect, expected: SDL_TRUE, got: %i", ret);
SDL_GetRGBA(color, SDL_GetPixelFormatDetails(src->format), SDL_GetSurfacePalette(src), &srcR, &srcG, &srcB, &srcA);
/* Set blend mode. */
if (mode >= 0) {
ret = SDL_SetSurfaceBlendMode(src, (SDL_BlendMode)mode);
SDLTest_AssertPass("Call to SDL_SetSurfaceBlendMode()");
SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetSurfaceBlendMode(..., %i), expected: 0, got: %i", mode, ret);
SDLTest_AssertCheck(ret == SDL_TRUE, "Verify result from SDL_SetSurfaceBlendMode(..., %i), expected: SDL_TRUE, got: %i", mode, ret);
} else {
ret = SDL_SetSurfaceBlendMode(src, SDL_BLENDMODE_BLEND);
SDLTest_AssertPass("Call to SDL_SetSurfaceBlendMode()");
SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetSurfaceBlendMode(..., %i), expected: 0, got: %i", mode, ret);
SDLTest_AssertCheck(ret == SDL_TRUE, "Verify result from SDL_SetSurfaceBlendMode(..., %i), expected: SDL_TRUE, got: %i", mode, ret);
}
/* Test blend mode. */
@@ -190,7 +190,7 @@ static void testBlitBlendModeWithFormats(int mode, SDL_PixelFormat src_format, S
case -1:
/* Set color mod. */
ret = SDL_SetSurfaceColorMod(src, srcR, srcG, srcB);
SDLTest_AssertCheck(ret == 0, "Validate results from calls to SDL_SetSurfaceColorMod, expected: 0, got: %i", ret);
SDLTest_AssertCheck(ret == SDL_TRUE, "Validate results from calls to SDL_SetSurfaceColorMod, expected: SDL_TRUE, got: %i", ret);
expectedR = (Uint8)SDL_roundf(SDL_clamp((FLOAT(srcR) * FLOAT(srcR)) * FLOAT(srcA) + FLOAT(dstR) * (1.0f - FLOAT(srcA)), 0.0f, 1.0f) * 255.0f);
expectedG = (Uint8)SDL_roundf(SDL_clamp((FLOAT(srcG) * FLOAT(srcG)) * FLOAT(srcA) + FLOAT(dstG) * (1.0f - FLOAT(srcA)), 0.0f, 1.0f) * 255.0f);
expectedB = (Uint8)SDL_roundf(SDL_clamp((FLOAT(srcB) * FLOAT(srcB)) * FLOAT(srcA) + FLOAT(dstB) * (1.0f - FLOAT(srcA)), 0.0f, 1.0f) * 255.0f);
@@ -199,7 +199,7 @@ static void testBlitBlendModeWithFormats(int mode, SDL_PixelFormat src_format, S
case -2:
/* Set alpha mod. */
ret = SDL_SetSurfaceAlphaMod(src, srcA);
SDLTest_AssertCheck(ret == 0, "Validate results from calls to SDL_SetSurfaceAlphaMod, expected: 0, got: %i", ret);
SDLTest_AssertCheck(ret == SDL_TRUE, "Validate results from calls to SDL_SetSurfaceAlphaMod, expected: SDL_TRUE, got: %i", ret);
expectedR = (Uint8)SDL_roundf(SDL_clamp(FLOAT(srcR) * (FLOAT(srcA) * FLOAT(srcA)) + FLOAT(dstR) * (1.0f - (FLOAT(srcA) * FLOAT(srcA))), 0.0f, 1.0f) * 255.0f);
expectedG = (Uint8)SDL_roundf(SDL_clamp(FLOAT(srcG) * (FLOAT(srcA) * FLOAT(srcA)) + FLOAT(dstG) * (1.0f - (FLOAT(srcA) * FLOAT(srcA))), 0.0f, 1.0f) * 255.0f);
expectedB = (Uint8)SDL_roundf(SDL_clamp(FLOAT(srcB) * (FLOAT(srcA) * FLOAT(srcA)) + FLOAT(dstB) * (1.0f - (FLOAT(srcA) * FLOAT(srcA))), 0.0f, 1.0f) * 255.0f);
@@ -262,8 +262,8 @@ static void testBlitBlendModeWithFormats(int mode, SDL_PixelFormat src_format, S
/* Blitting. */
ret = SDL_BlitSurface(src, NULL, dst, NULL);
SDLTest_AssertCheck(ret == 0, "Validate results from calls to SDL_BlitSurface, expected: 0, got: %i: %s", ret, (ret < 0) ? SDL_GetError() : "success");
if (ret == 0) {
SDLTest_AssertCheck(ret == SDL_TRUE, "Validate results from calls to SDL_BlitSurface, expected: SDL_TRUE, got: %i: %s", ret, !ret ? SDL_GetError() : "success");
if (ret) {
SDL_ReadSurfacePixel(dst, 0, 0, &actualR, &actualG, &actualB, &actualA);
deltaR = SDL_abs((int)actualR - expectedR);
deltaG = SDL_abs((int)actualG - expectedG);
@@ -336,7 +336,7 @@ static int surface_testSaveLoadBitmap(void *arg)
/* Save a surface */
ret = SDL_SaveBMP(face, sampleFilename);
SDLTest_AssertPass("Call to SDL_SaveBMP()");
SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SaveBMP, expected: 0, got: %i", ret);
SDLTest_AssertCheck(ret == SDL_TRUE, "Verify result from SDL_SaveBMP, expected: SDL_TRUE, got: %i", ret);
AssertFileExist(sampleFilename);
/* Load a surface */
@@ -380,7 +380,7 @@ static int surface_testBlitTiled(void *arg)
/* Tiled blit - 1.0 scale */
{
ret = SDL_BlitSurfaceTiled(face, NULL, testSurface, NULL);
SDLTest_AssertCheck(ret == 0, "Verify result from SDL_BlitSurfaceTiled expected: 0, got: %i", ret);
SDLTest_AssertCheck(ret == SDL_TRUE, "Verify result from SDL_BlitSurfaceTiled expected: SDL_TRUE, got: %i", ret);
/* See if it's the same */
SDL_DestroySurface(referenceSurface);
@@ -394,15 +394,15 @@ static int surface_testBlitTiled(void *arg)
testSurface2x = SDL_CreateSurface(testSurface->w * 2, testSurface->h * 2, testSurface->format);
SDLTest_AssertCheck(testSurface != NULL, "Check that testSurface2x is not NULL");
ret = SDL_FillSurfaceRect(testSurface2x, NULL, SDL_MapSurfaceRGBA(testSurface2x, 0, 0, 0, 255));
SDLTest_AssertCheck(ret == 0, "Validate result from SDL_FillSurfaceRect, expected: 0, got: %i", ret);
SDLTest_AssertCheck(ret == SDL_TRUE, "Validate result from SDL_FillSurfaceRect, expected: SDL_TRUE, got: %i", ret);
ret = SDL_BlitSurfaceTiledWithScale(face, NULL, 2.0f, SDL_SCALEMODE_NEAREST, testSurface2x, NULL);
SDLTest_AssertCheck(ret == 0, "Validate results from call to SDL_RenderTextureTiled, expected: 0, got: %i", ret);
SDLTest_AssertCheck(ret == SDL_TRUE, "Validate results from call to SDL_BlitSurfaceTiledWithScale, expected: SDL_TRUE, got: %i", ret);
/* See if it's the same */
referenceSurface2x = SDL_CreateSurface(referenceSurface->w * 2, referenceSurface->h * 2, referenceSurface->format);
SDL_BlitSurfaceScaled(referenceSurface, NULL, referenceSurface2x, NULL, SDL_SCALEMODE_NEAREST);
SDLTest_AssertCheck(ret == 0, "Validate results from call to SDL_BlitSurfaceScaled, expected: 0, got: %i", ret);
SDLTest_AssertCheck(ret == SDL_TRUE, "Validate results from call to SDL_BlitSurfaceScaled, expected: SDL_TRUE, got: %i", ret);
ret = SDLTest_CompareSurfaces(testSurface2x, referenceSurface2x, 0);
SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret);
}
@@ -512,7 +512,7 @@ static int surface_testBlit9Grid(void *arg)
Fill9GridReferenceSurface(referenceSurface, 1, 1, 1, 1);
ret = SDL_BlitSurface9Grid(source, NULL, 1, 1, 1, 1, 0.0f, SDL_SCALEMODE_NEAREST, testSurface, NULL);
SDLTest_AssertCheck(ret == 0, "Validate result from SDL_BlitSurface9Grid, expected: 0, got: %i", ret);
SDLTest_AssertCheck(ret == SDL_TRUE, "Validate result from SDL_BlitSurface9Grid, expected: SDL_TRUE, got: %i", ret);
ret = SDLTest_CompareSurfaces(testSurface, referenceSurface, 0);
SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret);
@@ -527,7 +527,7 @@ static int surface_testBlit9Grid(void *arg)
Fill9GridReferenceSurface(referenceSurface, 2, 2, 2, 2);
ret = SDL_BlitSurface9Grid(source, NULL, 1, 1, 1, 1, 2.0f, SDL_SCALEMODE_NEAREST, testSurface, NULL);
SDLTest_AssertCheck(ret == 0, "Validate result from SDL_BlitSurface9Grid, expected: 0, got: %i", ret);
SDLTest_AssertCheck(ret == SDL_TRUE, "Validate result from SDL_BlitSurface9Grid, expected: SDL_TRUE, got: %i", ret);
ret = SDLTest_CompareSurfaces(testSurface, referenceSurface, 0);
SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret);
@@ -579,7 +579,7 @@ static int surface_testBlit9Grid(void *arg)
Fill9GridReferenceSurface(referenceSurface, 1, 2, 1, 2);
ret = SDL_BlitSurface9Grid(source, NULL, 1, 2, 1, 2, 0.0f, SDL_SCALEMODE_NEAREST, testSurface, NULL);
SDLTest_AssertCheck(ret == 0, "Validate result from SDL_BlitSurface9Grid, expected: 0, got: %i", ret);
SDLTest_AssertCheck(ret == SDL_TRUE, "Validate result from SDL_BlitSurface9Grid, expected: SDL_TRUE, got: %i", ret);
ret = SDLTest_CompareSurfaces(testSurface, referenceSurface, 0);
SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret);
@@ -595,7 +595,7 @@ static int surface_testBlit9Grid(void *arg)
Fill9GridReferenceSurface(referenceSurface, 2, 4, 2, 4);
ret = SDL_BlitSurface9Grid(source, NULL, 1, 2, 1, 2, 2.0f, SDL_SCALEMODE_NEAREST, testSurface, NULL);
SDLTest_AssertCheck(ret == 0, "Validate result from SDL_BlitSurface9Grid, expected: 0, got: %i", ret);
SDLTest_AssertCheck(ret == SDL_TRUE, "Validate result from SDL_BlitSurface9Grid, expected: SDL_TRUE, got: %i", ret);
ret = SDLTest_CompareSurfaces(testSurface, referenceSurface, 0);
SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret);
@@ -691,7 +691,7 @@ static int surface_testSurfaceConversion(void *arg)
if (SDL_GetSurfacePalette(face)) {
ret = SDL_SetSurfaceColorKey(face, SDL_TRUE, *(Uint8 *)face->pixels);
SDLTest_AssertPass("Call to SDL_SetSurfaceColorKey()");
SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetSurfaceColorKey, expected: 0, got: %i", ret);
SDLTest_AssertCheck(ret == SDL_TRUE, "Verify result from SDL_SetSurfaceColorKey, expected: SDL_TRUE, got: %i", ret);
}
/* Convert to 32 bit to compare. */
@@ -766,7 +766,7 @@ static int surface_testCompleteSurfaceConversion(void *arg)
if (SDL_GetSurfacePalette(face)) {
ret = SDL_SetSurfaceColorKey(face, SDL_TRUE, *(Uint8 *)face->pixels);
SDLTest_AssertPass("Call to SDL_SetSurfaceColorKey()");
SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetSurfaceColorKey, expected: 0, got: %i", ret);
SDLTest_AssertCheck(ret == SDL_TRUE, "Verify result from SDL_SetSurfaceColorKey, expected: SDL_TRUE, got: %i", ret);
}
for (i = 0; i < SDL_arraysize(pixel_formats); ++i) {
@@ -1312,7 +1312,7 @@ static int surface_testPalettization(void *arg)
SDLTest_AssertCheck(palette != NULL, "SDL_CreatePalette()");
result = SDL_SetPaletteColors(palette, palette_colors, 0, SDL_arraysize(palette_colors));
SDLTest_AssertCheck(result >= 0, "SDL_SetPaletteColors()");
SDLTest_AssertCheck(result, "SDL_SetPaletteColors()");
source = SDL_CreateSurface(SDL_arraysize(palette_colors) + SDL_arraysize(colors), 1, SDL_PIXELFORMAT_RGBA8888);
SDLTest_AssertCheck(source != NULL, "SDL_CreateSurface()");
@@ -1321,11 +1321,11 @@ static int surface_testPalettization(void *arg)
SDLTest_AssertCheck(source->format == SDL_PIXELFORMAT_RGBA8888, "Expected source->format == SDL_PIXELFORMAT_RGBA8888, got 0x%x (%s)", source->format, SDL_GetPixelFormatName(source->format));
for (i = 0; i < SDL_arraysize(colors); i++) {
result = SDL_WriteSurfacePixel(source, i, 0, colors[i].c.r, colors[i].c.g, colors[i].c.b, colors[i].c.a);
SDLTest_AssertCheck(result >= 0, "SDL_WriteSurfacePixel");
SDLTest_AssertCheck(result == SDL_TRUE, "SDL_WriteSurfacePixel");
}
for (i = 0; i < SDL_arraysize(palette_colors); i++) {
result = SDL_WriteSurfacePixel(source, SDL_arraysize(colors) + i, 0, palette_colors[i].r, palette_colors[i].g, palette_colors[i].b, palette_colors[i].a);
SDLTest_AssertCheck(result >= 0, "SDL_WriteSurfacePixel");
SDLTest_AssertCheck(result == SDL_TRUE, "SDL_WriteSurfacePixel");
}
output = SDL_ConvertSurfaceAndColorspace(source, SDL_PIXELFORMAT_INDEX8, palette, SDL_COLORSPACE_UNKNOWN, 0);
@@ -1383,9 +1383,9 @@ static int surface_testClearSurface(void *arg)
surface = SDL_CreateSurface(1, 1, format);
SDLTest_AssertCheck(surface != NULL, "SDL_CreateSurface()");
ret = SDL_ClearSurface(surface, srcR, srcG, srcB, srcA);
SDLTest_AssertCheck(ret == 0, "SDL_ClearSurface()");
SDLTest_AssertCheck(ret == SDL_TRUE, "SDL_ClearSurface()");
ret = SDL_ReadSurfacePixelFloat(surface, 0, 0, &actualR, &actualG, &actualB, &actualA);
SDLTest_AssertCheck(ret == 0, "SDL_ReadSurfacePixelFloat()");
SDLTest_AssertCheck(ret == SDL_TRUE, "SDL_ReadSurfacePixelFloat()");
deltaR = SDL_fabsf(actualR - srcR);
deltaG = SDL_fabsf(actualG - srcG);
deltaB = SDL_fabsf(actualB - srcB);
@@ -1433,13 +1433,13 @@ static int surface_testPremultiplyAlpha(void *arg)
surface = SDL_CreateSurface(1, 1, format);
SDLTest_AssertCheck(surface != NULL, "SDL_CreateSurface()");
ret = SDL_SetSurfaceColorspace(surface, SDL_COLORSPACE_SRGB);
SDLTest_AssertCheck(ret == 0, "SDL_SetSurfaceColorspace()");
SDLTest_AssertCheck(ret == SDL_TRUE, "SDL_SetSurfaceColorspace()");
ret = SDL_ClearSurface(surface, srcR, srcG, srcB, srcA);
SDLTest_AssertCheck(ret == 0, "SDL_ClearSurface()");
SDLTest_AssertCheck(ret == SDL_TRUE, "SDL_ClearSurface()");
ret = SDL_PremultiplySurfaceAlpha(surface, SDL_FALSE);
SDLTest_AssertCheck(ret == 0, "SDL_PremultiplySurfaceAlpha()");
SDLTest_AssertCheck(ret == SDL_TRUE, "SDL_PremultiplySurfaceAlpha()");
ret = SDL_ReadSurfacePixelFloat(surface, 0, 0, &actualR, &actualG, &actualB, NULL);
SDLTest_AssertCheck(ret == 0, "SDL_ReadSurfacePixelFloat()");
SDLTest_AssertCheck(ret == SDL_TRUE, "SDL_ReadSurfacePixelFloat()");
deltaR = SDL_fabsf(actualR - expectedR);
deltaG = SDL_fabsf(actualG - expectedG);
deltaB = SDL_fabsf(actualB - expectedB);

View File

@@ -20,7 +20,7 @@ static int time_getRealtimeClock(void *arg)
result = SDL_GetCurrentTime(&ticks);
SDLTest_AssertPass("Call to SDL_GetRealtimeClockTicks()");
SDLTest_AssertCheck(result == 0, "Check result value, expected 0, got: %i", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Check result value, expected SDL_TRUE, got: %i", result);
return TEST_COMPLETED;
}
@@ -38,7 +38,7 @@ static int time_dateTimeConversion(void *arg)
result = SDL_TimeToDateTime(ticks[0], &dt, SDL_FALSE);
SDLTest_AssertPass("Call to SDL_TimeToUTCDateTime()");
SDLTest_AssertCheck(result == 0, "Check result value, expected 0, got: %i", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Check result value, expected SDL_TRUE, got: %i", result);
SDLTest_AssertCheck(dt.year == 2000, "Check year value, expected 2000, got: %i", dt.year);
SDLTest_AssertCheck(dt.month == 1, "Check month value, expected 1, got: %i", dt.month);
SDLTest_AssertCheck(dt.day == 1, "Check day value, expected 1, got: %i", dt.day);
@@ -48,7 +48,7 @@ static int time_dateTimeConversion(void *arg)
result = SDL_DateTimeToTime(&dt, &ticks[1]);
SDLTest_AssertPass("Call to SDL_DateTimeToTime()");
SDLTest_AssertCheck(result == 0, "Check result value, expected 0, got: %i", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Check result value, expected SDL_TRUE, got: %i", result);
result = ticks[0] == ticks[1];
SDLTest_AssertCheck(result, "Check that original and converted SDL_Time values match: ticks0 = %" SDL_PRIs64 ", ticks1 = %" SDL_PRIs64, ticks[0], ticks[1]);
@@ -56,12 +56,12 @@ static int time_dateTimeConversion(void *arg)
/* Local time unknown, so just verify success. */
result = SDL_TimeToDateTime(ticks[0], &dt, SDL_TRUE);
SDLTest_AssertPass("Call to SDL_TimeToLocalDateTime()");
SDLTest_AssertCheck(result == 0, "Check result value, expected 0, got: %i", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Check result value, expected SDL_TRUE, got: %i", result);
/* Convert back and verify result. */
result = SDL_DateTimeToTime(&dt, &ticks[1]);
SDLTest_AssertPass("Call to SDL_DateTimeToTime()");
SDLTest_AssertCheck(result == 0, "Check result value, expected 0, got: %i", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Check result value, expected SDL_TRUE, got: %i", result);
result = ticks[0] == ticks[1];
SDLTest_AssertCheck(result, "Check that original and converted SDL_Time values match: ticks0 = %" SDL_PRIs64 ", ticks1 = %" SDL_PRIs64, ticks[0], ticks[1]);
@@ -79,7 +79,7 @@ static int time_dateTimeConversion(void *arg)
result = SDL_DateTimeToTime(&dt, &ticks[1]);
SDLTest_AssertPass("Call to SDL_DateTimeToTime() (one day advanced)");
SDLTest_AssertCheck(result == 0, "Check result value, expected 0, got: %i", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Check result value, expected SDL_TRUE, got: %i", result);
result = (ticks[0] + (Sint64)SDL_SECONDS_TO_NS(86400)) == ticks[1];
SDLTest_AssertCheck(result, "Check that the difference is exactly 86400 seconds, got: %" SDL_PRIs64, (Sint64)SDL_NS_TO_SECONDS(ticks[1] - ticks[0]));
@@ -90,12 +90,12 @@ static int time_dateTimeConversion(void *arg)
dt.day = 1;
result = SDL_DateTimeToTime(&dt, &ticks[0]);
SDLTest_AssertPass("Call to SDL_DateTimeToTime() (year overflows an SDL_Time)");
SDLTest_AssertCheck(result == -1, "Check result value, expected -1, got: %i", result);
SDLTest_AssertCheck(result == SDL_FALSE, "Check result value, expected SDL_FALSE, got: %i", result);
dt.year = 1601;
result = SDL_DateTimeToTime(&dt, &ticks[0]);
SDLTest_AssertPass("Call to SDL_DateTimeToTime() (year underflows an SDL_Time)");
SDLTest_AssertCheck(result == -1, "Check result value, expected -1, got: %i", result);
SDLTest_AssertCheck(result == SDL_FALSE, "Check result value, expected SDL_FALSE, got: %i", result);
return TEST_COMPLETED;
}
@@ -175,19 +175,19 @@ static int time_dateTimeUtilities(void *arg)
result = SDL_GetDateTimeLocalePreferences(&dateFormat, &timeFormat);
SDLTest_AssertPass("Call to SDL_GetDateTimeLocalePreferences(&dateFormat, &timeFormat)");
SDLTest_AssertCheck(result == 0, "Check result value, expected 0, got: %i", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Check result value, expected SDL_TRUE, got: %i", result);
result = SDL_GetDateTimeLocalePreferences(&dateFormat, NULL);
SDLTest_AssertPass("Call to SDL_GetDateTimeLocalePreferences(&dateFormat, NULL)");
SDLTest_AssertCheck(result == 0, "Check result value, expected 0, got: %i", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Check result value, expected SDL_TRUE, got: %i", result);
result = SDL_GetDateTimeLocalePreferences(NULL, &timeFormat);
SDLTest_AssertPass("Call to SDL_GetDateTimeLocalePreferences(NULL, &timeFormat)");
SDLTest_AssertCheck(result == 0, "Check result value, expected 0, got: %i", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Check result value, expected SDL_TRUE, got: %i", result);
result = SDL_GetDateTimeLocalePreferences(NULL, NULL);
SDLTest_AssertPass("Call to SDL_GetDateTimeLocalePreferences(NULL, NULL)");
SDLTest_AssertCheck(result == 0, "Check result value, expected 0, got: %i", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Check result value, expected SDL_TRUE, got: %i", result);
return TEST_COMPLETED;
}

View File

@@ -23,10 +23,10 @@ static int g_timerCallbackCalled = 0;
static void timerSetUp(void *arg)
{
/* Start SDL timer subsystem */
int ret = SDL_InitSubSystem(SDL_INIT_TIMER);
SDL_bool ret = SDL_InitSubSystem(SDL_INIT_TIMER);
SDLTest_AssertPass("Call to SDL_InitSubSystem(SDL_INIT_TIMER)");
SDLTest_AssertCheck(ret == 0, "Check result from SDL_InitSubSystem(SDL_INIT_TIMER)");
if (ret != 0) {
SDLTest_AssertCheck(ret == SDL_TRUE, "Check result from SDL_InitSubSystem(SDL_INIT_TIMER)");
if (!ret) {
SDLTest_LogError("%s", SDL_GetError());
}
}
@@ -148,13 +148,13 @@ static int timer_addRemoveTimer(void *arg)
/* Remove timer again and check that callback was not called */
result = SDL_RemoveTimer(id);
SDLTest_AssertPass("Call to SDL_RemoveTimer()");
SDLTest_AssertCheck(result == 0, "Check result value, expected: 0, got: %i", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Check result value, expected: SDL_TRUE, got: %i", result);
SDLTest_AssertCheck(g_timerCallbackCalled == 0, "Check callback WAS NOT called, expected: 0, got: %i", g_timerCallbackCalled);
/* Try to remove timer again (should be a NOOP) */
result = SDL_RemoveTimer(id);
SDLTest_AssertPass("Call to SDL_RemoveTimer()");
SDLTest_AssertCheck(result < 0, "Check result value, expected: <0, got: %i", result);
SDLTest_AssertCheck(result == SDL_FALSE, "Check result value, expected: SDL_FALSE, got: %i", result);
/* Reset state */
param = SDLTest_RandomIntegerInRange(-1024, 1024);
@@ -174,7 +174,7 @@ static int timer_addRemoveTimer(void *arg)
/* Remove timer again and check that callback was called */
result = SDL_RemoveTimer(id);
SDLTest_AssertPass("Call to SDL_RemoveTimer()");
SDLTest_AssertCheck(result < 0, "Check result value, expected: <0, got: %i", result);
SDLTest_AssertCheck(result == SDL_FALSE, "Check result value, expected: SDL_FALSE, got: %i", result);
SDLTest_AssertCheck(g_timerCallbackCalled == 1, "Check callback WAS called, expected: 1, got: %i", g_timerCallbackCalled);
return TEST_COMPLETED;

View File

@@ -360,7 +360,7 @@ static int video_getClosestDisplayModeCurrentResolution(void *arg)
/* Make call */
result = SDL_GetClosestFullscreenDisplayMode(displays[i], current.w, current.h, current.refresh_rate, SDL_FALSE, &closest);
SDLTest_AssertPass("Call to SDL_GetClosestFullscreenDisplayMode(target=current)");
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Verify return value; expected: SDL_TRUE, got: %d", result);
/* Check that one gets the current resolution back again */
if (result == 0) {
@@ -815,7 +815,7 @@ static int video_getSetWindowPosition(void *arg)
/* Sanity check */
SDL_GetWindowPosition(window, &currentX, &currentY);
if (SDL_SetWindowPosition(window, currentX, currentY) < 0) {
if (!SDL_SetWindowPosition(window, currentX, currentY)) {
SDLTest_Log("Skipping window positioning tests: %s reports window positioning as unsupported", SDL_GetCurrentVideoDriver());
goto null_tests;
}
@@ -891,7 +891,7 @@ static int video_getSetWindowPosition(void *arg)
result = SDL_SyncWindow(window);
SDLTest_AssertPass("SDL_SyncWindow()");
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Verify return value; expected: SDL_TRUE, got: %d", result);
/* Get position */
currentX = desiredX + 1;
@@ -1013,9 +1013,9 @@ static int video_getSetWindowSize(void *arg)
/* Get display bounds for size range */
result = SDL_GetDisplayUsableBounds(SDL_GetPrimaryDisplay(), &display);
SDLTest_AssertPass("SDL_GetDisplayBounds()");
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
if (result != 0) {
SDLTest_AssertPass("SDL_GetDisplayUsableBounds()");
SDLTest_AssertCheck(result == SDL_TRUE, "Verify return value; expected: SDL_TRUE, got: %d", result);
if (!result) {
return TEST_ABORTED;
}
@@ -1098,7 +1098,7 @@ static int video_getSetWindowSize(void *arg)
result = SDL_SyncWindow(window);
SDLTest_AssertPass("SDL_SyncWindow()");
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Verify return value; expected: SDL_TRUE, got: %d", result);
/* Get size */
currentW = desiredW + 1;
@@ -1213,8 +1213,8 @@ static int video_getSetWindowMinimumSize(void *arg)
/* Get display bounds for size range */
result = SDL_GetDisplayBounds(SDL_GetPrimaryDisplay(), &display);
SDLTest_AssertPass("SDL_GetDisplayBounds()");
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
if (result != 0) {
SDLTest_AssertCheck(result == SDL_TRUE, "Verify return value; expected: SDL_TRUE, got: %d", result);
if (!result) {
return TEST_ABORTED;
}
@@ -1355,8 +1355,8 @@ static int video_getSetWindowMaximumSize(void *arg)
/* Get display bounds for size range */
result = SDL_GetDisplayBounds(SDL_GetPrimaryDisplay(), &display);
SDLTest_AssertPass("SDL_GetDisplayBounds()");
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
if (result != 0) {
SDLTest_AssertCheck(result == SDL_TRUE, "Verify return value; expected: SDL_TRUE, got: %d", result);
if (!result) {
return TEST_ABORTED;
}
@@ -1693,15 +1693,15 @@ static int video_setWindowCenteredOnDisplay(void *arg)
/* Get display bounds */
result = SDL_GetDisplayUsableBounds(displays[0 % displayNum], &display0);
SDLTest_AssertPass("SDL_GetDisplayUsableBounds()");
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
if (result != 0) {
SDLTest_AssertCheck(result == SDL_TRUE, "Verify return value; expected: SDL_TRUE, got: %d", result);
if (!result) {
return TEST_ABORTED;
}
result = SDL_GetDisplayUsableBounds(displays[1 % displayNum], &display1);
SDLTest_AssertPass("SDL_GetDisplayUsableBounds()");
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
if (result != 0) {
SDLTest_AssertCheck(result == SDL_TRUE, "Verify return value; expected: SDL_TRUE, got: %d", result);
if (!result) {
return TEST_ABORTED;
}
@@ -1781,11 +1781,11 @@ static int video_setWindowCenteredOnDisplay(void *arg)
/* Enter fullscreen desktop */
SDL_SetWindowPosition(window, x, y);
result = SDL_SetWindowFullscreen(window, SDL_TRUE);
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Verify return value; expected: SDL_TRUE, got: %d", result);
result = SDL_SyncWindow(window);
SDLTest_AssertPass("SDL_SyncWindow()");
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Verify return value; expected: SDL_TRUE, got: %d", result);
/* Check we are filling the full display */
currentDisplay = SDL_GetDisplayForWindow(window);
@@ -1798,7 +1798,7 @@ static int video_setWindowCenteredOnDisplay(void *arg)
*/
result = SDL_GetDisplayBounds(expectedDisplay, &expectedFullscreenRect);
SDLTest_AssertPass("SDL_GetDisplayBounds()");
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Verify return value; expected: SDL_TRUE, got: %d", result);
if (video_driver_is_wayland) {
SDLTest_Log("Skipping display ID validation: Wayland driver does not support window positioning");
@@ -1821,11 +1821,11 @@ static int video_setWindowCenteredOnDisplay(void *arg)
/* Leave fullscreen desktop */
result = SDL_SetWindowFullscreen(window, SDL_FALSE);
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Verify return value; expected: SDL_TRUE, got: %d", result);
result = SDL_SyncWindow(window);
SDLTest_AssertPass("SDL_SyncWindow()");
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Verify return value; expected: SDL_TRUE, got: %d", result);
/* Check window was restored correctly */
currentDisplay = SDL_GetDisplayForWindow(window);
@@ -1862,7 +1862,7 @@ static int video_setWindowCenteredOnDisplay(void *arg)
result = SDL_SyncWindow(window);
SDLTest_AssertPass("SDL_SyncWindow()");
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Verify return value; expected: SDL_TRUE, got: %d", result);
currentDisplay = SDL_GetDisplayForWindow(window);
SDL_GetWindowSize(window, &currentW, &currentH);
@@ -1958,16 +1958,15 @@ static int video_getSetWindowState(void *arg)
/* Maximize and check the dimensions */
result = SDL_MaximizeWindow(window);
SDLTest_AssertPass("SDL_MaximizeWindow()");
if (result < 0) {
if (!result) {
SDLTest_Log("Skipping state transition tests: %s reports window maximizing as unsupported", SDL_GetCurrentVideoDriver());
skipFlags |= SDL_WINDOW_MAXIMIZED;
goto minimize_test;
}
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
result = SDL_SyncWindow(window);
SDLTest_AssertPass("SDL_SyncWindow()");
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Verify return value; expected: SDL_TRUE, got: %d", result);
flags = SDL_GetWindowFlags(window);
SDLTest_AssertPass("SDL_GetWindowFlags()");
@@ -1980,7 +1979,7 @@ static int video_getSetWindowState(void *arg)
if (SDL_strcmp(SDL_GetCurrentVideoDriver(), "windows") != 0) {
result = SDL_GetDisplayUsableBounds(SDL_GetDisplayForWindow(window), &display);
SDLTest_AssertPass("SDL_GetDisplayUsableBounds()");
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Verify return value; expected: SDL_TRUE, got: %d", result);
desiredW = display.w;
desiredH = display.h;
@@ -1997,11 +1996,11 @@ static int video_getSetWindowState(void *arg)
/* Restore and check the dimensions */
result = SDL_RestoreWindow(window);
SDLTest_AssertPass("SDL_RestoreWindow()");
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Verify return value; expected: SDL_TRUE, got: %d", result);
result = SDL_SyncWindow(window);
SDLTest_AssertPass("SDL_SyncWindow()");
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Verify return value; expected: SDL_TRUE, got: %d", result);
flags = SDL_GetWindowFlags(window);
SDLTest_AssertPass("SDL_GetWindowFlags()");
@@ -2026,15 +2025,15 @@ static int video_getSetWindowState(void *arg)
/* Maximize, then immediately restore */
result = SDL_MaximizeWindow(window);
SDLTest_AssertPass("SDL_MaximizeWindow()");
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Verify return value; expected: SDL_TRUE, got: %d", result);
result = SDL_RestoreWindow(window);
SDLTest_AssertPass("SDL_RestoreWindow()");
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Verify return value; expected: SDL_TRUE, got: %d", result);
result = SDL_SyncWindow(window);
SDLTest_AssertPass("SDL_SyncWindow()");
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Verify return value; expected: SDL_TRUE, got: %d", result);
flags = SDL_GetWindowFlags(window);
SDLTest_AssertPass("SDL_GetWindowFlags()");
@@ -2060,15 +2059,15 @@ static int video_getSetWindowState(void *arg)
/* Maximize, then enter fullscreen */
result = SDL_MaximizeWindow(window);
SDLTest_AssertPass("SDL_MaximizeWindow()");
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Verify return value; expected: SDL_TRUE, got: %d", result);
result = SDL_SetWindowFullscreen(window, SDL_TRUE);
SDLTest_AssertPass("SDL_SetWindowFullscreen(SDL_TRUE)");
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Verify return value; expected: SDL_TRUE, got: %d", result);
result = SDL_SyncWindow(window);
SDLTest_AssertPass("SDL_SyncWindow()");
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Verify return value; expected: SDL_TRUE, got: %d", result);
flags = SDL_GetWindowFlags(window);
SDLTest_AssertPass("SDL_GetWindowFlags()");
@@ -2078,7 +2077,7 @@ static int video_getSetWindowState(void *arg)
/* Verify the fullscreen size and position */
result = SDL_GetDisplayBounds(SDL_GetDisplayForWindow(window), &display);
SDLTest_AssertPass("SDL_GetDisplayBounds()");
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Verify return value; expected: SDL_TRUE, got: %d", result);
if (!skipPos) {
desiredX = display.x;
@@ -2103,15 +2102,15 @@ static int video_getSetWindowState(void *arg)
/* Leave fullscreen and restore the window */
result = SDL_SetWindowFullscreen(window, SDL_FALSE);
SDLTest_AssertPass("SDL_SetWindowFullscreen(SDL_FALSE)");
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Verify return value; expected: SDL_TRUE, got: %d", result);
result = SDL_RestoreWindow(window);
SDLTest_AssertPass("SDL_RestoreWindow()");
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Verify return value; expected: SDL_TRUE, got: %d", result);
result = SDL_SyncWindow(window);
SDLTest_AssertPass("SDL_SyncWindow()");
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Verify return value; expected: SDL_TRUE, got: %d", result);
flags = SDL_GetWindowFlags(window);
SDLTest_AssertPass("SDL_GetWindowFlags()");
@@ -2137,29 +2136,29 @@ static int video_getSetWindowState(void *arg)
/* Maximize, change size, and restore */
result = SDL_MaximizeWindow(window);
SDLTest_AssertPass("SDL_MaximizeWindow()");
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Verify return value; expected: SDL_TRUE, got: %d", result);
desiredW = windowedW + 10;
desiredH = windowedH + 10;
result = SDL_SetWindowSize(window, desiredW, desiredH);
SDLTest_AssertPass("SDL_SetWindowSize()");
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Verify return value; expected: SDL_TRUE, got: %d", result);
if (!skipPos) {
desiredX = windowedX + 10;
desiredY = windowedY + 10;
result = SDL_SetWindowPosition(window, desiredX, desiredY);
SDLTest_AssertPass("SDL_SetWindowPosition()");
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Verify return value; expected: SDL_TRUE, got: %d", result);
}
result = SDL_RestoreWindow(window);
SDLTest_AssertPass("SDL_RestoreWindow()");
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Verify return value; expected: SDL_TRUE, got: %d", result);
result = SDL_SyncWindow(window);
SDLTest_AssertPass("SDL_SyncWindow()");
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Verify return value; expected: SDL_TRUE, got: %d", result);
flags = SDL_GetWindowFlags(window);
SDLTest_AssertPass("SDL_GetWindowFlags()");
@@ -2186,27 +2185,27 @@ static int video_getSetWindowState(void *arg)
desiredH = windowedH - 5;
result = SDL_SetWindowSize(window, desiredW, desiredH);
SDLTest_AssertPass("SDL_SetWindowSize()");
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Verify return value; expected: SDL_TRUE, got: %d", result);
if (!skipPos) {
desiredX = windowedX + 5;
desiredY = windowedY + 5;
result = SDL_SetWindowPosition(window, desiredX, desiredY);
SDLTest_AssertPass("SDL_SetWindowPosition()");
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Verify return value; expected: SDL_TRUE, got: %d", result);
}
result = SDL_MaximizeWindow(window);
SDLTest_AssertPass("SDL_MaximizeWindow()");
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Verify return value; expected: SDL_TRUE, got: %d", result);
result = SDL_RestoreWindow(window);
SDLTest_AssertPass("SDL_RestoreWindow()");
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Verify return value; expected: SDL_TRUE, got: %d", result);
result = SDL_SyncWindow(window);
SDLTest_AssertPass("SDL_SyncWindow()");
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Verify return value; expected: SDL_TRUE, got: %d", result);
flags = SDL_GetWindowFlags(window);
SDLTest_AssertPass("SDL_GetWindowFlags()");
@@ -2232,13 +2231,13 @@ minimize_test:
/* Minimize */
result = SDL_MinimizeWindow(window);
if (result == 0) {
if (result) {
SDLTest_AssertPass("SDL_MinimizeWindow()");
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Verify return value; expected: SDL_TRUE, got: %d", result);
result = SDL_SyncWindow(window);
SDLTest_AssertPass("SDL_SyncWindow()");
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Verify return value; expected: SDL_TRUE, got: %d", result);
flags = SDL_GetWindowFlags(window);
SDLTest_AssertPass("SDL_GetWindowFlags()");
@@ -2286,7 +2285,7 @@ static int video_createMinimized(void *arg)
if (SDL_GetWindowFlags(window) & SDL_WINDOW_MINIMIZED) {
result = SDL_RestoreWindow(window);
SDLTest_AssertPass("SDL_RestoreWindow()");
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Verify return value; expected: SDL_TRUE, got: %d", result);
} else {
SDLTest_Log("Requested minimized window on creation, but that isn't supported on this platform.");
}
@@ -2325,7 +2324,7 @@ static int video_createMaximized(void *arg)
if (SDL_GetWindowFlags(window) & SDL_WINDOW_MAXIMIZED) {
result = SDL_RestoreWindow(window);
SDLTest_AssertPass("SDL_RestoreWindow()");
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Verify return value; expected: SDL_TRUE, got: %d", result);
} else {
SDLTest_Log("Requested maximized window on creation, but that isn't supported on this platform.");
}
@@ -2365,7 +2364,7 @@ static int video_getWindowSurface(void *arg)
result = SDL_UpdateWindowSurface(window);
SDLTest_AssertPass("Call to SDL_UpdateWindowSurface(window)");
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Verify return value; expected: SDL_TRUE, got: %d", result);
/* We shouldn't be able to create a renderer on a window with a surface */
renderer = SDL_CreateRenderer(window, renderer_name);
@@ -2374,7 +2373,7 @@ static int video_getWindowSurface(void *arg)
result = SDL_DestroyWindowSurface(window);
SDLTest_AssertPass("Call to SDL_DestroyWindowSurface(window)");
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
SDLTest_AssertCheck(result == SDL_TRUE, "Verify return value; expected: SDL_TRUE, got: %d", result);
SDLTest_AssertCheck(!SDL_WindowHasSurface(window), "Validate that window does not have a surface");
/* We should be able to create a renderer on the window now */

View File

@@ -31,7 +31,7 @@ int main(int argc, char **argv)
return 1;
}
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
if (!SDL_Init(SDL_INIT_VIDEO)) {
SDL_Log("SDL_Init(SDL_INIT_VIDEO) failed: %s", SDL_GetError());
return 1;
}

View File

@@ -298,9 +298,7 @@ SDL_AppResult SDL_AppIterate(void *appstate)
frame_count++;
if (frame_current) {
if (SDL_ReleaseCameraFrame(camera, frame_current) < 0) {
SDL_Log("err SDL_ReleaseCameraFrame: %s", SDL_GetError());
}
SDL_ReleaseCameraFrame(camera, frame_current);
}
/* It's not needed to keep the frame once updated the texture is updated.
@@ -312,7 +310,7 @@ SDL_AppResult SDL_AppIterate(void *appstate)
if (frame_current) {
if (!texture ||
SDL_GetTextureSize(texture, &tw, &th) < 0 ||
!SDL_GetTextureSize(texture, &tw, &th) ||
(int)tw != frame_current->w || (int)th != frame_current->h) {
/* Resize the window to match */
SDL_SetWindowSize(window, frame_current->w, frame_current->h);

View File

@@ -155,7 +155,7 @@ static SDL_bool ReadPixel(int x, int y, SDL_Color *c)
surface = SDL_RenderReadPixels(renderer, &r);
if (surface) {
if (SDL_ReadSurfacePixel(surface, 0, 0, &c->r, &c->g, &c->b, &c->a) == 0) {
if (SDL_ReadSurfacePixel(surface, 0, 0, &c->r, &c->g, &c->b, &c->a)) {
result = SDL_TRUE;
} else {
SDL_Log("Couldn't read pixel: %s\n", SDL_GetError());

View File

@@ -1130,22 +1130,22 @@ static void SDLCALL VirtualGamepadSetPlayerIndex(void *userdata, int player_inde
SDL_Log("Virtual Gamepad: player index set to %d\n", player_index);
}
static int SDLCALL VirtualGamepadRumble(void *userdata, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble)
static SDL_bool SDLCALL VirtualGamepadRumble(void *userdata, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble)
{
SDL_Log("Virtual Gamepad: rumble set to %d/%d\n", low_frequency_rumble, high_frequency_rumble);
return 0;
return SDL_TRUE;
}
static int SDLCALL VirtualGamepadRumbleTriggers(void *userdata, Uint16 left_rumble, Uint16 right_rumble)
static SDL_bool SDLCALL VirtualGamepadRumbleTriggers(void *userdata, Uint16 left_rumble, Uint16 right_rumble)
{
SDL_Log("Virtual Gamepad: trigger rumble set to %d/%d\n", left_rumble, right_rumble);
return 0;
return SDL_TRUE;
}
static int SDLCALL VirtualGamepadSetLED(void *userdata, Uint8 red, Uint8 green, Uint8 blue)
static SDL_bool SDLCALL VirtualGamepadSetLED(void *userdata, Uint8 red, Uint8 green, Uint8 blue)
{
SDL_Log("Virtual Gamepad: LED set to RGB %d,%d,%d\n", red, green, blue);
return 0;
return SDL_TRUE;
}
static void OpenVirtualGamepad(void)
@@ -2044,7 +2044,7 @@ int main(int argc, char *argv[])
}
/* Initialize SDL (Note: video is required to start event loop) */
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_GAMEPAD) < 0) {
if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_GAMEPAD)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
return 1;
}

View File

@@ -80,11 +80,11 @@ int main(int argc, char *argv[])
i += consumed;
}
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
if (!SDL_Init(SDL_INIT_VIDEO)) {
SDL_Log("SDL_Init failed (%s)", SDL_GetError());
return 1;
}
if (SDL_CreateWindowAndRenderer("testdialog", 640, 480, 0, &w, &r) < 0) {
if (!SDL_CreateWindowAndRenderer("testdialog", 640, 480, 0, &w, &r)) {
SDL_Log("Failed to create window and/or renderer: %s\n", SDL_GetError());
SDL_Quit();
return 1;

View File

@@ -54,7 +54,7 @@ int main(int argc, char *argv[])
}
/* Load the SDL library */
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
if (!SDL_Init(SDL_INIT_VIDEO)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
return 1;
}

View File

@@ -120,7 +120,7 @@ int main(int argc, char *argv[])
}
/* Initialize SDL */
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
if (!SDL_Init(SDL_INIT_VIDEO)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init fail : %s\n", SDL_GetError());
return 1;
}

View File

@@ -85,7 +85,7 @@ int main(int argc, char *argv[])
}
/* Load the SDL library */
if (SDL_Init(0) < 0) {
if (!SDL_Init(0)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
return 1;
}

View File

@@ -623,7 +623,7 @@ static SDL_bool GetTextureForMemoryFrame(AVFrame *frame, SDL_Texture **texture)
if (sws_container->context) {
uint8_t *pixels[4];
int pitch[4];
if (SDL_LockTexture(*texture, NULL, (void **)&pixels[0], &pitch[0]) == 0) {
if (SDL_LockTexture(*texture, NULL, (void **)&pixels[0], &pitch[0])) {
sws_scale(sws_container->context, (const uint8_t *const *)frame->data, frame->linesize, 0, frame->height, pixels, pitch);
SDL_UnlockTexture(*texture);
}
@@ -1166,7 +1166,7 @@ static AVCodecContext *OpenAudioStream(AVFormatContext *ic, int stream, const AV
SDL_AudioSpec spec = { SDL_AUDIO_F32, codecpar->ch_layout.nb_channels, codecpar->sample_rate };
audio = SDL_OpenAudioDeviceStream(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, &spec, NULL, NULL);
if (audio) {
SDL_ResumeAudioDevice(SDL_GetAudioStreamDevice(audio));
SDL_ResumeAudioStreamDevice(audio);
} else {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't open audio: %s", SDL_GetError());
}
@@ -1366,7 +1366,7 @@ int main(int argc, char *argv[])
goto quit;
}
if (SDL_Init(SDL_INIT_AUDIO | SDL_INIT_VIDEO) < 0) {
if (!SDL_Init(SDL_INIT_AUDIO | SDL_INIT_VIDEO)) {
return_code = 2;
goto quit;
}
@@ -1403,7 +1403,7 @@ int main(int argc, char *argv[])
}
}
if (SDL_SetWindowTitle(window, file) < 0) {
if (!SDL_SetWindowTitle(window, file)) {
SDL_Log("SDL_SetWindowTitle: %s", SDL_GetError());
}

View File

@@ -253,7 +253,7 @@ static int createInstance(VulkanVideoContext *context)
static int createSurface(VulkanVideoContext *context, SDL_Window *window)
{
if (SDL_Vulkan_CreateSurface(window, context->instance, NULL, &context->surface) < 0) {
if (!SDL_Vulkan_CreateSurface(window, context->instance, NULL, &context->surface)) {
context->surface = VK_NULL_HANDLE;
return -1;
}

View File

@@ -32,7 +32,7 @@ static int SDLCALL enum_callback(void *userdata, const char *origdir, const char
return -1;
}
if (SDL_GetPathInfo(fullpath, &info) < 0) {
if (!SDL_GetPathInfo(fullpath, &info)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't stat '%s': %s", fullpath, SDL_GetError());
} else {
const char *type;
@@ -47,7 +47,7 @@ static int SDLCALL enum_callback(void *userdata, const char *origdir, const char
fullpath, type, info.size, info.modify_time, info.create_time, info.access_time);
if (info.type == SDL_PATHTYPE_DIRECTORY) {
if (SDL_EnumerateDirectory(fullpath, enum_callback, userdata) < 0) {
if (!SDL_EnumerateDirectory(fullpath, enum_callback, userdata)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Enumeration failed!");
}
}
@@ -78,7 +78,7 @@ int main(int argc, char *argv[])
return 1;
}
if (SDL_Init(0) < 0) {
if (!SDL_Init(0)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init() failed: %s\n", SDL_GetError());
return 1;
}
@@ -114,7 +114,7 @@ int main(int argc, char *argv[])
SDL_IOStream *stream;
const char *text = "foo\n";
if (SDL_EnumerateDirectory(base_path, enum_callback, NULL) < 0) {
if (!SDL_EnumerateDirectory(base_path, enum_callback, NULL)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Base path enumeration failed!");
}
@@ -130,19 +130,19 @@ int main(int argc, char *argv[])
}
/* !!! FIXME: put this in a subroutine and make it test more thoroughly (and put it in testautomation). */
if (SDL_CreateDirectory("testfilesystem-test") < 0) {
if (!SDL_CreateDirectory("testfilesystem-test")) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_CreateDirectory('testfilesystem-test') failed: %s", SDL_GetError());
} else if (SDL_CreateDirectory("testfilesystem-test/1") < 0) {
} else if (!SDL_CreateDirectory("testfilesystem-test/1")) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_CreateDirectory('testfilesystem-test/1') failed: %s", SDL_GetError());
} else if (SDL_CreateDirectory("testfilesystem-test/1") < 0) { /* THIS SHOULD NOT FAIL! Making a directory that already exists should succeed here. */
} else if (!SDL_CreateDirectory("testfilesystem-test/1")) { /* THIS SHOULD NOT FAIL! Making a directory that already exists should succeed here. */
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_CreateDirectory('testfilesystem-test/1') failed: %s", SDL_GetError());
} else if (SDL_RenamePath("testfilesystem-test/1", "testfilesystem-test/2") < 0) {
} else if (!SDL_RenamePath("testfilesystem-test/1", "testfilesystem-test/2")) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_RenamePath('testfilesystem-test/1', 'testfilesystem-test/2') failed: %s", SDL_GetError());
} else if (SDL_RemovePath("testfilesystem-test/2") < 0) {
} else if (!SDL_RemovePath("testfilesystem-test/2")) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_RemovePath('testfilesystem-test/2') failed: %s", SDL_GetError());
} else if (SDL_RemovePath("testfilesystem-test") < 0) {
} else if (!SDL_RemovePath("testfilesystem-test")) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_RemovePath('testfilesystem-test') failed: %s", SDL_GetError());
} else if (SDL_RemovePath("testfilesystem-test") < 0) { /* THIS SHOULD NOT FAIL! Removing a directory that is already gone should succeed here. */
} else if (!SDL_RemovePath("testfilesystem-test")) { /* THIS SHOULD NOT FAIL! Removing a directory that is already gone should succeed here. */
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_RemovePath('testfilesystem-test') failed: %s", SDL_GetError());
}
@@ -151,9 +151,9 @@ int main(int argc, char *argv[])
SDL_WriteIO(stream, text, SDL_strlen(text));
SDL_CloseIO(stream);
if (SDL_RenamePath("testfilesystem-A", "testfilesystem-B") < 0) {
if (!SDL_RenamePath("testfilesystem-A", "testfilesystem-B")) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_RenamePath('testfilesystem-A', 'testfilesystem-B') failed: %s", SDL_GetError());
} else if (SDL_CopyFile("testfilesystem-B", "testfilesystem-A") < 0) {
} else if (!SDL_CopyFile("testfilesystem-B", "testfilesystem-A")) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_CopyFile('testfilesystem-B', 'testfilesystem-A') failed: %s", SDL_GetError());
} else {
size_t sizeA, sizeB;
@@ -172,10 +172,10 @@ int main(int argc, char *argv[])
SDL_free(textB);
}
if (SDL_RemovePath("testfilesystem-A") < 0) {
if (!SDL_RemovePath("testfilesystem-A")) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_RemovePath('testfilesystem-A') failed: %s", SDL_GetError());
}
if (SDL_RemovePath("testfilesystem-B") < 0) {
if (!SDL_RemovePath("testfilesystem-B")) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_RemovePath('testfilesystem-B') failed: %s", SDL_GetError());
}
} else {

View File

@@ -56,7 +56,7 @@ static int LoadSprite(const char *file)
if (!sprites[i]) {
return -1;
}
if (SDL_SetTextureBlendMode(sprites[i], blendMode) < 0) {
if (!SDL_SetTextureBlendMode(sprites[i], blendMode)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set blend mode: %s\n", SDL_GetError());
SDL_DestroyTexture(sprites[i]);
return -1;

View File

@@ -202,11 +202,10 @@ static void Render(void)
static void LogSwapInterval(void)
{
int interval = 0;
const int ret_interval = SDL_GL_GetSwapInterval(&interval);
if (ret_interval < 0) {
SDL_Log("Swap Interval : %d error: %s\n", interval, SDL_GetError());
} else {
if (SDL_GL_GetSwapInterval(&interval)) {
SDL_Log("Swap Interval : %d\n", interval);
} else {
SDL_Log("Swap Interval : %d error: %s\n", interval, SDL_GetError());
}
}
@@ -219,7 +218,6 @@ int main(int argc, char *argv[])
SDL_Event event;
Uint64 then, now;
Uint32 frames;
int status;
int dw, dh;
int swap_interval = 0;
@@ -316,40 +314,34 @@ int main(int argc, char *argv[])
SDL_Log("Extensions : %s\n", ctx.glGetString(GL_EXTENSIONS));
SDL_Log("\n");
status = SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value);
if (!status) {
if (SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value)) {
SDL_Log("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value);
} else {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_RED_SIZE: %s\n", SDL_GetError());
}
status = SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value);
if (!status) {
if (SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value)) {
SDL_Log("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value);
} else {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_GREEN_SIZE: %s\n", SDL_GetError());
}
status = SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value);
if (!status) {
if (SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value)) {
SDL_Log("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value);
} else {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_BLUE_SIZE: %s\n", SDL_GetError());
}
status = SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value);
if (!status) {
if (SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value)) {
SDL_Log("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", 16, value);
} else {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_DEPTH_SIZE: %s\n", SDL_GetError());
}
if (fsaa) {
status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value);
if (!status) {
if (SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value)) {
SDL_Log("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value);
} else {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n",
SDL_GetError());
}
status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value);
if (!status) {
if (SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value)) {
SDL_Log("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa,
value);
} else {
@@ -358,8 +350,7 @@ int main(int argc, char *argv[])
}
}
if (accel >= 0) {
status = SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value);
if (!status) {
if (SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value)) {
SDL_Log("SDL_GL_ACCELERATED_VISUAL: requested %d, got %d\n", accel,
value);
} else {

View File

@@ -104,7 +104,6 @@ int main(int argc, char *argv[])
const SDL_DisplayMode *mode;
SDL_Event event;
Uint32 then, now, frames;
int status;
/* Initialize parameters */
fsaa = 0;
@@ -203,44 +202,38 @@ int main(int argc, char *argv[])
SDL_Log("Extensions : %s\n", glGetString(GL_EXTENSIONS));
SDL_Log("\n");
status = SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value);
if (!status) {
if (SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value)) {
SDL_Log("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value);
} else {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_RED_SIZE: %s\n",
SDL_GetError());
}
status = SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value);
if (!status) {
if (SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value)) {
SDL_Log("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value);
} else {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_GREEN_SIZE: %s\n",
SDL_GetError());
}
status = SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value);
if (!status) {
if (SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value)) {
SDL_Log("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value);
} else {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_BLUE_SIZE: %s\n",
SDL_GetError());
}
status = SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value);
if (!status) {
if (SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value)) {
SDL_Log("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", depth, value);
} else {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_DEPTH_SIZE: %s\n",
SDL_GetError());
}
if (fsaa) {
status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value);
if (!status) {
if (SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value)) {
SDL_Log("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value);
} else {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n",
SDL_GetError());
}
status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value);
if (!status) {
if (SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value)) {
SDL_Log("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa,
value);
} else {
@@ -249,8 +242,7 @@ int main(int argc, char *argv[])
}
}
if (accel) {
status = SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value);
if (!status) {
if (SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value)) {
SDL_Log("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value);
} else {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n",
@@ -262,8 +254,7 @@ int main(int argc, char *argv[])
for (i = 0; i < state->num_windows; ++i) {
float aspectAdjust;
status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
if (status) {
if (!SDL_GL_MakeCurrent(state->windows[i], context[i])) {
SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
/* Continue for next window */
@@ -293,8 +284,7 @@ int main(int argc, char *argv[])
if (event.type == SDL_EVENT_WINDOW_RESIZED) {
for (i = 0; i < state->num_windows; ++i) {
if (event.window.windowID == SDL_GetWindowID(state->windows[i])) {
status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
if (status) {
if (!SDL_GL_MakeCurrent(state->windows[i], context[i])) {
SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
break;
}
@@ -313,8 +303,7 @@ int main(int argc, char *argv[])
if (state->windows[i] == NULL) {
continue;
}
status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
if (status) {
if (!SDL_GL_MakeCurrent(state->windows[i], context[i])) {
SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
/* Continue for next window */

View File

@@ -544,14 +544,13 @@ static thread_data *threads;
static void
render_window(int index)
{
int w, h, status;
int w, h;
if (!state->windows[index]) {
return;
}
status = SDL_GL_MakeCurrent(state->windows[index], context[index]);
if (status) {
if (!SDL_GL_MakeCurrent(state->windows[index], context[index])) {
SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
return;
}
@@ -673,7 +672,6 @@ int main(int argc, char *argv[])
int i;
const SDL_DisplayMode *mode;
Uint64 then, now;
int status;
shader_data *data;
/* Initialize parameters */
@@ -786,44 +784,38 @@ int main(int argc, char *argv[])
SDL_Log("Extensions : %s\n", ctx.glGetString(GL_EXTENSIONS));
SDL_Log("\n");
status = SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value);
if (!status) {
if (SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value)) {
SDL_Log("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value);
} else {
SDL_Log("Failed to get SDL_GL_RED_SIZE: %s\n",
SDL_GetError());
}
status = SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value);
if (!status) {
if (SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value)) {
SDL_Log("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value);
} else {
SDL_Log("Failed to get SDL_GL_GREEN_SIZE: %s\n",
SDL_GetError());
}
status = SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value);
if (!status) {
if (SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value)) {
SDL_Log("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value);
} else {
SDL_Log("Failed to get SDL_GL_BLUE_SIZE: %s\n",
SDL_GetError());
}
status = SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value);
if (!status) {
if (SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value)) {
SDL_Log("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", depth, value);
} else {
SDL_Log("Failed to get SDL_GL_DEPTH_SIZE: %s\n",
SDL_GetError());
}
if (fsaa) {
status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value);
if (!status) {
if (SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value)) {
SDL_Log("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value);
} else {
SDL_Log("Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n",
SDL_GetError());
}
status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value);
if (!status) {
if (SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value)) {
SDL_Log("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa,
value);
} else {
@@ -832,8 +824,7 @@ int main(int argc, char *argv[])
}
}
if (accel) {
status = SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value);
if (!status) {
if (SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value)) {
SDL_Log("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value);
} else {
SDL_Log("Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n",
@@ -847,8 +838,7 @@ int main(int argc, char *argv[])
for (i = 0; i < state->num_windows; ++i) {
int w, h;
status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
if (status) {
if (!SDL_GL_MakeCurrent(state->windows[i], context[i])) {
SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
/* Continue for next window */

View File

@@ -329,7 +329,6 @@ static void loop(void)
{
SDL_Event event;
int i;
int status;
/* Check for events */
++frames;
@@ -363,8 +362,7 @@ static void loop(void)
for (i = 0; i < state->num_windows; ++i) {
if (event.window.windowID == SDL_GetWindowID(state->windows[i])) {
int w, h;
status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
if (status) {
if (!SDL_GL_MakeCurrent(state->windows[i], context[i])) {
SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
break;
}
@@ -415,8 +413,7 @@ static void loop(void)
if (!done) {
for (i = 0; i < state->num_windows; ++i) {
status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
if (status) {
if (!SDL_GL_MakeCurrent(state->windows[i], context[i])) {
SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
/* Continue for next window */
@@ -440,7 +437,6 @@ int main(int argc, char *argv[])
int i;
const SDL_DisplayMode *mode;
Uint64 then, now;
int status;
shader_data *data;
char *path = NULL;
@@ -618,44 +614,38 @@ int main(int argc, char *argv[])
SDL_Log("Extensions : %s\n", ctx.glGetString(GL_EXTENSIONS));
SDL_Log("\n");
status = SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value);
if (!status) {
if (SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value)) {
SDL_Log("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value);
} else {
SDL_Log("Failed to get SDL_GL_RED_SIZE: %s\n",
SDL_GetError());
}
status = SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value);
if (!status) {
if (SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value)) {
SDL_Log("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value);
} else {
SDL_Log("Failed to get SDL_GL_GREEN_SIZE: %s\n",
SDL_GetError());
}
status = SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value);
if (!status) {
if (SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value)) {
SDL_Log("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value);
} else {
SDL_Log("Failed to get SDL_GL_BLUE_SIZE: %s\n",
SDL_GetError());
}
status = SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value);
if (!status) {
if (SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value)) {
SDL_Log("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", depth, value);
} else {
SDL_Log("Failed to get SDL_GL_DEPTH_SIZE: %s\n",
SDL_GetError());
}
if (fsaa) {
status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value);
if (!status) {
if (SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value)) {
SDL_Log("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value);
} else {
SDL_Log("Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n",
SDL_GetError());
}
status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value);
if (!status) {
if (SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value)) {
SDL_Log("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa,
value);
} else {
@@ -664,8 +654,7 @@ int main(int argc, char *argv[])
}
}
if (accel) {
status = SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value);
if (!status) {
if (SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value)) {
SDL_Log("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value);
} else {
SDL_Log("Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n",
@@ -679,8 +668,7 @@ int main(int argc, char *argv[])
for (i = 0; i < state->num_windows; ++i) {
int w, h;
status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
if (status) {
if (!SDL_GL_MakeCurrent(state->windows[i], context[i])) {
SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
/* Continue for next window */

View File

@@ -81,8 +81,7 @@ int main(int argc, char **argv)
}
/* Initialize the force feedbackness */
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_JOYSTICK |
SDL_INIT_HAPTIC);
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC);
haptics = SDL_GetHaptics(&num_haptics);
SDL_Log("%d Haptic devices detected.\n", num_haptics);
for (i = 0; i < num_haptics; ++i) {

View File

@@ -99,7 +99,7 @@ int main(int argc, char **argv)
}
for (i = 0; i < state->num_windows; i++) {
if (SDL_SetWindowHitTest(state->windows[i], hitTest, NULL) < 0) {
if (!SDL_SetWindowHitTest(state->windows[i], hitTest, NULL)) {
SDL_Log("Enabling hit-testing failed for window %d: %s", i, SDL_GetError());
SDL_Quit();
return 1;

View File

@@ -71,7 +71,7 @@ int main(int argc, char *argv[])
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");
/* Initialize SDL (Note: video is required to start event loop) */
if (SDL_Init(init_subsystems) < 0) {
if (!SDL_Init(init_subsystems)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
exit(1);
}
@@ -126,7 +126,7 @@ int main(int argc, char *argv[])
haptic = SDL_OpenHapticFromJoystick(joystick);
if (haptic) {
SDL_Log("Joy Haptic Opened\n");
if (SDL_InitHapticRumble(haptic) < 0) {
if (!SDL_InitHapticRumble(haptic)) {
SDL_Log("Could not init Rumble!: %s\n", SDL_GetError());
SDL_CloseHaptic(haptic);
haptic = NULL;

View File

@@ -28,7 +28,7 @@ widelen(char *data)
static char *get_next_line(Uint8 **fdataptr, size_t *fdatalen)
{
char *retval = (char *) *fdataptr;
char *result = (char *) *fdataptr;
Uint8 *ptr = *fdataptr;
size_t len = *fdatalen;
@@ -51,7 +51,7 @@ static char *get_next_line(Uint8 **fdataptr, size_t *fdatalen)
*fdataptr = ptr;
*fdatalen = len;
return retval;
return result;
}
int main(int argc, char *argv[])

View File

@@ -361,14 +361,14 @@ static int unifont_load_texture(Uint32 textureID)
}
unifontTexture[UNIFONT_NUM_TEXTURES * i + textureID] = tex;
SDL_SetTextureBlendMode(tex, SDL_BLENDMODE_BLEND);
if (SDL_UpdateTexture(tex, NULL, textureRGBA, UNIFONT_TEXTURE_PITCH) < 0) {
if (!SDL_UpdateTexture(tex, NULL, textureRGBA, UNIFONT_TEXTURE_PITCH)) {
SDL_Log("unifont error: Failed to update texture %" SDL_PRIu32 " data for renderer %d.\n", textureID, i);
}
}
SDL_free(textureRGBA);
unifontTextureLoaded[textureID] = 1;
return 0;
return -1;
}
static int unifont_glyph_width(Uint32 codepoint)

View File

@@ -37,7 +37,7 @@ int main(int argc, char *argv[])
return 1;
}
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
if (!SDL_Init(SDL_INIT_VIDEO)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
exit(1);
}

View File

@@ -31,7 +31,7 @@ static void log_usage(char *progname, SDLTest_CommonState *state) {
int main(int argc, char *argv[])
{
int i;
int retval = 0;
int result = 0;
int hello = 0;
const char *libname = NULL;
const char *symname = NULL;
@@ -82,7 +82,7 @@ int main(int argc, char *argv[])
}
/* Initialize SDL */
if (SDL_Init(0) < 0) {
if (!SDL_Init(0)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
return 2;
}
@@ -91,13 +91,13 @@ int main(int argc, char *argv[])
if (!lib) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_LoadObject('%s') failed: %s\n",
libname, SDL_GetError());
retval = 3;
result = 3;
} else {
fn = (fntype)SDL_LoadFunction(lib, symname);
if (!fn) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_LoadFunction('%s') failed: %s\n",
symname, SDL_GetError());
retval = 4;
result = 4;
} else {
SDL_Log("Found %s in %s at %p\n", symname, libname, fn);
if (hello) {
@@ -111,5 +111,5 @@ int main(int argc, char *argv[])
}
SDL_Quit();
SDLTest_CommonDestroyState(state);
return retval;
return result;
}

View File

@@ -175,7 +175,7 @@ int main(int argc, char *argv[])
threads = SDL_malloc(nb_threads * sizeof(SDL_Thread*));
/* Load the SDL library */
if (SDL_Init(0) < 0) {
if (!SDL_Init(0)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s\n", SDL_GetError());
exit(1);
}

View File

@@ -105,7 +105,7 @@ int main(int argc, char *argv[])
"Simple MessageBox",
"This is a simple error MessageBox",
NULL);
if (success == -1) {
if (!success) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
quit(1);
}
@@ -114,7 +114,7 @@ int main(int argc, char *argv[])
"Simple MessageBox",
"This is a simple MessageBox with a newline:\r\nHello world!",
NULL);
if (success == -1) {
if (!success) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
quit(1);
}
@@ -123,7 +123,7 @@ int main(int argc, char *argv[])
NULL,
"NULL Title",
NULL);
if (success == -1) {
if (!success) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
quit(1);
}
@@ -132,7 +132,7 @@ int main(int argc, char *argv[])
"NULL Message",
NULL,
NULL);
if (success == -1) {
if (!success) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
quit(1);
}
@@ -142,7 +142,7 @@ int main(int argc, char *argv[])
"UTF-8 Simple MessageBox",
"Unicode text: '牛肉西蘭花' ...",
NULL);
if (success == -1) {
if (!success) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
quit(1);
}
@@ -152,7 +152,7 @@ int main(int argc, char *argv[])
"UTF-8 Simple MessageBox",
"Unicode text and newline:\r\n'牛肉西蘭花'\n'牛肉西蘭花'",
NULL);
if (success == -1) {
if (!success) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
quit(1);
}
@@ -162,7 +162,7 @@ int main(int argc, char *argv[])
"牛肉西蘭花",
"Unicode text in the title.",
NULL);
if (success == -1) {
if (!success) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
quit(1);
}
@@ -175,7 +175,7 @@ int main(int argc, char *argv[])
to work, since the message box events are dispatched by the Cocoa
subsystem on the main thread.
*/
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
if (!SDL_Init(SDL_INIT_VIDEO)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL video subsystem: %s\n", SDL_GetError());
return 1;
}
@@ -211,7 +211,7 @@ int main(int argc, char *argv[])
"Simple MessageBox",
"This is a simple error MessageBox with a parent window. Press a key or close the window after dismissing this messagebox.",
window);
if (success == -1) {
if (!success) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
quit(1);
}

View File

@@ -49,19 +49,18 @@ int main(int argc, char *argv[])
i += consumed;
}
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
if (!SDL_Init(SDL_INIT_VIDEO)) {
SDL_Log("SDL_Init failed (%s)", SDL_GetError());
return 1;
}
if (SDL_CreateWindowAndRenderer("Parent Window", 640, 480, 0, &w1, &r1)) {
if (!SDL_CreateWindowAndRenderer("Parent Window", 640, 480, 0, &w1, &r1)) {
SDL_Log("Failed to create parent window and/or renderer: %s\n", SDL_GetError());
exit_code = 1;
goto sdl_quit;
}
SDL_CreateWindowAndRenderer("Non-Modal Window", 320, 200, 0, &w2, &r2);
if (!w2) {
if (!SDL_CreateWindowAndRenderer("Non-Modal Window", 320, 200, 0, &w2, &r2)) {
SDL_Log("Failed to create parent window and/or renderer: %s\n", SDL_GetError());
exit_code = 1;
goto sdl_quit;
@@ -92,7 +91,7 @@ int main(int argc, char *argv[])
}
} else if (e.type == SDL_EVENT_KEY_DOWN) {
if ((e.key.key == SDLK_M || e.key.key == SDLK_N) && !w2) {
if (SDL_CreateWindowAndRenderer("Non-Modal Window", 320, 200, SDL_WINDOW_HIDDEN, &w2, &r2) < 0) {
if (!SDL_CreateWindowAndRenderer("Non-Modal Window", 320, 200, SDL_WINDOW_HIDDEN, &w2, &r2)) {
SDL_Log("Failed to create modal window and/or renderer: %s\n", SDL_GetError());
exit_code = 1;
goto sdl_quit;

View File

@@ -297,7 +297,7 @@ int main(int argc, char *argv[])
}
/* Initialize SDL (Note: video is required to start event loop) */
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
if (!SDL_Init(SDL_INIT_VIDEO)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
exit(1);
}

View File

@@ -64,7 +64,7 @@ test_multi_audio(const SDL_AudioDeviceID *devices, int devcount)
if ((stream = SDL_OpenAudioDeviceStream(devices[i], &spec, NULL, NULL)) == NULL) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Audio stream creation failed: %s", SDL_GetError());
} else {
SDL_ResumeAudioDevice(SDL_GetAudioStreamDevice(stream));
SDL_ResumeAudioStreamDevice(stream);
SDL_PutAudioStreamData(stream, sound, soundlen);
SDL_FlushAudioStream(stream);
#ifdef SDL_PLATFORM_EMSCRIPTEN
@@ -104,7 +104,7 @@ test_multi_audio(const SDL_AudioDeviceID *devices, int devcount)
/* try to start all the devices about the same time. SDL does not guarantee sync across physical devices. */
for (i = 0; i < devcount; i++) {
if (streams[i]) {
SDL_ResumeAudioDevice(SDL_GetAudioStreamDevice(streams[i]));
SDL_ResumeAudioStreamDevice(streams[i]);
}
}
@@ -171,7 +171,7 @@ int main(int argc, char **argv)
}
/* Load the SDL library */
if (SDL_Init(SDL_INIT_AUDIO) < 0) {
if (!SDL_Init(SDL_INIT_AUDIO)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
return 1;
}
@@ -185,12 +185,12 @@ int main(int argc, char **argv)
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Don't see any specific audio playback devices!");
} else {
/* Load the wave file into memory */
if (SDL_LoadWAV(filename, &spec, &sound, &soundlen) < 0) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", filename,
SDL_GetError());
} else {
if (SDL_LoadWAV(filename, &spec, &sound, &soundlen)) {
test_multi_audio(devices, devcount);
SDL_free(sound);
} else {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", filename,
SDL_GetError());
}
SDL_free(devices);
}

View File

@@ -125,7 +125,7 @@ int main(int argc, char *argv[])
return 1;
}
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
if (!SDL_Init(SDL_INIT_VIDEO)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL video: %s\n",
SDL_GetError());
exit(1);

View File

@@ -110,7 +110,7 @@ int main(int argc, char *argv[])
/* Force the offscreen renderer, if it cannot be created then fail out */
SDL_SetHint(SDL_HINT_VIDEO_DRIVER, "offscreen");
if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) {
if (!SDL_InitSubSystem(SDL_INIT_VIDEO)) {
SDL_Log("Couldn't initialize the offscreen video driver: %s\n",
SDL_GetError());
return SDL_FALSE;

View File

@@ -77,7 +77,7 @@ int main(int argc, char *argv[])
return 1;
}
if (SDL_Init(0) < 0) {
if (!SDL_Init(0)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init() failed: %s\n", SDL_GetError());
return 1;
}

View File

@@ -78,7 +78,7 @@ DrawComposite(DrawState *s)
surface = SDL_RenderReadPixels(s->renderer, NULL);
if (surface) {
Uint8 r, g, b, a;
if (SDL_ReadSurfacePixel(surface, 0, 0, &r, &g, &b, &a) == 0) {
if (SDL_ReadSurfacePixel(surface, 0, 0, &r, &g, &b, &a)) {
SDL_Log("Blended pixel: 0x%.2x%.2x%.2x%.2x\n", r, g, b, a);
}
SDL_DestroySurface(surface);

View File

@@ -95,20 +95,20 @@ int main(int argc, char **argv)
goto end;
}
if (SDL_Init(SDL_INIT_AUDIO) < 0) {
if (!SDL_Init(SDL_INIT_AUDIO)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init() failed: %s\n", SDL_GetError());
ret = 2;
goto end;
}
if (SDL_LoadWAV(file_in, &spec, &data, &len) < 0) {
if (!SDL_LoadWAV(file_in, &spec, &data, &len)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "failed to load %s: %s\n", file_in, SDL_GetError());
ret = 3;
goto end;
}
cvtspec.format = spec.format;
if (SDL_ConvertAudioSamples(&spec, data, len, &cvtspec, &dst_buf, &dst_len) < 0) {
if (!SDL_ConvertAudioSamples(&spec, data, len, &cvtspec, &dst_buf, &dst_len)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "failed to convert samples: %s\n", SDL_GetError());
ret = 4;
goto end;
@@ -141,7 +141,7 @@ int main(int argc, char **argv)
SDL_WriteU32LE(io, dst_len); /* size */
SDL_WriteIO(io, dst_buf, dst_len);
if (SDL_CloseIO(io) < 0) {
if (!SDL_CloseIO(io)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "closing '%s' failed: %s\n", file_out, SDL_GetError());
ret = 6;
goto end;

View File

@@ -85,8 +85,7 @@ int main(int argc, char **argv)
}
/* Initialize the force feedbackness */
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_JOYSTICK |
SDL_INIT_HAPTIC);
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC);
haptics = SDL_GetHaptics(&num_haptics);
SDL_Log("%d Haptic devices detected.\n", num_haptics);
if (num_haptics == 0) {
@@ -132,16 +131,16 @@ int main(int argc, char **argv)
/* We only want force feedback errors. */
SDL_ClearError();
if (SDL_HapticRumbleSupported(haptic) == SDL_FALSE) {
if (!SDL_HapticRumbleSupported(haptic)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Rumble not supported!\n");
return 1;
}
if (SDL_InitHapticRumble(haptic) < 0) {
if (!SDL_InitHapticRumble(haptic)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to initialize rumble: %s\n", SDL_GetError());
return 1;
}
SDL_Log("Playing 2 second rumble at 0.5 magnitude.\n");
if (SDL_PlayHapticRumble(haptic, 0.5, 5000) < 0) {
if (!SDL_PlayHapticRumble(haptic, 0.5, 5000)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to play rumble: %s\n", SDL_GetError());
return 1;
}
@@ -150,7 +149,7 @@ int main(int argc, char **argv)
SDL_StopHapticRumble(haptic);
SDL_Delay(2000);
SDL_Log("Playing 2 second rumble at 0.3 magnitude.\n");
if (SDL_PlayHapticRumble(haptic, 0.3f, 5000) < 0) {
if (!SDL_PlayHapticRumble(haptic, 0.3f, 5000)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to play rumble: %s\n", SDL_GetError());
return 1;
}

View File

@@ -133,7 +133,7 @@ int main(int argc, char *argv[])
threads = SDL_malloc(nb_threads * sizeof(SDL_Thread*));
/* Load the SDL library */
if (SDL_Init(0) < 0) {
if (!SDL_Init(0)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s\n", SDL_GetError());
return 1;
}

View File

@@ -108,13 +108,13 @@ TestWaitTimeout(void)
Uint64 start_ticks;
Uint64 end_ticks;
Uint64 duration;
int retval;
SDL_bool result;
sem = SDL_CreateSemaphore(0);
SDL_Log("Waiting 2 seconds on semaphore\n");
start_ticks = SDL_GetTicks();
retval = SDL_WaitSemaphoreTimeout(sem, 2000);
result = SDL_WaitSemaphoreTimeout(sem, 2000);
end_ticks = SDL_GetTicks();
duration = end_ticks - start_ticks;
@@ -124,8 +124,8 @@ TestWaitTimeout(void)
SDL_assert(duration > 1900 && duration < 2050);
/* Check to make sure the return value indicates timed out */
if (retval != SDL_MUTEX_TIMEDOUT) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_WaitSemaphoreTimeout returned: %d; expected: %d\n\n", retval, SDL_MUTEX_TIMEDOUT);
if (result) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_WaitSemaphoreTimeout returned: %d; expected: SDL_FALSE\n\n", result);
}
SDL_DestroySemaphore(sem);
@@ -166,7 +166,7 @@ ThreadFuncOverheadContended(void *data)
if (state->flag) {
while (alive) {
if (SDL_TryWaitSemaphore(sem) == SDL_MUTEX_TIMEDOUT) {
if (!SDL_TryWaitSemaphore(sem)) {
++state->content_count;
}
++state->loop_count;
@@ -174,7 +174,7 @@ ThreadFuncOverheadContended(void *data)
} else {
while (alive) {
/* Timeout needed to allow check on alive flag */
if (SDL_WaitSemaphoreTimeout(sem, 50) == SDL_MUTEX_TIMEDOUT) {
if (!SDL_WaitSemaphoreTimeout(sem, 50)) {
++state->content_count;
}
++state->loop_count;
@@ -302,7 +302,7 @@ int main(int argc, char **argv)
}
/* Load the SDL library */
if (SDL_Init(0) < 0) {
if (!SDL_Init(0)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
return 1;
}

View File

@@ -78,7 +78,7 @@ int main(int argc, char **argv)
}
/* Load the SDL library */
if (SDL_Init(SDL_INIT_SENSOR) < 0) {
if (!SDL_Init(SDL_INIT_SENSOR)) {
SDL_Log("Couldn't initialize SDL: %s\n", SDL_GetError());
SDL_Quit();
SDLTest_CommonDestroyState(state);

View File

@@ -482,7 +482,7 @@ int main(int argc, char **argv)
}
/* Initialize SDL for video output */
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
if (!SDL_Init(SDL_INIT_VIDEO)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to initialize SDL: %s\n", SDL_GetError());
exit(1);
}

View File

@@ -20,7 +20,7 @@ static SDL_HitTestResult SDLCALL ShapeHitTest(SDL_Window *window, const SDL_Poin
SDL_Surface *shape = (SDL_Surface *)userdata;
Uint8 r, g, b, a;
if (SDL_ReadSurfacePixel(shape, area->x, area->y, &r, &g, &b, &a) == 0) {
if (SDL_ReadSurfacePixel(shape, area->x, area->y, &r, &g, &b, &a)) {
if (a != SDL_ALPHA_TRANSPARENT) {
/* We'll just make everything draggable */
return SDL_HITTEST_DRAGGABLE;
@@ -96,7 +96,7 @@ int main(int argc, char *argv[])
if (!resizable) {
/* Set the hit test callback so we can drag the window */
if (SDL_SetWindowHitTest(window, ShapeHitTest, shape) < 0) {
if (!SDL_SetWindowHitTest(window, ShapeHitTest, shape)) {
SDL_Log("Couldn't set hit test callback: %s\n", SDL_GetError());
goto quit;
}

View File

@@ -62,7 +62,7 @@ static int LoadSprite(const char *file)
if (!sprites[i]) {
return -1;
}
if (SDL_SetTextureBlendMode(sprites[i], blendMode) < 0) {
if (!SDL_SetTextureBlendMode(sprites[i], blendMode)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set blend mode: %s\n", SDL_GetError());
SDL_DestroyTexture(sprites[i]);
return -1;

View File

@@ -120,7 +120,7 @@ int main(int argc, char *argv[])
goto quit;
}
if (SDL_CreateWindowAndRenderer("testspriteminimal", WINDOW_WIDTH, WINDOW_HEIGHT, 0, &window, &renderer) < 0) {
if (!SDL_CreateWindowAndRenderer("testspriteminimal", WINDOW_WIDTH, WINDOW_HEIGHT, 0, &window, &renderer)) {
return_code = 2;
goto quit;
}

View File

@@ -85,7 +85,7 @@ static void UpdateTexture(SDL_Texture *texture)
void *pixels;
int pitch;
if (SDL_LockTexture(texture, NULL, &pixels, &pitch) < 0) {
if (!SDL_LockTexture(texture, NULL, &pixels, &pitch)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't lock texture: %s\n", SDL_GetError());
quit(5);
}
@@ -154,7 +154,7 @@ int main(int argc, char **argv)
return 1;
}
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
if (!SDL_Init(SDL_INIT_VIDEO)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
return 1;
}

View File

@@ -165,7 +165,7 @@ int main(int argc, char *argv[])
return 1;
}
if (SDL_Init(SDL_INIT_AUDIO) < 0) {
if (!SDL_Init(SDL_INIT_AUDIO)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
return 1;
}
@@ -196,7 +196,7 @@ int main(int argc, char *argv[])
SDL_Log("Testing audio device: %s\n", devname);
if (SDL_GetAudioDeviceFormat(devices[i], &spec, NULL) < 0) {
if (!SDL_GetAudioDeviceFormat(devices[i], &spec, NULL)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_GetAudioDeviceFormat() failed: %s\n", SDL_GetError());
continue;
}
@@ -215,7 +215,7 @@ int main(int argc, char *argv[])
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_OpenAudioDeviceStream() failed: %s\n", SDL_GetError());
continue;
}
SDL_ResumeAudioDevice(SDL_GetAudioStreamDevice(stream));
SDL_ResumeAudioStreamDevice(stream);
for (j = 0; j < total_channels; j++) {
const int sine_freq = is_lfe_channel(j, total_channels) ? LFE_SINE_FREQ_HZ : SINE_FREQ_HZ;

View File

@@ -122,7 +122,7 @@ int main(int argc, char *argv[])
}
/* Load the SDL library */
if (SDL_Init(0) < 0) {
if (!SDL_Init(0)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
return 1;
}

View File

@@ -119,7 +119,7 @@ int main(int argc, char *argv[])
i += consumed;
}
if (SDL_Init(SDL_INIT_TIMER) < 0) {
if (!SDL_Init(SDL_INIT_TIMER)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
return 1;
}

View File

@@ -15,7 +15,7 @@
static void tryOpenURL(const char *url)
{
SDL_Log("Opening '%s' ...", url);
if (SDL_OpenURL(url) == 0) {
if (SDL_OpenURL(url)) {
SDL_Log(" success!");
} else {
SDL_Log(" failed! %s", SDL_GetError());
@@ -25,7 +25,7 @@ static void tryOpenURL(const char *url)
int main(int argc, char **argv)
{
int i;
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
if (!SDL_Init(SDL_INIT_VIDEO)) {
SDL_Log("SDL_Init failed: %s\n", SDL_GetError());
return 1;
}

View File

@@ -262,7 +262,7 @@ static void loadInstanceFunctions(void)
static void createSurface(void)
{
if (SDL_Vulkan_CreateSurface(vulkanContext->window, vulkanContext->instance, NULL, &vulkanContext->surface) < 0) {
if (!SDL_Vulkan_CreateSurface(vulkanContext->window, vulkanContext->instance, NULL, &vulkanContext->surface)) {
vulkanContext->surface = VK_NULL_HANDLE;
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Vulkan_CreateSurface(): %s\n", SDL_GetError());
quit(2);
@@ -1007,7 +1007,7 @@ static void shutdownVulkan(SDL_bool doDestroySwapchain)
static SDL_bool render(void)
{
uint32_t frameIndex;
VkResult result;
VkResult rc;
double currentTime;
VkClearColorValue clearColor = { { 0 } };
VkPipelineStageFlags waitDestStageMask = VK_PIPELINE_STAGE_TRANSFER_BIT;
@@ -1016,36 +1016,36 @@ static SDL_bool render(void)
int w, h;
if (!vulkanContext->swapchain) {
SDL_bool retval = createNewSwapchainAndSwapchainSpecificStuff();
if (!retval) {
SDL_bool result = createNewSwapchainAndSwapchainSpecificStuff();
if (!result) {
SDL_Delay(100);
}
return retval;
return result;
}
result = vkAcquireNextImageKHR(vulkanContext->device,
vulkanContext->swapchain,
UINT64_MAX,
vulkanContext->imageAvailableSemaphore,
VK_NULL_HANDLE,
&frameIndex);
if (result == VK_ERROR_OUT_OF_DATE_KHR) {
rc = vkAcquireNextImageKHR(vulkanContext->device,
vulkanContext->swapchain,
UINT64_MAX,
vulkanContext->imageAvailableSemaphore,
VK_NULL_HANDLE,
&frameIndex);
if (rc == VK_ERROR_OUT_OF_DATE_KHR) {
return createNewSwapchainAndSwapchainSpecificStuff();
}
if ((result != VK_SUBOPTIMAL_KHR) && (result != VK_SUCCESS)) {
if ((rc != VK_SUBOPTIMAL_KHR) && (rc != VK_SUCCESS)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"vkAcquireNextImageKHR(): %s\n",
getVulkanResultString(result));
getVulkanResultString(rc));
quit(2);
}
result = vkWaitForFences(vulkanContext->device, 1, &vulkanContext->fences[frameIndex], VK_FALSE, UINT64_MAX);
if (result != VK_SUCCESS) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "vkWaitForFences(): %s\n", getVulkanResultString(result));
rc = vkWaitForFences(vulkanContext->device, 1, &vulkanContext->fences[frameIndex], VK_FALSE, UINT64_MAX);
if (rc != VK_SUCCESS) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "vkWaitForFences(): %s\n", getVulkanResultString(rc));
quit(2);
}
result = vkResetFences(vulkanContext->device, 1, &vulkanContext->fences[frameIndex]);
if (result != VK_SUCCESS) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "vkResetFences(): %s\n", getVulkanResultString(result));
rc = vkResetFences(vulkanContext->device, 1, &vulkanContext->fences[frameIndex]);
if (rc != VK_SUCCESS) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "vkResetFences(): %s\n", getVulkanResultString(rc));
quit(2);
}
currentTime = (double)SDL_GetPerformanceCounter() / SDL_GetPerformanceFrequency();
@@ -1062,10 +1062,10 @@ static SDL_bool render(void)
submitInfo.pCommandBuffers = &vulkanContext->commandBuffers[frameIndex];
submitInfo.signalSemaphoreCount = 1;
submitInfo.pSignalSemaphores = &vulkanContext->renderingFinishedSemaphore;
result = vkQueueSubmit(vulkanContext->graphicsQueue, 1, &submitInfo, vulkanContext->fences[frameIndex]);
rc = vkQueueSubmit(vulkanContext->graphicsQueue, 1, &submitInfo, vulkanContext->fences[frameIndex]);
if (result != VK_SUCCESS) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "vkQueueSubmit(): %s\n", getVulkanResultString(result));
if (rc != VK_SUCCESS) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "vkQueueSubmit(): %s\n", getVulkanResultString(rc));
quit(2);
}
presentInfo.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
@@ -1074,15 +1074,15 @@ static SDL_bool render(void)
presentInfo.swapchainCount = 1;
presentInfo.pSwapchains = &vulkanContext->swapchain;
presentInfo.pImageIndices = &frameIndex;
result = vkQueuePresentKHR(vulkanContext->presentQueue, &presentInfo);
if ((result == VK_ERROR_OUT_OF_DATE_KHR) || (result == VK_SUBOPTIMAL_KHR)) {
rc = vkQueuePresentKHR(vulkanContext->presentQueue, &presentInfo);
if ((rc == VK_ERROR_OUT_OF_DATE_KHR) || (rc == VK_SUBOPTIMAL_KHR)) {
return createNewSwapchainAndSwapchainSpecificStuff();
}
if (result != VK_SUCCESS) {
if (rc != VK_SUCCESS) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"vkQueuePresentKHR(): %s\n",
getVulkanResultString(result));
getVulkanResultString(rc));
quit(2);
}
SDL_GetWindowSizeInPixels(vulkanContext->window, &w, &h);

View File

@@ -194,7 +194,7 @@ int main(int argc, char **argv)
int ret = -1;
SDL_PropertiesID props;
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS) != 0) {
if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS)) {
return -1;
}

View File

@@ -77,7 +77,7 @@ static SDL_bool verify_yuv_data(Uint32 format, SDL_Colorspace colorspace, const
return SDL_FALSE;
}
if (SDL_ConvertPixelsAndColorspace(surface->w, surface->h, format, colorspace, 0, yuv, yuv_pitch, surface->format, SDL_COLORSPACE_SRGB, 0, rgb, surface->pitch) == 0) {
if (SDL_ConvertPixelsAndColorspace(surface->w, surface->h, format, colorspace, 0, yuv, yuv_pitch, surface->format, SDL_COLORSPACE_SRGB, 0, rgb, surface->pitch)) {
int x, y;
result = SDL_TRUE;
for (y = 0; y < surface->h; ++y) {
@@ -151,7 +151,7 @@ static int run_automated_tests(int pattern_size, int extra_pitch)
/* Verify conversion to YUV formats */
for (i = 0; i < SDL_arraysize(formats); ++i) {
yuv1_pitch = CalculateYUVPitch(formats[i], pattern->w) + extra_pitch;
if (SDL_ConvertPixelsAndColorspace(pattern->w, pattern->h, pattern->format, SDL_COLORSPACE_SRGB, 0, pattern->pixels, pattern->pitch, formats[i], colorspace, 0, yuv1, yuv1_pitch) < 0) {
if (!SDL_ConvertPixelsAndColorspace(pattern->w, pattern->h, pattern->format, SDL_COLORSPACE_SRGB, 0, pattern->pixels, pattern->pitch, formats[i], colorspace, 0, yuv1, yuv1_pitch)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't convert %s to %s: %s\n", SDL_GetPixelFormatName(pattern->format), SDL_GetPixelFormatName(formats[i]), SDL_GetError());
goto done;
}
@@ -166,11 +166,11 @@ static int run_automated_tests(int pattern_size, int extra_pitch)
for (j = 0; j < SDL_arraysize(formats); ++j) {
yuv1_pitch = CalculateYUVPitch(formats[i], pattern->w) + extra_pitch;
yuv2_pitch = CalculateYUVPitch(formats[j], pattern->w) + extra_pitch;
if (SDL_ConvertPixelsAndColorspace(pattern->w, pattern->h, pattern->format, SDL_COLORSPACE_SRGB, 0, pattern->pixels, pattern->pitch, formats[i], colorspace, 0, yuv1, yuv1_pitch) < 0) {
if (!SDL_ConvertPixelsAndColorspace(pattern->w, pattern->h, pattern->format, SDL_COLORSPACE_SRGB, 0, pattern->pixels, pattern->pitch, formats[i], colorspace, 0, yuv1, yuv1_pitch)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't convert %s to %s: %s\n", SDL_GetPixelFormatName(pattern->format), SDL_GetPixelFormatName(formats[i]), SDL_GetError());
goto done;
}
if (SDL_ConvertPixelsAndColorspace(pattern->w, pattern->h, formats[i], colorspace, 0, yuv1, yuv1_pitch, formats[j], colorspace, 0, yuv2, yuv2_pitch) < 0) {
if (!SDL_ConvertPixelsAndColorspace(pattern->w, pattern->h, formats[i], colorspace, 0, yuv1, yuv1_pitch, formats[j], colorspace, 0, yuv2, yuv2_pitch)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't convert %s to %s: %s\n", SDL_GetPixelFormatName(formats[i]), SDL_GetPixelFormatName(formats[j]), SDL_GetError());
goto done;
}
@@ -191,11 +191,11 @@ static int run_automated_tests(int pattern_size, int extra_pitch)
yuv1_pitch = CalculateYUVPitch(formats[i], pattern->w) + extra_pitch;
yuv2_pitch = CalculateYUVPitch(formats[j], pattern->w) + extra_pitch;
if (SDL_ConvertPixelsAndColorspace(pattern->w, pattern->h, pattern->format, SDL_COLORSPACE_SRGB, 0, pattern->pixels, pattern->pitch, formats[i], colorspace, 0, yuv1, yuv1_pitch) < 0) {
if (!SDL_ConvertPixelsAndColorspace(pattern->w, pattern->h, pattern->format, SDL_COLORSPACE_SRGB, 0, pattern->pixels, pattern->pitch, formats[i], colorspace, 0, yuv1, yuv1_pitch)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't convert %s to %s: %s\n", SDL_GetPixelFormatName(pattern->format), SDL_GetPixelFormatName(formats[i]), SDL_GetError());
goto done;
}
if (SDL_ConvertPixelsAndColorspace(pattern->w, pattern->h, formats[i], colorspace, 0, yuv1, yuv1_pitch, formats[j], colorspace, 0, yuv1, yuv2_pitch) < 0) {
if (!SDL_ConvertPixelsAndColorspace(pattern->w, pattern->h, formats[i], colorspace, 0, yuv1, yuv1_pitch, formats[j], colorspace, 0, yuv1, yuv2_pitch)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't convert %s to %s: %s\n", SDL_GetPixelFormatName(formats[i]), SDL_GetPixelFormatName(formats[j]), SDL_GetError());
goto done;
}
@@ -220,7 +220,7 @@ static int run_automated_tests(int pattern_size, int extra_pitch)
/* The pitch needs to be Uint16 aligned for P010 pixels */
yuv1_pitch = CalculateYUVPitch(SDL_PIXELFORMAT_P010, pattern->w) + ((extra_pitch + 1) & ~1);
if (SDL_ConvertPixelsAndColorspace(pattern->w, pattern->h, pattern->format, SDL_COLORSPACE_SRGB, 0, pattern->pixels, pattern->pitch, SDL_PIXELFORMAT_P010, colorspace, 0, yuv1, yuv1_pitch) < 0) {
if (!SDL_ConvertPixelsAndColorspace(pattern->w, pattern->h, pattern->format, SDL_COLORSPACE_SRGB, 0, pattern->pixels, pattern->pitch, SDL_PIXELFORMAT_P010, colorspace, 0, yuv1, yuv1_pitch)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't convert %s to %s: %s\n", SDL_GetPixelFormatName(pattern->format), SDL_GetPixelFormatName(SDL_PIXELFORMAT_P010), SDL_GetError());
goto done;
}

View File

@@ -92,7 +92,7 @@ int main(int argc, char *argv[])
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Load the SDL library */
if (SDL_Init(0) < 0) {
if (!SDL_Init(0)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
return 1;
}