Remove newlines from log messages

This commit is contained in:
nightmareci
2025-01-22 12:59:57 -08:00
committed by Sam Lantinga
parent 17625e20df
commit 718034f5fa
123 changed files with 1143 additions and 1118 deletions

View File

@@ -185,7 +185,7 @@ static void PrintModifierState(void)
left = sizeof(message);
print_modifiers(&spot, &left, SDL_GetModState());
SDL_Log("Initial state:%s\n", message);
SDL_Log("Initial state:%s", message);
}
static void PrintKey(SDL_KeyboardEvent *event)
@@ -218,7 +218,7 @@ static void PrintKey(SDL_KeyboardEvent *event)
if (event->repeat) {
print_string(&spot, &left, " (repeat)");
}
SDL_Log("%s\n", message);
SDL_Log("%s", message);
}
static void PrintText(const char *eventtype, const char *text)
@@ -231,7 +231,7 @@ static void PrintText(const char *eventtype, const char *text)
size_t length = SDL_strlen(expanded);
(void)SDL_snprintf(expanded + length, sizeof(expanded) - length, "\\x%.2x", (unsigned char)*spot);
}
SDL_Log("%s Text (%s): \"%s%s\"\n", eventtype, expanded, *text == '"' ? "\\" : "", text);
SDL_Log("%s Text (%s): \"%s%s\"", eventtype, expanded, *text == '"' ? "\\" : "", text);
}
static void CountKeysDown(void)
@@ -244,7 +244,7 @@ static void CountKeysDown(void)
++count;
}
}
SDL_Log("Keys down: %d\n", count);
SDL_Log("Keys down: %d", count);
}
static void DrawCursor(int i)
@@ -373,10 +373,10 @@ static void loop(void)
{
SDL_Window *window = SDL_GetWindowFromEvent(&event);
if (SDL_TextInputActive(window)) {
SDL_Log("Stopping text input for window %" SDL_PRIu32 "\n", event.tfinger.windowID);
SDL_Log("Stopping text input for window %" SDL_PRIu32, event.tfinger.windowID);
SDL_StopTextInput(window);
} else {
SDL_Log("Starting text input for window %" SDL_PRIu32 "\n", event.tfinger.windowID);
SDL_Log("Starting text input for window %" SDL_PRIu32, event.tfinger.windowID);
SDL_StartTextInput(window);
}
break;
@@ -385,16 +385,16 @@ static void loop(void)
if (event.button.button == SDL_BUTTON_RIGHT) {
SDL_Window *window = SDL_GetWindowFromEvent(&event);
if (SDL_TextInputActive(window)) {
SDL_Log("Stopping text input for window %" SDL_PRIu32 "\n", event.button.windowID);
SDL_Log("Stopping text input for window %" SDL_PRIu32, event.button.windowID);
SDL_StopTextInput(window);
} else {
SDL_Log("Starting text input for window %" SDL_PRIu32 "\n", event.button.windowID);
SDL_Log("Starting text input for window %" SDL_PRIu32, event.button.windowID);
SDL_StartTextInput(window);
}
}
break;
case SDL_EVENT_KEYMAP_CHANGED:
SDL_Log("Keymap changed!\n");
SDL_Log("Keymap changed!");
break;
case SDL_EVENT_QUIT:
done = 1;
@@ -466,13 +466,13 @@ int main(int argc, char *argv[])
/* Initialize SDL */
if (!SDLTest_CommonInit(state)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s", SDL_GetError());
return 1;
}
windowstates = (TextWindowState *)SDL_calloc(state->num_windows, sizeof(*windowstates));
if (!windowstates) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't allocate text windows: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't allocate text windows: %s", SDL_GetError());
goto done;
}

View File

@@ -142,7 +142,7 @@ int main(int argc, char *argv[]) {
#else
SDL_strlcpy(error, strerror(errno), sizeof(error));
#endif
SDL_Log("Error reading from stdin: %s\n", error);
SDL_Log("Error reading from stdin: %s", error);
}
break;
}

View File

@@ -78,20 +78,20 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
/* Load the SDL library */
if (!SDL_Init(SDL_INIT_AUDIO | SDL_INIT_EVENTS)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s", SDL_GetError());
return SDL_APP_FAILURE;
}
filename = GetResourceFilename(filename, "sample.wav");
if (!filename) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s", SDL_GetError());
return SDL_APP_FAILURE;
}
/* Load the wave file into memory */
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_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", filename, SDL_GetError());
SDL_free(filename);
return SDL_APP_FAILURE;
}
@@ -104,11 +104,11 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
SDL_Log("%i: %s", i, SDL_GetAudioDriver(i));
}
SDL_Log("Using audio driver: %s\n", SDL_GetCurrentAudioDriver());
SDL_Log("Using audio driver: %s", SDL_GetCurrentAudioDriver());
stream = SDL_OpenAudioDeviceStream(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, &wave.spec, NULL, NULL);
if (!stream) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create audio stream: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create audio stream: %s", SDL_GetError());
return SDL_APP_FAILURE;
}

View File

@@ -40,39 +40,43 @@ static void RunBasicTest(void)
SDL_AtomicInt v;
bool tfret = false;
SDL_Log("\nspin lock---------------------------------------\n\n");
SDL_Log("%s", "");
SDL_Log("spin lock---------------------------------------");
SDL_Log("%s", "");
SDL_LockSpinlock(&lock);
SDL_Log("AtomicLock lock=%d\n", lock);
SDL_Log("AtomicLock lock=%d", lock);
SDL_UnlockSpinlock(&lock);
SDL_Log("AtomicUnlock lock=%d\n", lock);
SDL_Log("AtomicUnlock lock=%d", lock);
SDL_Log("\natomic -----------------------------------------\n\n");
SDL_Log("%s", "");
SDL_Log("atomic -----------------------------------------");
SDL_Log("%s", "");
SDL_SetAtomicInt(&v, 0);
tfret = SDL_SetAtomicInt(&v, 10) == 0;
SDL_Log("AtomicSet(10) tfret=%s val=%d\n", tf(tfret), SDL_GetAtomicInt(&v));
SDL_Log("AtomicSet(10) tfret=%s val=%d", tf(tfret), SDL_GetAtomicInt(&v));
tfret = SDL_AddAtomicInt(&v, 10) == 10;
SDL_Log("AtomicAdd(10) tfret=%s val=%d\n", tf(tfret), SDL_GetAtomicInt(&v));
SDL_Log("AtomicAdd(10) tfret=%s val=%d", tf(tfret), SDL_GetAtomicInt(&v));
SDL_SetAtomicInt(&v, 0);
SDL_AtomicIncRef(&v);
tfret = (SDL_GetAtomicInt(&v) == 1);
SDL_Log("AtomicIncRef() tfret=%s val=%d\n", tf(tfret), SDL_GetAtomicInt(&v));
SDL_Log("AtomicIncRef() tfret=%s val=%d", tf(tfret), SDL_GetAtomicInt(&v));
SDL_AtomicIncRef(&v);
tfret = (SDL_GetAtomicInt(&v) == 2);
SDL_Log("AtomicIncRef() tfret=%s val=%d\n", tf(tfret), SDL_GetAtomicInt(&v));
SDL_Log("AtomicIncRef() tfret=%s val=%d", tf(tfret), SDL_GetAtomicInt(&v));
tfret = (SDL_AtomicDecRef(&v) == false);
SDL_Log("AtomicDecRef() tfret=%s val=%d\n", tf(tfret), SDL_GetAtomicInt(&v));
SDL_Log("AtomicDecRef() tfret=%s val=%d", tf(tfret), SDL_GetAtomicInt(&v));
tfret = (SDL_AtomicDecRef(&v) == true);
SDL_Log("AtomicDecRef() tfret=%s val=%d\n", tf(tfret), SDL_GetAtomicInt(&v));
SDL_Log("AtomicDecRef() tfret=%s val=%d", tf(tfret), SDL_GetAtomicInt(&v));
SDL_SetAtomicInt(&v, 10);
tfret = (SDL_CompareAndSwapAtomicInt(&v, 0, 20) == false);
SDL_Log("AtomicCAS() tfret=%s val=%d\n", tf(tfret), SDL_GetAtomicInt(&v));
SDL_Log("AtomicCAS() tfret=%s val=%d", tf(tfret), SDL_GetAtomicInt(&v));
value = SDL_GetAtomicInt(&v);
tfret = (SDL_CompareAndSwapAtomicInt(&v, value, 20) == true);
SDL_Log("AtomicCAS() tfret=%s val=%d\n", tf(tfret), SDL_GetAtomicInt(&v));
SDL_Log("AtomicCAS() tfret=%s val=%d", tf(tfret), SDL_GetAtomicInt(&v));
}
/**************************************************************************/
@@ -115,7 +119,7 @@ static SDL_Semaphore *threadDone;
static int SDLCALL adder(void *junk)
{
unsigned long N = NInter;
SDL_Log("Thread subtracting %d %lu times\n", CountInc, N);
SDL_Log("Thread subtracting %d %lu times", CountInc, N);
while (N--) {
SDL_AddAtomicInt(&good, -CountInc);
bad -= CountInc;
@@ -153,7 +157,7 @@ static void runAdder(void)
end = SDL_GetTicksNS();
SDL_Log("Finished in %f sec\n", (end - start) / 1000000000.0);
SDL_Log("Finished in %f sec", (end - start) / 1000000000.0);
}
static void RunEpicTest(void)
@@ -161,28 +165,30 @@ static void RunEpicTest(void)
int b;
atomicValue v;
SDL_Log("\nepic test---------------------------------------\n\n");
SDL_Log("%s", "");
SDL_Log("epic test---------------------------------------");
SDL_Log("%s", "");
SDL_Log("Size asserted to be >= 32-bit\n");
SDL_Log("Size asserted to be >= 32-bit");
SDL_assert(sizeof(atomicValue) >= 4);
SDL_Log("Check static initializer\n");
SDL_Log("Check static initializer");
v = SDL_GetAtomicInt(&good);
SDL_assert(v == 42);
SDL_assert(bad == 42);
SDL_Log("Test negative values\n");
SDL_Log("Test negative values");
SDL_SetAtomicInt(&good, -5);
v = SDL_GetAtomicInt(&good);
SDL_assert(v == -5);
SDL_Log("Verify maximum value\n");
SDL_Log("Verify maximum value");
SDL_SetAtomicInt(&good, CountTo);
v = SDL_GetAtomicInt(&good);
SDL_assert(v == CountTo);
SDL_Log("Test compare and exchange\n");
SDL_Log("Test compare and exchange");
b = SDL_CompareAndSwapAtomicInt(&good, 500, 43);
SDL_assert(!b); /* no swap since CountTo!=500 */
@@ -194,7 +200,7 @@ static void RunEpicTest(void)
v = SDL_GetAtomicInt(&good);
SDL_assert(v == 44);
SDL_Log("Test Add\n");
SDL_Log("Test Add");
v = SDL_AddAtomicInt(&good, 1);
SDL_assert(v == 44);
@@ -206,7 +212,7 @@ static void RunEpicTest(void)
v = SDL_GetAtomicInt(&good);
SDL_assert(v == 55);
SDL_Log("Test Add (Negative values)\n");
SDL_Log("Test Add (Negative values)");
v = SDL_AddAtomicInt(&good, -20);
SDL_assert(v == 55);
@@ -223,7 +229,7 @@ static void RunEpicTest(void)
v = SDL_GetAtomicInt(&good);
SDL_assert(v == 15);
SDL_Log("Reset before count down test\n");
SDL_Log("Reset before count down test");
SDL_SetAtomicInt(&good, CountTo);
v = SDL_GetAtomicInt(&good);
SDL_assert(v == CountTo);
@@ -231,11 +237,11 @@ static void RunEpicTest(void)
bad = CountTo;
SDL_assert(bad == CountTo);
SDL_Log("Counting down from %d, Expect %d remaining\n", CountTo, Expect);
SDL_Log("Counting down from %d, Expect %d remaining", CountTo, Expect);
runAdder();
v = SDL_GetAtomicInt(&good);
SDL_Log("Atomic %d Non-Atomic %d\n", v, bad);
SDL_Log("Atomic %d Non-Atomic %d", v, bad);
SDL_assert(v == Expect);
/* We can't guarantee that bad != Expect, this would happen on a single core system, for example. */
/*SDL_assert(bad != Expect);*/
@@ -431,7 +437,7 @@ static bool EnqueueEvent_Mutex(SDL_EventQueue *queue, const SDL_Event *event)
} else if (delta < 0) {
/* We ran into an old queue entry, which means it still needs to be dequeued */
} else {
SDL_Log("ERROR: mutex failed!\n");
SDL_Log("ERROR: mutex failed!");
}
SDL_UnlockMutex(queue->mutex);
@@ -464,7 +470,7 @@ static bool DequeueEvent_Mutex(SDL_EventQueue *queue, SDL_Event *event)
} else if (delta < 0) {
/* We ran into an old queue entry, which means we've hit empty */
} else {
SDL_Log("ERROR: mutex failed!\n");
SDL_Log("ERROR: mutex failed!");
}
SDL_UnlockMutex(queue->mutex);
@@ -597,8 +603,10 @@ static void RunFIFOTest(bool lock_free)
char textBuffer[1024];
size_t len;
SDL_Log("\nFIFO test---------------------------------------\n\n");
SDL_Log("Mode: %s\n", lock_free ? "LockFree" : "Mutex");
SDL_Log("%s", "");
SDL_Log("FIFO test---------------------------------------");
SDL_Log("%s", "");
SDL_Log("Mode: %s", lock_free ? "LockFree" : "Mutex");
SDL_memset(&queue, 0xff, sizeof(queue));
@@ -617,7 +625,7 @@ static void RunFIFOTest(bool lock_free)
#endif
/* Start the readers first */
SDL_Log("Starting %d readers\n", NUM_READERS);
SDL_Log("Starting %d readers", NUM_READERS);
SDL_zeroa(readerData);
for (i = 0; i < NUM_READERS; ++i) {
char name[64];
@@ -628,7 +636,7 @@ static void RunFIFOTest(bool lock_free)
}
/* Start up the writers */
SDL_Log("Starting %d writers\n", NUM_WRITERS);
SDL_Log("Starting %d writers", NUM_WRITERS);
SDL_zeroa(writerData);
for (i = 0; i < NUM_WRITERS; ++i) {
char name[64];
@@ -663,16 +671,16 @@ static void RunFIFOTest(bool lock_free)
SDL_DestroyMutex(queue.mutex);
}
SDL_Log("Finished in %f sec\n", (end - start) / 1000000000.0);
SDL_Log("Finished in %f sec", (end - start) / 1000000000.0);
SDL_Log("\n");
SDL_Log("%s", "");
for (i = 0; i < NUM_WRITERS; ++i) {
SDL_Log("Writer %d wrote %d events, had %d waits\n", i, EVENTS_PER_WRITER, writerData[i].waits);
SDL_Log("Writer %d wrote %d events, had %d waits", i, EVENTS_PER_WRITER, writerData[i].waits);
}
SDL_Log("Writers wrote %d total events\n", NUM_WRITERS * EVENTS_PER_WRITER);
SDL_Log("Writers wrote %d total events", NUM_WRITERS * EVENTS_PER_WRITER);
/* Print a breakdown of which readers read messages from which writer */
SDL_Log("\n");
SDL_Log("%s", "");
grand_total = 0;
for (i = 0; i < NUM_READERS; ++i) {
int total = 0;
@@ -680,7 +688,7 @@ static void RunFIFOTest(bool lock_free)
total += readerData[i].counters[j];
}
grand_total += total;
SDL_Log("Reader %d read %d events, had %d waits\n", i, total, readerData[i].waits);
SDL_Log("Reader %d read %d events, had %d waits", i, total, readerData[i].waits);
(void)SDL_snprintf(textBuffer, sizeof(textBuffer), " { ");
for (j = 0; j < NUM_WRITERS; ++j) {
if (j > 0) {
@@ -694,7 +702,7 @@ static void RunFIFOTest(bool lock_free)
(void)SDL_snprintf(textBuffer + len, sizeof(textBuffer) - len, " }\n");
SDL_Log("%s", textBuffer);
}
SDL_Log("Readers read %d total events\n", grand_total);
SDL_Log("Readers read %d total events", grand_total);
}
/* End FIFO test */

View File

@@ -84,7 +84,7 @@ static void iteration(void)
if (!stream) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to create/bind an audio stream to %u ('%s'): %s", (unsigned int) which, name, SDL_GetError());
} else {
SDL_Log("Opened '%s' as %u\n", name, (unsigned int) which);
SDL_Log("Opened '%s' as %u", name, (unsigned int) which);
/* !!! 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);
@@ -94,7 +94,7 @@ static void iteration(void)
}
} else if (e.type == SDL_EVENT_AUDIO_DEVICE_REMOVED) {
dev = (SDL_AudioDeviceID)e.adevice.which;
SDL_Log("%s device %u removed.\n", devtypestr(e.adevice.recording), (unsigned int)dev);
SDL_Log("%s device %u removed.", devtypestr(e.adevice.recording), (unsigned int)dev);
/* !!! FIXME: we need to keep track of our streams and destroy them here. */
}
}
@@ -144,14 +144,14 @@ int main(int argc, char *argv[])
/* Load the SDL library */
if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s", SDL_GetError());
return 1;
}
/* Some targets (Mac CoreAudio) need an event queue for audio hotplug, so make and immediately hide a window. */
window = SDL_CreateWindow("testaudiohotplug", 640, 480, 0);
if (!window) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_CreateWindow failed: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_CreateWindow failed: %s", SDL_GetError());
quit(1);
}
SDL_MinimizeWindow(window);
@@ -159,13 +159,13 @@ int main(int argc, char *argv[])
filename = GetResourceFilename(filename, "sample.wav");
if (!filename) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s", SDL_GetError());
quit(1);
}
/* Load the wave file into memory */
if (!SDL_LoadWAV(filename, &spec, &sound, &soundlen)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", filename, SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", filename, SDL_GetError());
quit(1);
}
@@ -187,8 +187,8 @@ int main(int argc, char *argv[])
SDL_Log("%i: %s", i, SDL_GetAudioDriver(i));
}
SDL_Log("Select a driver with the SDL_AUDIO_DRIVER environment variable.\n");
SDL_Log("Using audio driver: %s\n", SDL_GetCurrentAudioDriver());
SDL_Log("Select a driver with the SDL_AUDIO_DRIVER environment variable.");
SDL_Log("Using audio driver: %s", SDL_GetCurrentAudioDriver());
#ifdef SDL_PLATFORM_EMSCRIPTEN
emscripten_set_main_loop(loop, 0, 1);

View File

@@ -23,28 +23,30 @@ print_devices(bool recording)
SDL_AudioDeviceID *devices = recording ? SDL_GetAudioRecordingDevices(&n) : SDL_GetAudioPlaybackDevices(&n);
if (!devices) {
SDL_Log(" Driver failed to report %s devices: %s\n\n", typestr, SDL_GetError());
SDL_Log(" Driver failed to report %s devices: %s", typestr, SDL_GetError());
SDL_Log("%s", "");
} else if (n == 0) {
SDL_Log(" No %s devices found.\n\n", typestr);
SDL_Log(" No %s devices found.", typestr);
SDL_Log("%s", "");
} else {
int i;
SDL_Log("Found %d %s device%s:\n", n, typestr, n != 1 ? "s" : "");
SDL_Log("Found %d %s device%s:", n, typestr, n != 1 ? "s" : "");
for (i = 0; i < n; i++) {
const char *name = SDL_GetAudioDeviceName(devices[i]);
if (name) {
SDL_Log(" %d: %s\n", i, name);
SDL_Log(" %d: %s", i, name);
} else {
SDL_Log(" %d Error: %s\n", i, SDL_GetError());
SDL_Log(" %d Error: %s", i, SDL_GetError());
}
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);
SDL_Log(" Buffer Size: %d frames\n", frames);
SDL_Log(" Sample Rate: %d", spec.freq);
SDL_Log(" Channels: %d", spec.channels);
SDL_Log(" SDL_AudioFormat: %X", spec.format);
SDL_Log(" Buffer Size: %d frames", frames);
}
}
SDL_Log("\n");
SDL_Log("%s", "");
}
SDL_free(devices);
}
@@ -70,45 +72,47 @@ int main(int argc, char **argv)
/* Load the SDL library */
if (!SDL_Init(SDL_INIT_AUDIO)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s", SDL_GetError());
return 1;
}
/* Print available audio drivers */
n = SDL_GetNumAudioDrivers();
if (n == 0) {
SDL_Log("No built-in audio drivers\n\n");
SDL_Log("No built-in audio drivers");
SDL_Log("%s", "");
} else {
SDL_Log("Built-in audio drivers:\n");
SDL_Log("Built-in audio drivers:");
for (i = 0; i < n; ++i) {
SDL_Log(" %d: %s\n", i, SDL_GetAudioDriver(i));
SDL_Log(" %d: %s", i, SDL_GetAudioDriver(i));
}
SDL_Log("Select a driver with the SDL_AUDIO_DRIVER environment variable.\n");
SDL_Log("Select a driver with the SDL_AUDIO_DRIVER environment variable.");
}
SDL_Log("Using audio driver: %s\n\n", SDL_GetCurrentAudioDriver());
SDL_Log("Using audio driver: %s", SDL_GetCurrentAudioDriver());
SDL_Log("%s", "");
print_devices(false);
print_devices(true);
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);
SDL_Log("Default Playback Device:");
SDL_Log("Sample Rate: %d", spec.freq);
SDL_Log("Channels: %d", spec.channels);
SDL_Log("SDL_AudioFormat: %X", spec.format);
SDL_Log("Buffer Size: %d frames", frames);
} else {
SDL_Log("Error when calling SDL_GetAudioDeviceFormat(default playback): %s\n", SDL_GetError());
SDL_Log("Error when calling SDL_GetAudioDeviceFormat(default playback): %s", SDL_GetError());
}
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);
SDL_Log("Default Recording Device:");
SDL_Log("Sample Rate: %d", spec.freq);
SDL_Log("Channels: %d", spec.channels);
SDL_Log("SDL_AudioFormat: %X", spec.format);
SDL_Log("Buffer Size: %d frames", frames);
} else {
SDL_Log("Error when calling SDL_GetAudioDeviceFormat(default recording): %s\n", SDL_GetError());
SDL_Log("Error when calling SDL_GetAudioDeviceFormat(default recording): %s", SDL_GetError());
}
SDL_Quit();

View File

@@ -62,31 +62,31 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char **argv)
/* Load the SDL library */
if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s", SDL_GetError());
return SDL_APP_SUCCESS;
}
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());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create SDL window and renderer: %s", SDL_GetError());
return SDL_APP_SUCCESS;
}
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
SDL_RenderClear(renderer);
SDL_RenderPresent(renderer);
SDL_Log("Using audio driver: %s\n", SDL_GetCurrentAudioDriver());
SDL_Log("Using audio driver: %s", SDL_GetCurrentAudioDriver());
devices = SDL_GetAudioRecordingDevices(NULL);
for (i = 0; devices[i] != 0; i++) {
const char *name = SDL_GetAudioDeviceName(devices[i]);
SDL_Log(" Recording device #%d: '%s'\n", i, name);
SDL_Log(" Recording device #%d: '%s'", i, name);
if (devname && (SDL_strcmp(devname, name) == 0)) {
want_device = devices[i];
}
}
if (devname && (want_device == SDL_AUDIO_DEVICE_DEFAULT_RECORDING)) {
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "Didn't see a recording device named '%s', using the system default instead.\n", devname);
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "Didn't see a recording device named '%s', using the system default instead.", devname);
devname = NULL;
}
@@ -96,10 +96,10 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char **argv)
open your recording devices second in case you land in those bizarre
circumstances. */
SDL_Log("Opening default playback device...\n");
SDL_Log("Opening default playback device...");
device = SDL_OpenAudioDevice(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, NULL);
if (!device) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't open an audio device for playback: %s!\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't open an audio device for playback: %s!", SDL_GetError());
SDL_free(devices);
return SDL_APP_FAILURE;
}
@@ -107,23 +107,23 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char **argv)
SDL_GetAudioDeviceFormat(device, &outspec, NULL);
stream_out = SDL_CreateAudioStream(&outspec, &outspec);
if (!stream_out) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create an audio stream for playback: %s!\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create an audio stream for playback: %s!", SDL_GetError());
SDL_free(devices);
return SDL_APP_FAILURE;
} 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_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't bind an audio stream for playback: %s!", SDL_GetError());
SDL_free(devices);
return SDL_APP_FAILURE;
}
SDL_Log("Opening recording device %s%s%s...\n",
SDL_Log("Opening recording device %s%s%s...",
devname ? "'" : "",
devname ? devname : "[[default]]",
devname ? "'" : "");
device = SDL_OpenAudioDevice(want_device, NULL);
if (!device) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't open an audio device for recording: %s!\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't open an audio device for recording: %s!", SDL_GetError());
SDL_free(devices);
return SDL_APP_FAILURE;
}
@@ -132,16 +132,16 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char **argv)
SDL_GetAudioDeviceFormat(device, &inspec, NULL);
stream_in = SDL_CreateAudioStream(&inspec, &inspec);
if (!stream_in) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create an audio stream for recording: %s!\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create an audio stream for recording: %s!", SDL_GetError());
return SDL_APP_FAILURE;
} 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());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't bind an audio stream for recording: %s!", SDL_GetError());
return SDL_APP_FAILURE;
}
SDL_SetAudioStreamFormat(stream_in, NULL, &outspec); /* make sure we output at the playback format. */
SDL_Log("Ready! Hold down mouse or finger to record!\n");
SDL_Log("Ready! Hold down mouse or finger to record!");
return SDL_APP_CONTINUE;
}
@@ -185,10 +185,10 @@ SDL_AppResult SDL_AppIterate(void *appstate)
Uint8 buf[1024];
const int br = SDL_GetAudioStreamData(stream_in, buf, sizeof(buf));
if (br < 0) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to read from input audio stream: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to read from input audio stream: %s", SDL_GetError());
return SDL_APP_FAILURE;
} 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());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to write to output audio stream: %s", SDL_GetError());
return SDL_APP_FAILURE;
}
}
@@ -198,7 +198,7 @@ SDL_AppResult SDL_AppIterate(void *appstate)
void SDL_AppQuit(void *appstate, SDL_AppResult result)
{
SDL_Log("Shutting down.\n");
SDL_Log("Shutting down.");
const SDL_AudioDeviceID devid_in = SDL_GetAudioStreamDevice(stream_in);
const SDL_AudioDeviceID devid_out = SDL_GetAudioStreamDevice(stream_out);
SDL_CloseAudioDevice(devid_in); /* !!! FIXME: use SDL_OpenAudioDeviceStream instead so we can dump this. */

View File

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

View File

@@ -36,10 +36,10 @@ static void PrintCameraSpecs(SDL_CameraID camera_id)
if (specs) {
int i;
SDL_Log("Available formats:\n");
SDL_Log("Available formats:");
for (i = 0; specs[i]; ++i) {
const SDL_CameraSpec *s = specs[i];
SDL_Log(" %dx%d %.2f FPS %s\n", s->width, s->height, (float)s->framerate_numerator / s->framerate_denominator, SDL_GetPixelFormatName(s->format));
SDL_Log(" %dx%d %.2f FPS %s", s->width, s->height, (float)s->framerate_numerator / s->framerate_denominator, SDL_GetPixelFormatName(s->format));
}
SDL_free(specs);
}

View File

@@ -41,12 +41,12 @@ static const void *ClipboardDataCallback(void *userdata, const char *mime_type,
SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
{
if (!SDL_Init(SDL_INIT_VIDEO)) {
SDL_Log("Couldn't initialize SDL: %s\n", SDL_GetError());
SDL_Log("Couldn't initialize SDL: %s", SDL_GetError());
return SDL_APP_FAILURE;
}
if (!SDL_CreateWindowAndRenderer("testclipboard", 640, 480, 0, &window, &renderer)) {
SDL_Log("Couldn't create window and renderer: %s\n", SDL_GetError());
SDL_Log("Couldn't create window and renderer: %s", SDL_GetError());
return SDL_APP_FAILURE;
}
return SDL_APP_CONTINUE;
@@ -69,12 +69,12 @@ SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event)
case SDL_EVENT_CLIPBOARD_UPDATE:
if (event->clipboard.num_mime_types > 0) {
int i;
SDL_Log("Clipboard updated:\n");
SDL_Log("Clipboard updated:");
for (i = 0; event->clipboard.mime_types[i]; ++i) {
SDL_Log(" %s\n", event->clipboard.mime_types[i]);
SDL_Log(" %s", event->clipboard.mime_types[i]);
}
} else {
SDL_Log("Clipboard cleared\n");
SDL_Log("Clipboard cleared");
}
break;

View File

@@ -64,12 +64,12 @@ static void UpdateHDRState(void)
props = SDL_GetWindowProperties(window);
HDR_enabled = SDL_GetBooleanProperty(props, SDL_PROP_WINDOW_HDR_ENABLED_BOOLEAN, false);
SDL_Log("HDR %s\n", HDR_enabled ? "enabled" : "disabled");
SDL_Log("HDR %s", HDR_enabled ? "enabled" : "disabled");
if (HDR_enabled) {
props = SDL_GetRendererProperties(renderer);
if (SDL_GetNumberProperty(props, SDL_PROP_RENDERER_OUTPUT_COLORSPACE_NUMBER, SDL_COLORSPACE_SRGB) != SDL_COLORSPACE_SRGB_LINEAR) {
SDL_Log("Run with --colorspace linear to display HDR colors\n");
SDL_Log("Run with --colorspace linear to display HDR colors");
}
HDR_headroom = SDL_GetFloatProperty(props, SDL_PROP_RENDERER_HDR_HEADROOM_FLOAT, 1.0f);
}
@@ -86,12 +86,12 @@ static void CreateRenderer(void)
renderer = SDL_CreateRendererWithProperties(props);
SDL_DestroyProperties(props);
if (!renderer) {
SDL_Log("Couldn't create renderer: %s\n", SDL_GetError());
SDL_Log("Couldn't create renderer: %s", SDL_GetError());
return;
}
renderer_name = SDL_GetRendererName(renderer);
SDL_Log("Created renderer %s\n", renderer_name);
SDL_Log("Created renderer %s", renderer_name);
UpdateHDRState();
}
@@ -159,11 +159,11 @@ static bool ReadPixel(int x, int y, SDL_Color *c)
if (SDL_ReadSurfacePixel(surface, 0, 0, &c->r, &c->g, &c->b, &c->a)) {
result = true;
} else {
SDL_Log("Couldn't read pixel: %s\n", SDL_GetError());
SDL_Log("Couldn't read pixel: %s", SDL_GetError());
}
SDL_DestroySurface(surface);
} else {
SDL_Log("Couldn't read back pixels: %s\n", SDL_GetError());
SDL_Log("Couldn't read back pixels: %s", SDL_GetError());
}
return result;
}
@@ -662,7 +662,7 @@ static void loop(void)
static void LogUsage(const char *argv0)
{
SDL_Log("Usage: %s [--renderer renderer] [--colorspace colorspace]\n", argv0);
SDL_Log("Usage: %s [--renderer renderer] [--colorspace colorspace]", argv0);
}
int main(int argc, char *argv[])
@@ -691,7 +691,7 @@ int main(int argc, char *argv[])
colorspace = SDL_COLORSPACE_HDR10;
*/
} else {
SDL_Log("Unknown colorspace %s\n", argv[i + 1]);
SDL_Log("Unknown colorspace %s", argv[i + 1]);
goto quit;
}
++i;
@@ -707,20 +707,20 @@ int main(int argc, char *argv[])
window = SDL_CreateWindow("SDL colorspace test", WINDOW_WIDTH, WINDOW_HEIGHT, 0);
if (!window) {
SDL_Log("Couldn't create window: %s\n", SDL_GetError());
SDL_Log("Couldn't create window: %s", SDL_GetError());
return_code = 2;
goto quit;
}
renderer_count = SDL_GetNumRenderDrivers();
SDL_Log("There are %d render drivers:\n", renderer_count);
SDL_Log("There are %d render drivers:", renderer_count);
for (i = 0; i < renderer_count; ++i) {
const char *name = SDL_GetRenderDriver(i);
if (renderer_name && SDL_strcasecmp(renderer_name, name) == 0) {
renderer_index = i;
}
SDL_Log(" %s\n", name);
SDL_Log(" %s", name);
}
CreateRenderer();

View File

@@ -923,9 +923,9 @@ static void AddController(SDL_JoystickID id, bool verbose)
const char *name = SDL_GetJoystickName(joystick);
const char *path = SDL_GetJoystickPath(joystick);
char guid[33];
SDL_Log("Opened joystick %s%s%s\n", name, path ? ", " : "", path ? path : "");
SDL_Log("Opened joystick %s%s%s", name, path ? ", " : "", path ? path : "");
SDL_GUIDToString(SDL_GetJoystickGUID(joystick), guid, sizeof(guid));
SDL_Log("No gamepad mapping for %s\n", guid);
SDL_Log("No gamepad mapping for %s", guid);
}
} else {
SDL_Log("Couldn't open joystick: %s", SDL_GetError());
@@ -1021,7 +1021,7 @@ static void HandleGamepadAdded(SDL_JoystickID id, bool verbose)
if (i < 0) {
return;
}
SDL_Log("Gamepad %" SDL_PRIu32 " added\n", id);
SDL_Log("Gamepad %" SDL_PRIu32 " added", id);
SDL_assert(!controllers[i].gamepad);
controllers[i].gamepad = SDL_OpenGamepad(id);
@@ -1035,11 +1035,11 @@ static void HandleGamepadAdded(SDL_JoystickID id, bool verbose)
SDL_GUID guid = SDL_GetGamepadGUIDForID(id);
char guid_string[33];
SDL_GUIDToString(guid, guid_string, sizeof(guid_string));
SDL_Log("Opened gamepad %s, guid %s%s%s\n", name, guid_string, path ? ", " : "", path ? path : "");
SDL_Log("Opened gamepad %s, guid %s%s%s", name, guid_string, path ? ", " : "", path ? path : "");
firmware_version = SDL_GetGamepadFirmwareVersion(gamepad);
if (firmware_version) {
SDL_Log("Firmware version: 0x%x (%d)\n", firmware_version, firmware_version);
SDL_Log("Firmware version: 0x%x (%d)", firmware_version, firmware_version);
}
if (SDL_GetBooleanProperty(props, SDL_PROP_GAMEPAD_CAP_PLAYER_LED_BOOLEAN, false)) {
@@ -1055,7 +1055,7 @@ static void HandleGamepadAdded(SDL_JoystickID id, bool verbose)
}
if (SDL_GetGamepadPlayerIndex(gamepad) >= 0) {
SDL_Log("Player index: %d\n", SDL_GetGamepadPlayerIndex(gamepad));
SDL_Log("Player index: %d", SDL_GetGamepadPlayerIndex(gamepad));
}
}
@@ -1064,7 +1064,7 @@ static void HandleGamepadAdded(SDL_JoystickID id, bool verbose)
if (SDL_GamepadHasSensor(gamepad, sensor)) {
if (verbose) {
SDL_Log("Enabling %s at %.2f Hz\n", GetSensorName(sensor), SDL_GetGamepadSensorDataRate(gamepad, sensor));
SDL_Log("Enabling %s at %.2f Hz", GetSensorName(sensor), SDL_GetGamepadSensorDataRate(gamepad, sensor));
}
SDL_SetGamepadSensorEnabled(gamepad, sensor, true);
}
@@ -1073,7 +1073,7 @@ static void HandleGamepadAdded(SDL_JoystickID id, bool verbose)
if (verbose) {
char *mapping = SDL_GetGamepadMapping(gamepad);
if (mapping) {
SDL_Log("Mapping: %s\n", mapping);
SDL_Log("Mapping: %s", mapping);
SDL_free(mapping);
}
}
@@ -1093,7 +1093,7 @@ static void HandleGamepadRemoved(SDL_JoystickID id)
if (i < 0) {
return;
}
SDL_Log("Gamepad %" SDL_PRIu32 " removed\n", id);
SDL_Log("Gamepad %" SDL_PRIu32 " removed", id);
if (controllers[i].mapping) {
SDL_free(controllers[i].mapping);
@@ -1137,24 +1137,24 @@ static bool ShowingFront(void)
static void SDLCALL VirtualGamepadSetPlayerIndex(void *userdata, int player_index)
{
SDL_Log("Virtual Gamepad: player index set to %d\n", player_index);
SDL_Log("Virtual Gamepad: player index set to %d", player_index);
}
static 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);
SDL_Log("Virtual Gamepad: rumble set to %d/%d", low_frequency_rumble, high_frequency_rumble);
return true;
}
static 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);
SDL_Log("Virtual Gamepad: trigger rumble set to %d/%d", left_rumble, right_rumble);
return true;
}
static 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);
SDL_Log("Virtual Gamepad: LED set to RGB %d,%d,%d", red, green, blue);
return true;
}
@@ -1184,11 +1184,11 @@ static void OpenVirtualGamepad(void)
virtual_id = SDL_AttachVirtualJoystick(&desc);
if (virtual_id == 0) {
SDL_Log("Couldn't attach virtual device: %s\n", SDL_GetError());
SDL_Log("Couldn't attach virtual device: %s", SDL_GetError());
} else {
virtual_joystick = SDL_OpenJoystick(virtual_id);
if (!virtual_joystick) {
SDL_Log("Couldn't open virtual device: %s\n", SDL_GetError());
SDL_Log("Couldn't open virtual device: %s", SDL_GetError());
}
}
}
@@ -1620,7 +1620,7 @@ SDL_AppResult SDLCALL SDL_AppEvent(void *appstate, SDL_Event *event)
}
#ifdef DEBUG_AXIS_MAPPING
SDL_Log("AXIS %d nValue %d nCurrentDistance %d nFarthestDistance %d\n", event->jaxis.axis, nValue, nCurrentDistance, nFarthestDistance);
SDL_Log("AXIS %d nValue %d nCurrentDistance %d nFarthestDistance %d", event->jaxis.axis, nValue, nCurrentDistance, nFarthestDistance);
#endif
/* If we've gone out far enough and started to come back, let's bind this axis */
if (nFarthestDistance >= 16000 && nCurrentDistance <= 10000) {
@@ -1642,7 +1642,7 @@ SDL_AppResult SDLCALL SDL_AppEvent(void *appstate, SDL_Event *event)
}
}
#ifdef DEBUG_AXIS_MAPPING
SDL_Log("AXIS %d axis_min = %d, axis_max = %d, binding = %s\n", event->jaxis.axis, axis_min, axis_max, binding);
SDL_Log("AXIS %d axis_min = %d, axis_max = %d, binding = %s", event->jaxis.axis, axis_min, axis_max, binding);
#endif
CommitBindingElement(binding, false);
}
@@ -1698,7 +1698,7 @@ SDL_AppResult SDLCALL SDL_AppEvent(void *appstate, SDL_Event *event)
case SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN:
case SDL_EVENT_GAMEPAD_TOUCHPAD_MOTION:
case SDL_EVENT_GAMEPAD_TOUCHPAD_UP:
SDL_Log("Gamepad %" SDL_PRIu32 " touchpad %" SDL_PRIs32 " finger %" SDL_PRIs32 " %s %.2f, %.2f, %.2f\n",
SDL_Log("Gamepad %" SDL_PRIu32 " touchpad %" SDL_PRIs32 " finger %" SDL_PRIs32 " %s %.2f, %.2f, %.2f",
event->gtouchpad.which,
event->gtouchpad.touchpad,
event->gtouchpad.finger,
@@ -1711,7 +1711,7 @@ SDL_AppResult SDLCALL SDL_AppEvent(void *appstate, SDL_Event *event)
#ifdef VERBOSE_SENSORS
case SDL_EVENT_GAMEPAD_SENSOR_UPDATE:
SDL_Log("Gamepad %" SDL_PRIu32 " sensor %s: %.2f, %.2f, %.2f (%" SDL_PRIu64 ")\n",
SDL_Log("Gamepad %" SDL_PRIu32 " sensor %s: %.2f, %.2f, %.2f (%" SDL_PRIu64 ")",
event->gsensor.which,
GetSensorName((SDL_SensorType) event->gsensor.sensor),
event->gsensor.data[0],
@@ -1728,7 +1728,7 @@ SDL_AppResult SDLCALL SDL_AppEvent(void *appstate, SDL_Event *event)
SetController(event->gaxis.which);
}
}
SDL_Log("Gamepad %" SDL_PRIu32 " axis %s changed to %d\n",
SDL_Log("Gamepad %" SDL_PRIu32 " axis %s changed to %d",
event->gaxis.which,
SDL_GetGamepadStringForAxis((SDL_GamepadAxis) event->gaxis.axis),
event->gaxis.value);
@@ -1743,7 +1743,7 @@ SDL_AppResult SDLCALL SDL_AppEvent(void *appstate, SDL_Event *event)
}
}
#ifdef VERBOSE_BUTTONS
SDL_Log("Gamepad %" SDL_PRIu32 " button %s %s\n",
SDL_Log("Gamepad %" SDL_PRIu32 " button %s %s",
event->gbutton.which,
SDL_GetGamepadStringForButton((SDL_GamepadButton) event->gbutton.button),
event->gbutton.state ? "pressed" : "released");
@@ -1784,8 +1784,8 @@ SDL_AppResult SDLCALL SDL_AppEvent(void *appstate, SDL_Event *event)
} else if (display_mode == CONTROLLER_MODE_BINDING) {
if (GamepadButtonContains(done_mapping_button, event->button.x, event->button.y)) {
if (controller->mapping) {
SDL_Log("Mapping complete:\n");
SDL_Log("%s\n", controller->mapping);
SDL_Log("Mapping complete:");
SDL_Log("%s", controller->mapping);
}
SetDisplayMode(CONTROLLER_MODE_TESTING);
} else if (GamepadButtonContains(cancel_button, event->button.x, event->button.y)) {
@@ -2047,7 +2047,7 @@ SDL_AppResult SDLCALL SDL_AppInit(void **appstate, 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)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s", SDL_GetError());
return SDL_APP_FAILURE;
}
@@ -2057,11 +2057,11 @@ SDL_AppResult SDLCALL SDL_AppInit(void **appstate, int argc, char *argv[])
int count = 0;
char **mappings = SDL_GetGamepadMappings(&count);
int map_i;
SDL_Log("Supported mappings:\n");
SDL_Log("Supported mappings:");
for (map_i = 0; map_i < count; ++map_i) {
SDL_Log("\t%s\n", mappings[map_i]);
SDL_Log("\t%s", mappings[map_i]);
}
SDL_Log("\n");
SDL_Log("%s", "");
SDL_free(mappings);
}
@@ -2074,13 +2074,13 @@ SDL_AppResult SDLCALL SDL_AppInit(void **appstate, int argc, char *argv[])
screen_height = (int)SDL_ceilf(SCREEN_HEIGHT * content_scale);
window = SDL_CreateWindow("SDL Controller Test", screen_width, screen_height, 0);
if (!window) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window: %s", SDL_GetError());
return SDL_APP_FAILURE;
}
screen = SDL_CreateRenderer(window, NULL);
if (!screen) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s", SDL_GetError());
SDL_DestroyWindow(window);
return SDL_APP_FAILURE;
}

View File

@@ -33,14 +33,14 @@ static void SDLCALL callback(void* userdata, const char* const* files, int filte
}
}
SDL_Log("Filter used: '%s'\n", filter_name);
SDL_Log("Filter used: '%s'", filter_name);
while (*files) {
SDL_Log("'%s'\n", *files);
SDL_Log("'%s'", *files);
files++;
}
} else {
SDL_Log("Error: %s\n", SDL_GetError());
SDL_Log("Error: %s", SDL_GetError());
}
}
@@ -82,7 +82,7 @@ int main(int argc, char *argv[])
return 1;
}
if (!SDL_CreateWindowAndRenderer("testdialog", 640, 480, 0, &w, &r)) {
SDL_Log("Failed to create window and/or renderer: %s\n", SDL_GetError());
SDL_Log("Failed to create window and/or renderer: %s", SDL_GetError());
SDL_Quit();
return 1;
}
@@ -90,7 +90,7 @@ int main(int argc, char *argv[])
initial_path = SDL_GetUserFolder(SDL_FOLDER_HOME);
if (!initial_path) {
SDL_Log("Will not use an initial path, couldn't get the home directory path: %s\n", SDL_GetError());
SDL_Log("Will not use an initial path, couldn't get the home directory path: %s", SDL_GetError());
}
while (1) {

View File

@@ -25,7 +25,7 @@ print_mode(const char *prefix, const SDL_DisplayMode *mode)
return;
}
SDL_Log("%s: %dx%d@%gx, %gHz, fmt=%s\n",
SDL_Log("%s: %dx%d@%gx, %gHz, fmt=%s",
prefix,
mode->w, mode->h, mode->pixel_density, mode->refresh_rate,
SDL_GetPixelFormatName(mode->format));
@@ -52,14 +52,14 @@ int main(int argc, char *argv[])
/* Load the SDL library */
if (!SDL_Init(SDL_INIT_VIDEO)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s", SDL_GetError());
return 1;
}
SDL_Log("Using video target '%s'.\n", SDL_GetCurrentVideoDriver());
SDL_Log("Using video target '%s'.", SDL_GetCurrentVideoDriver());
displays = SDL_GetDisplays(&num_displays);
SDL_Log("See %d displays.\n", num_displays);
SDL_Log("See %d displays.", num_displays);
for (i = 0; i < num_displays; i++) {
SDL_DisplayID dpy = displays[i];
@@ -70,20 +70,20 @@ int main(int argc, char *argv[])
SDL_GetDisplayBounds(dpy, &rect);
modes = SDL_GetFullscreenDisplayModes(dpy, &num_modes);
SDL_Log("%" SDL_PRIu32 ": \"%s\" (%dx%d at %d,%d), content scale %.2f, %d fullscreen modes, HDR capable: %s.\n", dpy, SDL_GetDisplayName(dpy), rect.w, rect.h, rect.x, rect.y, SDL_GetDisplayContentScale(dpy), num_modes, has_HDR ? "yes" : "no");
SDL_Log("%" SDL_PRIu32 ": \"%s\" (%dx%d at %d,%d), content scale %.2f, %d fullscreen modes, HDR capable: %s.", dpy, SDL_GetDisplayName(dpy), rect.w, rect.h, rect.x, rect.y, SDL_GetDisplayContentScale(dpy), num_modes, has_HDR ? "yes" : "no");
mode = SDL_GetCurrentDisplayMode(dpy);
if (mode) {
print_mode("CURRENT", mode);
} else {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, " CURRENT: failed to query (%s)\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, " CURRENT: failed to query (%s)", SDL_GetError());
}
mode = SDL_GetDesktopDisplayMode(dpy);
if (mode) {
print_mode("DESKTOP", mode);
} else {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, " DESKTOP: failed to query (%s)\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, " DESKTOP: failed to query (%s)", SDL_GetError());
}
for (m = 0; m < num_modes; m++) {
@@ -93,7 +93,7 @@ int main(int argc, char *argv[])
}
SDL_free(modes);
SDL_Log("\n");
SDL_Log("%s", "");
}
SDL_free(displays);

View File

@@ -208,7 +208,7 @@ static void loop(void)
/* Print out some timing information */
const Uint64 then = next_fps_check - fps_check_delay;
const double fps = ((double)frames * 1000) / (now - then);
SDL_Log("%2.2f frames per second\n", fps);
SDL_Log("%2.2f frames per second", fps);
next_fps_check = now + fps_check_delay;
frames = 0;
}

View File

@@ -132,14 +132,14 @@ int main(int argc, char *argv[])
/* Initialize SDL */
if (!SDL_Init(SDL_INIT_VIDEO)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init fail : %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init fail : %s", SDL_GetError());
return 1;
}
/* Create window and renderer for given surface */
window = SDL_CreateWindow("Chess Board", 640, 480, SDL_WINDOW_RESIZABLE);
if (!window) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Window creation fail : %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Window creation fail : %s", SDL_GetError());
return 1;
}
#ifdef USE_SOFTWARE_RENDERER
@@ -149,7 +149,7 @@ int main(int argc, char *argv[])
renderer = SDL_CreateRenderer(window, NULL);
#endif
if (!renderer) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Render creation for surface fail : %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Render creation for surface fail : %s", SDL_GetError());
return 1;
}

View File

@@ -38,10 +38,10 @@ ThreadFunc(void *data)
SDL_SetError("Thread %s (%" SDL_PRIu64 ") had a problem: %s",
(char *)data, SDL_GetCurrentThreadID(), "nevermind");
while (alive) {
SDL_Log("Thread '%s' is alive!\n", (char *)data);
SDL_Log("Thread '%s' is alive!", (char *)data);
SDL_Delay(1 * 1000);
}
SDL_Log("Child thread error string: %s\n", SDL_GetError());
SDL_Log("Child thread error string: %s", SDL_GetError());
return 0;
}
@@ -83,7 +83,7 @@ int main(int argc, char *argv[])
/* Load the SDL library */
if (!SDL_Init(0)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s", SDL_GetError());
return 1;
}
@@ -100,16 +100,16 @@ int main(int argc, char *argv[])
alive = 1;
thread = SDL_CreateThread(ThreadFunc, NULL, "#1");
if (!thread) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s", SDL_GetError());
quit(1);
}
SDL_Delay(5 * 1000);
SDL_Log("Waiting for thread #1\n");
SDL_Log("Waiting for thread #1");
alive = 0;
SDL_WaitThread(thread, NULL);
}
SDL_Log("Main thread error string: %s\n", SDL_GetError());
SDL_Log("Main thread error string: %s", SDL_GetError());
SDL_Quit();
SDLTest_CommonDestroyState(state);

View File

@@ -171,7 +171,7 @@ static bool CreateWindowAndRenderer(SDL_WindowFlags window_flags, const char *dr
return false;
}
SDL_Log("Created renderer %s\n", SDL_GetRendererName(renderer));
SDL_Log("Created renderer %s", SDL_GetRendererName(renderer));
#ifdef HAVE_EGL
if (useEGL) {
@@ -377,9 +377,9 @@ static enum AVPixelFormat GetSupportedPixelFormat(AVCodecContext *s, const enum
}
if (*p == AV_PIX_FMT_NONE) {
SDL_Log("Couldn't find a supported pixel format:\n");
SDL_Log("Couldn't find a supported pixel format:");
for (p = pix_fmts; *p != AV_PIX_FMT_NONE; p++) {
SDL_Log(" %s\n", av_get_pix_fmt_name(*p));
SDL_Log(" %s", av_get_pix_fmt_name(*p));
}
}
@@ -395,7 +395,7 @@ static AVCodecContext *OpenVideoStream(AVFormatContext *ic, int stream, const AV
int i;
int result;
SDL_Log("Video stream: %s %dx%d\n", avcodec_get_name(codec->id), codecpar->width, codecpar->height);
SDL_Log("Video stream: %s %dx%d", avcodec_get_name(codec->id), codecpar->width, codecpar->height);
context = avcodec_alloc_context3(NULL);
if (!context) {
@@ -405,7 +405,7 @@ static AVCodecContext *OpenVideoStream(AVFormatContext *ic, int stream, const AV
result = avcodec_parameters_to_context(context, ic->streams[stream]->codecpar);
if (result < 0) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "avcodec_parameters_to_context failed: %s\n", av_err2str(result));
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "avcodec_parameters_to_context failed: %s", av_err2str(result));
avcodec_free_context(&context);
return NULL;
}
@@ -416,7 +416,7 @@ static AVCodecContext *OpenVideoStream(AVFormatContext *ic, int stream, const AV
while (!context->hw_device_ctx &&
(config = avcodec_get_hw_config(codec, i++)) != NULL) {
#if 0
SDL_Log("Found %s hardware acceleration with pixel format %s\n", av_hwdevice_get_type_name(config->device_type), av_get_pix_fmt_name(config->pix_fmt));
SDL_Log("Found %s hardware acceleration with pixel format %s", av_hwdevice_get_type_name(config->device_type), av_get_pix_fmt_name(config->pix_fmt));
#endif
if (!(config->methods & AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX) ||
@@ -440,7 +440,7 @@ static AVCodecContext *OpenVideoStream(AVFormatContext *ic, int stream, const AV
if (result < 0) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create %s hardware device context: %s", av_hwdevice_get_type_name(config->device_type), av_err2str(result));
} else {
SDL_Log("Using %s hardware acceleration with pixel format %s\n", av_hwdevice_get_type_name(config->device_type), av_get_pix_fmt_name(config->pix_fmt));
SDL_Log("Using %s hardware acceleration with pixel format %s", av_hwdevice_get_type_name(config->device_type), av_get_pix_fmt_name(config->pix_fmt));
}
} else
#endif
@@ -456,14 +456,14 @@ static AVCodecContext *OpenVideoStream(AVFormatContext *ic, int stream, const AV
if (result < 0) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create %s hardware device context: %s", av_hwdevice_get_type_name(config->device_type), av_err2str(result));
} else {
SDL_Log("Using %s hardware acceleration with pixel format %s\n", av_hwdevice_get_type_name(config->device_type), av_get_pix_fmt_name(config->pix_fmt));
SDL_Log("Using %s hardware acceleration with pixel format %s", av_hwdevice_get_type_name(config->device_type), av_get_pix_fmt_name(config->pix_fmt));
}
} else {
result = av_hwdevice_ctx_create(&context->hw_device_ctx, config->device_type, NULL, NULL, 0);
if (result < 0) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create %s hardware device context: %s", av_hwdevice_get_type_name(config->device_type), av_err2str(result));
} else {
SDL_Log("Using %s hardware acceleration with pixel format %s\n", av_hwdevice_get_type_name(config->device_type), av_get_pix_fmt_name(config->pix_fmt));
SDL_Log("Using %s hardware acceleration with pixel format %s", av_hwdevice_get_type_name(config->device_type), av_get_pix_fmt_name(config->pix_fmt));
}
}
}
@@ -498,7 +498,7 @@ static SDL_Colorspace GetFrameColorspace(AVFrame *frame)
if (frame && frame->colorspace != AVCOL_SPC_RGB) {
#ifdef DEBUG_COLORSPACE
SDL_Log("Frame colorspace: range: %d, primaries: %d, trc: %d, colorspace: %d, chroma_location: %d\n", frame->color_range, frame->color_primaries, frame->color_trc, frame->colorspace, frame->chroma_location);
SDL_Log("Frame colorspace: range: %d, primaries: %d, trc: %d, colorspace: %d, chroma_location: %d", frame->color_range, frame->color_primaries, frame->color_trc, frame->colorspace, frame->chroma_location);
#endif
colorspace = SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_YCBCR,
frame->color_range,
@@ -731,7 +731,7 @@ static bool GetNV12TextureForDRMFrame(AVFrame *frame, SDL_Texture **texture)
EGLImage image = eglCreateImage(display, EGL_NO_CONTEXT, EGL_LINUX_DMA_BUF_EXT, NULL, attr);
if (image == EGL_NO_IMAGE) {
SDL_Log("Couldn't create image: %d\n", glGetError());
SDL_Log("Couldn't create image: %d", glGetError());
return false;
}
@@ -916,7 +916,7 @@ static bool GetOESTextureForDRMFrame(AVFrame *frame, SDL_Texture **texture)
EGLImage image = eglCreateImage(display, EGL_NO_CONTEXT, EGL_LINUX_DMA_BUF_EXT, NULL, attr);
if (image == EGL_NO_IMAGE) {
SDL_Log("Couldn't create image: %d\n", glGetError());
SDL_Log("Couldn't create image: %d", glGetError());
return false;
}
@@ -1082,7 +1082,7 @@ static void DisplayVideoTexture(AVFrame *frame)
{
/* Update the video texture */
if (!GetTextureForFrame(frame, &video_texture)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't get texture for frame: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't get texture for frame: %s", SDL_GetError());
return;
}
@@ -1138,17 +1138,17 @@ static AVCodecContext *OpenAudioStream(AVFormatContext *ic, int stream, const AV
AVCodecContext *context;
int result;
SDL_Log("Audio stream: %s %d channels, %d Hz\n", avcodec_get_name(codec->id), codecpar->ch_layout.nb_channels, codecpar->sample_rate);
SDL_Log("Audio stream: %s %d channels, %d Hz", avcodec_get_name(codec->id), codecpar->ch_layout.nb_channels, codecpar->sample_rate);
context = avcodec_alloc_context3(NULL);
if (!context) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "avcodec_alloc_context3 failed\n");
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "avcodec_alloc_context3 failed");
return NULL;
}
result = avcodec_parameters_to_context(context, ic->streams[stream]->codecpar);
if (result < 0) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "avcodec_parameters_to_context failed: %s\n", av_err2str(result));
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "avcodec_parameters_to_context failed: %s", av_err2str(result));
avcodec_free_context(&context);
return NULL;
}
@@ -1471,7 +1471,7 @@ int main(int argc, char *argv[])
positions = (SDL_FRect *)SDL_malloc(num_sprites * sizeof(*positions));
velocities = (SDL_FRect *)SDL_malloc(num_sprites * sizeof(*velocities));
if (!positions || !velocities) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n");
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!");
return_code = 3;
goto quit;
}
@@ -1510,7 +1510,7 @@ int main(int argc, char *argv[])
if (!flushing) {
result = av_read_frame(ic, pkt);
if (result < 0) {
SDL_Log("End of stream, finishing decode\n");
SDL_Log("End of stream, finishing decode");
if (audio_context) {
avcodec_flush_buffers(audio_context);
}

View File

@@ -53,7 +53,7 @@ cleanup(void)
static void
iostrm_error_quit(unsigned line, SDL_IOStream *iostrm)
{
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "testfile.c(%d): failed\n", line);
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "testfile.c(%d): failed", line);
if (iostrm) {
SDL_CloseIO(iostrm);
}
@@ -105,7 +105,7 @@ int main(int argc, char *argv[])
if (iostrm) {
RWOP_ERR_QUIT(iostrm);
}
SDL_Log("test1 OK\n");
SDL_Log("test1 OK");
/* test 2 : check that inexistent file is not successfully opened/created when required */
/* modes : r, r+ imply that file MUST exist
@@ -144,7 +144,7 @@ int main(int argc, char *argv[])
}
SDL_CloseIO(iostrm);
unlink(FBASENAME2);
SDL_Log("test2 OK\n");
SDL_Log("test2 OK");
/* test 3 : creation, writing , reading, seeking,
test : w mode, r mode, w+ mode
@@ -257,7 +257,7 @@ int main(int argc, char *argv[])
RWOP_ERR_QUIT(iostrm);
}
SDL_CloseIO(iostrm);
SDL_Log("test3 OK\n");
SDL_Log("test3 OK");
/* test 4: same in r+ mode */
iostrm = SDL_IOFromFile(FBASENAME1, "rb+"); /* write + read + file must exists, no truncation */
@@ -308,7 +308,7 @@ int main(int argc, char *argv[])
RWOP_ERR_QUIT(iostrm);
}
SDL_CloseIO(iostrm);
SDL_Log("test4 OK\n");
SDL_Log("test4 OK");
/* test5 : append mode */
iostrm = SDL_IOFromFile(FBASENAME1, "ab+"); /* write + read + append */
@@ -365,7 +365,7 @@ int main(int argc, char *argv[])
RWOP_ERR_QUIT(iostrm);
}
SDL_CloseIO(iostrm);
SDL_Log("test5 OK\n");
SDL_Log("test5 OK");
cleanup();
SDL_Quit();
SDLTest_CommonDestroyState(state);

View File

@@ -106,42 +106,42 @@ int main(int argc, char *argv[])
}
if (!SDL_Init(0)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init() failed: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init() failed: %s", SDL_GetError());
return 1;
}
base_path = SDL_GetBasePath();
if (!base_path) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't find base path: %s\n",
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't find base path: %s",
SDL_GetError());
} else {
SDL_Log("base path: '%s'\n", base_path);
SDL_Log("base path: '%s'", base_path);
}
pref_path = SDL_GetPrefPath("libsdl", "test_filesystem");
if (!pref_path) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't find pref path: %s\n",
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't find pref path: %s",
SDL_GetError());
} else {
SDL_Log("pref path: '%s'\n", pref_path);
SDL_Log("pref path: '%s'", pref_path);
}
SDL_free(pref_path);
pref_path = SDL_GetPrefPath(NULL, "test_filesystem");
if (!pref_path) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't find pref path without organization: %s\n",
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't find pref path without organization: %s",
SDL_GetError());
} else {
SDL_Log("pref path: '%s'\n", pref_path);
SDL_Log("pref path: '%s'", pref_path);
}
SDL_free(pref_path);
curdir = SDL_GetCurrentDirectory();
if (!curdir) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't find current directory: %s\n",
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't find current directory: %s",
SDL_GetError());
} else {
SDL_Log("current directory: '%s'\n", curdir);
SDL_Log("current directory: '%s'", curdir);
}
SDL_free(curdir);
@@ -209,13 +209,13 @@ int main(int argc, char *argv[])
textA = (char *)SDL_LoadFile("testfilesystem-A", &sizeA);
if (!textA || sizeA != SDL_strlen(text) || SDL_strcmp(textA, text) != 0) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Contents of testfilesystem-A didn't match, expected %s, got %s\n", text, textA);
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Contents of testfilesystem-A didn't match, expected %s, got %s", text, textA);
}
SDL_free(textA);
textB = (char *)SDL_LoadFile("testfilesystem-B", &sizeB);
if (!textB || sizeB != SDL_strlen(text) || SDL_strcmp(textB, text) != 0) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Contents of testfilesystem-B didn't match, expected %s, got %s\n", text, textB);
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Contents of testfilesystem-B didn't match, expected %s, got %s", text, textB);
}
SDL_free(textB);
}

View File

@@ -57,7 +57,7 @@ static int LoadSprite(const char *file)
return -1;
}
if (!SDL_SetTextureBlendMode(sprites[i], blendMode)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set blend mode: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set blend mode: %s", SDL_GetError());
SDL_DestroyTexture(sprites[i]);
return -1;
}
@@ -239,7 +239,7 @@ int main(int argc, char *argv[])
sprites =
(SDL_Texture **)SDL_malloc(state->num_windows * sizeof(*sprites));
if (!sprites) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n");
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!");
quit(2);
}
/* Create the windows and initialize the renderers */
@@ -274,7 +274,7 @@ int main(int argc, char *argv[])
now = SDL_GetTicks();
if (now > then) {
double fps = ((double)frames * 1000) / (now - then);
SDL_Log("%2.2f frames per second\n", fps);
SDL_Log("%2.2f frames per second", fps);
}
quit(0);

View File

@@ -203,9 +203,9 @@ static void LogSwapInterval(void)
{
int interval = 0;
if (SDL_GL_GetSwapInterval(&interval)) {
SDL_Log("Swap Interval : %d\n", interval);
SDL_Log("Swap Interval : %d", interval);
} else {
SDL_Log("Swap Interval : %d error: %s\n", interval, SDL_GetError());
SDL_Log("Swap Interval : %d error: %s", interval, SDL_GetError());
}
}
@@ -282,13 +282,13 @@ int main(int argc, char *argv[])
/* Create OpenGL context */
context = SDL_GL_CreateContext(state->windows[0]);
if (!context) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_GL_CreateContext(): %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_GL_CreateContext(): %s", SDL_GetError());
quit(2);
}
/* Important: call this *after* creating the context */
if (!LoadContext(&ctx)) {
SDL_Log("Could not load GL functions\n");
SDL_Log("Could not load GL functions");
quit(2);
return 0;
}
@@ -298,68 +298,68 @@ int main(int argc, char *argv[])
mode = SDL_GetCurrentDisplayMode(SDL_GetPrimaryDisplay());
if (mode) {
SDL_Log("Screen BPP : %d\n", SDL_BITSPERPIXEL(mode->format));
SDL_Log("Screen BPP : %d", SDL_BITSPERPIXEL(mode->format));
}
LogSwapInterval();
SDL_GetWindowSize(state->windows[0], &dw, &dh);
SDL_Log("Window Size : %d,%d\n", dw, dh);
SDL_Log("Window Size : %d,%d", dw, dh);
SDL_GetWindowSizeInPixels(state->windows[0], &dw, &dh);
SDL_Log("Draw Size : %d,%d\n", dw, dh);
SDL_Log("\n");
SDL_Log("Vendor : %s\n", ctx.glGetString(GL_VENDOR));
SDL_Log("Renderer : %s\n", ctx.glGetString(GL_RENDERER));
SDL_Log("Version : %s\n", ctx.glGetString(GL_VERSION));
SDL_Log("Extensions : %s\n", ctx.glGetString(GL_EXTENSIONS));
SDL_Log("\n");
SDL_Log("Draw Size : %d,%d", dw, dh);
SDL_Log("%s", "");
SDL_Log("Vendor : %s", ctx.glGetString(GL_VENDOR));
SDL_Log("Renderer : %s", ctx.glGetString(GL_RENDERER));
SDL_Log("Version : %s", ctx.glGetString(GL_VERSION));
SDL_Log("Extensions : %s", ctx.glGetString(GL_EXTENSIONS));
SDL_Log("%s", "");
if (SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value)) {
SDL_Log("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value);
SDL_Log("SDL_GL_RED_SIZE: requested %d, got %d", 5, value);
} else {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_RED_SIZE: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_RED_SIZE: %s", SDL_GetError());
}
if (SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value)) {
SDL_Log("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value);
SDL_Log("SDL_GL_GREEN_SIZE: requested %d, got %d", 5, value);
} else {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_GREEN_SIZE: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_GREEN_SIZE: %s", SDL_GetError());
}
if (SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value)) {
SDL_Log("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value);
SDL_Log("SDL_GL_BLUE_SIZE: requested %d, got %d", 5, value);
} else {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_BLUE_SIZE: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_BLUE_SIZE: %s", SDL_GetError());
}
if (SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value)) {
SDL_Log("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", 16, value);
SDL_Log("SDL_GL_DEPTH_SIZE: requested %d, got %d", 16, value);
} else {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_DEPTH_SIZE: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_DEPTH_SIZE: %s", SDL_GetError());
}
if (SDL_GL_GetAttribute(SDL_GL_CONTEXT_RELEASE_BEHAVIOR, &value)) {
SDL_Log("SDL_GL_CONTEXT_RELEASE_BEHAVIOR: requested %d, got %d\n", 0, value);
SDL_Log("SDL_GL_CONTEXT_RELEASE_BEHAVIOR: requested %d, got %d", 0, value);
} else {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_CONTEXT_RELEASE_BEHAVIOR: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_CONTEXT_RELEASE_BEHAVIOR: %s", SDL_GetError());
}
if (fsaa) {
if (SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value)) {
SDL_Log("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value);
SDL_Log("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d", value);
} else {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n",
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s",
SDL_GetError());
}
if (SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value)) {
SDL_Log("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa,
SDL_Log("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d", fsaa,
value);
} else {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n",
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_MULTISAMPLESAMPLES: %s",
SDL_GetError());
}
}
if (accel >= 0) {
if (SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value)) {
SDL_Log("SDL_GL_ACCELERATED_VISUAL: requested %d, got %d\n", accel,
SDL_Log("SDL_GL_ACCELERATED_VISUAL: requested %d, got %d", accel,
value);
} else {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n",
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_ACCELERATED_VISUAL: %s",
SDL_GetError());
}
}
@@ -398,7 +398,7 @@ int main(int argc, char *argv[])
}
if (update_swap_interval) {
SDL_Log("Swap interval to be set to %d\n", swap_interval);
SDL_Log("Swap interval to be set to %d", swap_interval);
}
for (i = 0; i < state->num_windows; ++i) {
@@ -428,7 +428,7 @@ int main(int argc, char *argv[])
/* Print out some timing information */
now = SDL_GetTicks();
if (now > then) {
SDL_Log("%2.2f frames per second\n",
SDL_Log("%2.2f frames per second",
((double)frames * 1000) / (now - then));
}
quit(0);
@@ -439,7 +439,7 @@ int main(int argc, char *argv[])
int main(int argc, char *argv[])
{
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No OpenGL support on this system\n");
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No OpenGL support on this system");
return 1;
}

View File

@@ -173,7 +173,7 @@ int main(int argc, char *argv[])
context = (SDL_GLContext *)SDL_calloc(state->num_windows, sizeof(*context));
if (!context) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n");
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!");
quit(2);
}
@@ -181,7 +181,7 @@ int main(int argc, char *argv[])
for (i = 0; i < state->num_windows; i++) {
context[i] = SDL_GL_CreateContext(state->windows[i]);
if (!context[i]) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_GL_CreateContext(): %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_GL_CreateContext(): %s", SDL_GetError());
quit(2);
}
}
@@ -190,59 +190,59 @@ int main(int argc, char *argv[])
mode = SDL_GetCurrentDisplayMode(SDL_GetPrimaryDisplay());
if (mode) {
SDL_Log("Screen bpp: %d\n", SDL_BITSPERPIXEL(mode->format));
SDL_Log("\n");
SDL_Log("Screen bpp: %d", SDL_BITSPERPIXEL(mode->format));
SDL_Log("%s", "");
}
SDL_Log("Vendor : %s\n", glGetString(GL_VENDOR));
SDL_Log("Renderer : %s\n", glGetString(GL_RENDERER));
SDL_Log("Version : %s\n", glGetString(GL_VERSION));
SDL_Log("Extensions : %s\n", glGetString(GL_EXTENSIONS));
SDL_Log("\n");
SDL_Log("Vendor : %s", glGetString(GL_VENDOR));
SDL_Log("Renderer : %s", glGetString(GL_RENDERER));
SDL_Log("Version : %s", glGetString(GL_VERSION));
SDL_Log("Extensions : %s", glGetString(GL_EXTENSIONS));
SDL_Log("%s", "");
if (SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value)) {
SDL_Log("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value);
SDL_Log("SDL_GL_RED_SIZE: requested %d, got %d", 5, value);
} else {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_RED_SIZE: %s\n",
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_RED_SIZE: %s",
SDL_GetError());
}
if (SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value)) {
SDL_Log("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value);
SDL_Log("SDL_GL_GREEN_SIZE: requested %d, got %d", 5, value);
} else {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_GREEN_SIZE: %s\n",
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_GREEN_SIZE: %s",
SDL_GetError());
}
if (SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value)) {
SDL_Log("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value);
SDL_Log("SDL_GL_BLUE_SIZE: requested %d, got %d", 5, value);
} else {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_BLUE_SIZE: %s\n",
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_BLUE_SIZE: %s",
SDL_GetError());
}
if (SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value)) {
SDL_Log("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", depth, value);
SDL_Log("SDL_GL_DEPTH_SIZE: requested %d, got %d", depth, value);
} else {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_DEPTH_SIZE: %s\n",
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_DEPTH_SIZE: %s",
SDL_GetError());
}
if (fsaa) {
if (SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value)) {
SDL_Log("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value);
SDL_Log("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d", value);
} else {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n",
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s",
SDL_GetError());
}
if (SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value)) {
SDL_Log("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa,
SDL_Log("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d", fsaa,
value);
} else {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n",
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_MULTISAMPLESAMPLES: %s",
SDL_GetError());
}
}
if (accel) {
if (SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value)) {
SDL_Log("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value);
SDL_Log("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d", value);
} else {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n",
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_ACCELERATED_VISUAL: %s",
SDL_GetError());
}
}
@@ -252,7 +252,7 @@ int main(int argc, char *argv[])
float aspectAdjust;
if (!SDL_GL_MakeCurrent(state->windows[i], context[i])) {
SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
SDL_Log("SDL_GL_MakeCurrent(): %s", SDL_GetError());
/* Continue for next window */
continue;
@@ -282,7 +282,7 @@ int main(int argc, char *argv[])
for (i = 0; i < state->num_windows; ++i) {
if (event.window.windowID == SDL_GetWindowID(state->windows[i])) {
if (!SDL_GL_MakeCurrent(state->windows[i], context[i])) {
SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
SDL_Log("SDL_GL_MakeCurrent(): %s", SDL_GetError());
break;
}
/* Change view port to the new window dimensions */
@@ -301,7 +301,7 @@ int main(int argc, char *argv[])
continue;
}
if (!SDL_GL_MakeCurrent(state->windows[i], context[i])) {
SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
SDL_Log("SDL_GL_MakeCurrent(): %s", SDL_GetError());
/* Continue for next window */
continue;
@@ -314,7 +314,7 @@ int main(int argc, char *argv[])
/* Print out some timing information */
now = SDL_GetTicks();
if (now > then) {
SDL_Log("%2.2f frames per second\n",
SDL_Log("%2.2f frames per second",
((double)frames * 1000) / (now - then));
}
#ifndef SDL_PLATFORM_ANDROID
@@ -327,7 +327,7 @@ int main(int argc, char *argv[])
int main(int argc, char *argv[])
{
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No OpenGL ES support on this system\n");
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No OpenGL ES support on this system");
return 1;
}

View File

@@ -124,7 +124,7 @@ quit(int rc)
{ \
GLenum glError = ctx.glGetError(); \
if (glError != GL_NO_ERROR) { \
SDL_Log("glGetError() = %i (0x%.8x) at line %i\n", glError, glError, __LINE__); \
SDL_Log("glGetError() = %i (0x%.8x) at line %i", glError, glError, __LINE__); \
quit(1); \
} \
}
@@ -551,7 +551,7 @@ render_window(int index)
}
if (!SDL_GL_MakeCurrent(state->windows[index], context[index])) {
SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
SDL_Log("SDL_GL_MakeCurrent(): %s", SDL_GetError());
return;
}
@@ -750,7 +750,7 @@ int main(int argc, char *argv[])
context = (SDL_GLContext *)SDL_calloc(state->num_windows, sizeof(*context));
if (!context) {
SDL_Log("Out of memory!\n");
SDL_Log("Out of memory!");
quit(2);
}
@@ -758,14 +758,14 @@ int main(int argc, char *argv[])
for (i = 0; i < state->num_windows; i++) {
context[i] = SDL_GL_CreateContext(state->windows[i]);
if (!context[i]) {
SDL_Log("SDL_GL_CreateContext(): %s\n", SDL_GetError());
SDL_Log("SDL_GL_CreateContext(): %s", SDL_GetError());
quit(2);
}
}
/* Important: call this *after* creating the context */
if (!LoadContext(&ctx)) {
SDL_Log("Could not load GLES2 functions\n");
SDL_Log("Could not load GLES2 functions");
quit(2);
return 0;
}
@@ -773,61 +773,61 @@ int main(int argc, char *argv[])
SDL_GL_SetSwapInterval(state->render_vsync);
mode = SDL_GetCurrentDisplayMode(SDL_GetPrimaryDisplay());
SDL_Log("Threaded : %s\n", threaded ? "yes" : "no");
SDL_Log("Threaded : %s", threaded ? "yes" : "no");
if (mode) {
SDL_Log("Screen bpp: %d\n", SDL_BITSPERPIXEL(mode->format));
SDL_Log("\n");
SDL_Log("Screen bpp: %d", SDL_BITSPERPIXEL(mode->format));
SDL_Log("%s", "");
}
SDL_Log("Vendor : %s\n", ctx.glGetString(GL_VENDOR));
SDL_Log("Renderer : %s\n", ctx.glGetString(GL_RENDERER));
SDL_Log("Version : %s\n", ctx.glGetString(GL_VERSION));
SDL_Log("Extensions : %s\n", ctx.glGetString(GL_EXTENSIONS));
SDL_Log("\n");
SDL_Log("Vendor : %s", ctx.glGetString(GL_VENDOR));
SDL_Log("Renderer : %s", ctx.glGetString(GL_RENDERER));
SDL_Log("Version : %s", ctx.glGetString(GL_VERSION));
SDL_Log("Extensions : %s", ctx.glGetString(GL_EXTENSIONS));
SDL_Log("%s", "");
if (SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value)) {
SDL_Log("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value);
SDL_Log("SDL_GL_RED_SIZE: requested %d, got %d", 5, value);
} else {
SDL_Log("Failed to get SDL_GL_RED_SIZE: %s\n",
SDL_Log("Failed to get SDL_GL_RED_SIZE: %s",
SDL_GetError());
}
if (SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value)) {
SDL_Log("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value);
SDL_Log("SDL_GL_GREEN_SIZE: requested %d, got %d", 5, value);
} else {
SDL_Log("Failed to get SDL_GL_GREEN_SIZE: %s\n",
SDL_Log("Failed to get SDL_GL_GREEN_SIZE: %s",
SDL_GetError());
}
if (SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value)) {
SDL_Log("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value);
SDL_Log("SDL_GL_BLUE_SIZE: requested %d, got %d", 5, value);
} else {
SDL_Log("Failed to get SDL_GL_BLUE_SIZE: %s\n",
SDL_Log("Failed to get SDL_GL_BLUE_SIZE: %s",
SDL_GetError());
}
if (SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value)) {
SDL_Log("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", depth, value);
SDL_Log("SDL_GL_DEPTH_SIZE: requested %d, got %d", depth, value);
} else {
SDL_Log("Failed to get SDL_GL_DEPTH_SIZE: %s\n",
SDL_Log("Failed to get SDL_GL_DEPTH_SIZE: %s",
SDL_GetError());
}
if (fsaa) {
if (SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value)) {
SDL_Log("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value);
SDL_Log("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d", value);
} else {
SDL_Log("Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n",
SDL_Log("Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s",
SDL_GetError());
}
if (SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value)) {
SDL_Log("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa,
SDL_Log("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d", fsaa,
value);
} else {
SDL_Log("Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n",
SDL_Log("Failed to get SDL_GL_MULTISAMPLESAMPLES: %s",
SDL_GetError());
}
}
if (accel) {
if (SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value)) {
SDL_Log("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value);
SDL_Log("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d", value);
} else {
SDL_Log("Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n",
SDL_Log("Failed to get SDL_GL_ACCELERATED_VISUAL: %s",
SDL_GetError());
}
}
@@ -839,7 +839,7 @@ int main(int argc, char *argv[])
int w, h;
if (!SDL_GL_MakeCurrent(state->windows[i], context[i])) {
SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
SDL_Log("SDL_GL_MakeCurrent(): %s", SDL_GetError());
/* Continue for next window */
continue;
@@ -936,7 +936,7 @@ int main(int argc, char *argv[])
/* Print out some timing information */
now = SDL_GetTicks();
if (now > then) {
SDL_Log("%2.2f frames per second\n",
SDL_Log("%2.2f frames per second",
((double)frames * 1000) / (now - then));
}
#ifndef SDL_PLATFORM_ANDROID
@@ -949,7 +949,7 @@ int main(int argc, char *argv[])
int main(int argc, char *argv[])
{
SDL_Log("No OpenGL ES support on this system\n");
SDL_Log("No OpenGL ES support on this system");
return 1;
}

View File

@@ -114,7 +114,7 @@ quit(int rc)
{ \
GLenum glError = ctx.glGetError(); \
if (glError != GL_NO_ERROR) { \
SDL_Log("glGetError() = %i (0x%.8x) at line %i\n", glError, glError, __LINE__); \
SDL_Log("glGetError() = %i (0x%.8x) at line %i", glError, glError, __LINE__); \
quit(1); \
} \
}
@@ -363,7 +363,7 @@ static void loop(void)
if (event.window.windowID == SDL_GetWindowID(state->windows[i])) {
int w, h;
if (!SDL_GL_MakeCurrent(state->windows[i], context[i])) {
SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
SDL_Log("SDL_GL_MakeCurrent(): %s", SDL_GetError());
break;
}
/* Change view port to the new window dimensions */
@@ -414,7 +414,7 @@ static void loop(void)
if (!done) {
for (i = 0; i < state->num_windows; ++i) {
if (!SDL_GL_MakeCurrent(state->windows[i], context[i])) {
SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
SDL_Log("SDL_GL_MakeCurrent(): %s", SDL_GetError());
/* Continue for next window */
continue;
@@ -509,7 +509,7 @@ int main(int argc, char *argv[])
context = (SDL_GLContext *)SDL_calloc(state->num_windows, sizeof(*context));
if (!context) {
SDL_Log("Out of memory!\n");
SDL_Log("Out of memory!");
quit(2);
}
@@ -517,14 +517,14 @@ int main(int argc, char *argv[])
for (i = 0; i < state->num_windows; i++) {
context[i] = SDL_GL_CreateContext(state->windows[i]);
if (!context[i]) {
SDL_Log("SDL_GL_CreateContext(): %s\n", SDL_GetError());
SDL_Log("SDL_GL_CreateContext(): %s", SDL_GetError());
quit(2);
}
}
/* Important: call this *after* creating the context */
if (!LoadContext(&ctx)) {
SDL_Log("Could not load GLES2 functions\n");
SDL_Log("Could not load GLES2 functions");
quit(2);
return 0;
}
@@ -554,7 +554,7 @@ int main(int argc, char *argv[])
}
if (!path) {
SDL_Log("out of memory\n");
SDL_Log("out of memory");
exit(-1);
}
@@ -605,59 +605,59 @@ int main(int argc, char *argv[])
mode = SDL_GetCurrentDisplayMode(SDL_GetPrimaryDisplay());
if (mode) {
SDL_Log("Screen bpp: %d\n", SDL_BITSPERPIXEL(mode->format));
SDL_Log("\n");
SDL_Log("Screen bpp: %d", SDL_BITSPERPIXEL(mode->format));
SDL_Log("%s", "");
}
SDL_Log("Vendor : %s\n", ctx.glGetString(GL_VENDOR));
SDL_Log("Renderer : %s\n", ctx.glGetString(GL_RENDERER));
SDL_Log("Version : %s\n", ctx.glGetString(GL_VERSION));
SDL_Log("Extensions : %s\n", ctx.glGetString(GL_EXTENSIONS));
SDL_Log("\n");
SDL_Log("Vendor : %s", ctx.glGetString(GL_VENDOR));
SDL_Log("Renderer : %s", ctx.glGetString(GL_RENDERER));
SDL_Log("Version : %s", ctx.glGetString(GL_VERSION));
SDL_Log("Extensions : %s", ctx.glGetString(GL_EXTENSIONS));
SDL_Log("%s", "");
if (SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value)) {
SDL_Log("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value);
SDL_Log("SDL_GL_RED_SIZE: requested %d, got %d", 5, value);
} else {
SDL_Log("Failed to get SDL_GL_RED_SIZE: %s\n",
SDL_Log("Failed to get SDL_GL_RED_SIZE: %s",
SDL_GetError());
}
if (SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value)) {
SDL_Log("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value);
SDL_Log("SDL_GL_GREEN_SIZE: requested %d, got %d", 5, value);
} else {
SDL_Log("Failed to get SDL_GL_GREEN_SIZE: %s\n",
SDL_Log("Failed to get SDL_GL_GREEN_SIZE: %s",
SDL_GetError());
}
if (SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value)) {
SDL_Log("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value);
SDL_Log("SDL_GL_BLUE_SIZE: requested %d, got %d", 5, value);
} else {
SDL_Log("Failed to get SDL_GL_BLUE_SIZE: %s\n",
SDL_Log("Failed to get SDL_GL_BLUE_SIZE: %s",
SDL_GetError());
}
if (SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value)) {
SDL_Log("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", depth, value);
SDL_Log("SDL_GL_DEPTH_SIZE: requested %d, got %d", depth, value);
} else {
SDL_Log("Failed to get SDL_GL_DEPTH_SIZE: %s\n",
SDL_Log("Failed to get SDL_GL_DEPTH_SIZE: %s",
SDL_GetError());
}
if (fsaa) {
if (SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value)) {
SDL_Log("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value);
SDL_Log("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d", value);
} else {
SDL_Log("Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n",
SDL_Log("Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s",
SDL_GetError());
}
if (SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value)) {
SDL_Log("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa,
SDL_Log("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d", fsaa,
value);
} else {
SDL_Log("Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n",
SDL_Log("Failed to get SDL_GL_MULTISAMPLESAMPLES: %s",
SDL_GetError());
}
}
if (accel) {
if (SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value)) {
SDL_Log("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value);
SDL_Log("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d", value);
} else {
SDL_Log("Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n",
SDL_Log("Failed to get SDL_GL_ACCELERATED_VISUAL: %s",
SDL_GetError());
}
}
@@ -669,7 +669,7 @@ int main(int argc, char *argv[])
int w, h;
if (!SDL_GL_MakeCurrent(state->windows[i], context[i])) {
SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
SDL_Log("SDL_GL_MakeCurrent(): %s", SDL_GetError());
/* Continue for next window */
continue;
@@ -765,7 +765,7 @@ int main(int argc, char *argv[])
/* Print out some timing information */
now = SDL_GetTicks();
if (now > then) {
SDL_Log("%2.2f frames per second\n",
SDL_Log("%2.2f frames per second",
((double)frames * 1000) / (now - then));
}
#ifndef SDL_PLATFORM_ANDROID
@@ -778,7 +778,7 @@ int main(int argc, char *argv[])
int main(int argc, char *argv[])
{
SDL_Log("No OpenGL ES support on this system\n");
SDL_Log("No OpenGL ES support on this system");
return 1;
}

View File

@@ -54,13 +54,13 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
mode = SDL_GetCurrentDisplayMode(SDL_GetPrimaryDisplay());
if (mode) {
SDL_Log("Screen BPP : %d\n", SDL_BITSPERPIXEL(mode->format));
SDL_Log("Screen BPP : %d", SDL_BITSPERPIXEL(mode->format));
}
SDL_GetWindowSize(state->windows[0], &dw, &dh);
SDL_Log("Window Size : %d,%d\n", dw, dh);
SDL_Log("Window Size : %d,%d", dw, dh);
SDL_GetWindowSizeInPixels(state->windows[0], &dw, &dh);
SDL_Log("Draw Size : %d,%d\n", dw, dh);
SDL_Log("\n");
SDL_Log("Draw Size : %d,%d", dw, dh);
SDL_Log("%s", "");
then = SDL_GetTicks();
@@ -119,7 +119,7 @@ void SDL_AppQuit(void *appstate, SDL_AppResult result)
/* Print out some timing information */
const Uint64 now = SDL_GetTicks();
if (now > then) {
SDL_Log("%2.2f frames per second\n", ((double)frames * 1000) / (now - then));
SDL_Log("%2.2f frames per second", ((double)frames * 1000) / (now - then));
}
SDL_ReleaseWindowFromGPUDevice(gpu_device, state->windows[0]);

View File

@@ -27,7 +27,7 @@
#define TESTGPU_SUPPORTED_FORMATS (SDL_GPU_SHADERFORMAT_SPIRV | SDL_GPU_SHADERFORMAT_DXBC | SDL_GPU_SHADERFORMAT_DXIL | SDL_GPU_SHADERFORMAT_METALLIB)
#define CHECK_CREATE(var, thing) { if (!(var)) { SDL_Log("Failed to create %s: %s\n", thing, SDL_GetError()); quit(2); } }
#define CHECK_CREATE(var, thing) { if (!(var)) { SDL_Log("Failed to create %s: %s", thing, SDL_GetError()); quit(2); } }
static Uint32 frames = 0;
@@ -641,7 +641,7 @@ init_render_state(int msaa)
window_states = (WindowState *) SDL_calloc(state->num_windows, sizeof (WindowState));
if (!window_states) {
SDL_Log("Out of memory!\n");
SDL_Log("Out of memory!");
quit(2);
}
@@ -729,7 +729,7 @@ main(int argc, char *argv[])
}
mode = SDL_GetCurrentDisplayMode(SDL_GetDisplayForWindow(state->windows[0]));
SDL_Log("Screen bpp: %d\n", SDL_BITSPERPIXEL(mode->format));
SDL_Log("Screen bpp: %d", SDL_BITSPERPIXEL(mode->format));
init_render_state(msaa);
@@ -749,7 +749,7 @@ main(int argc, char *argv[])
/* Print out some timing information */
now = SDL_GetTicks();
if (now > then) {
SDL_Log("%2.2f frames per second\n",
SDL_Log("%2.2f frames per second",
((double) frames * 1000) / (now - then));
}
#if !defined(__ANDROID__)

View File

@@ -69,9 +69,9 @@ int main(int argc, char **argv)
if (consumed <= 0) {
static const char *options[] = { "[device]", NULL };
SDLTest_CommonLogUsage(state, argv[0], options);
SDL_Log("\n");
SDL_Log("If device is a two-digit number it'll use it as an index, otherwise\n"
"it'll use it as if it were part of the device's name.\n");
SDL_Log("%s", "");
SDL_Log("If device is a two-digit number it'll use it as an index, otherwise");
SDL_Log("it'll use it as if it were part of the device's name.");
return 1;
}
@@ -81,12 +81,12 @@ int main(int argc, char **argv)
/* Initialize the force feedbackness */
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC);
haptics = SDL_GetHaptics(&num_haptics);
SDL_Log("%d Haptic devices detected.\n", num_haptics);
SDL_Log("%d Haptic devices detected.", num_haptics);
for (i = 0; i < num_haptics; ++i) {
SDL_Log(" %s\n", SDL_GetHapticNameForID(haptics[i]));
SDL_Log(" %s", SDL_GetHapticNameForID(haptics[i]));
}
if (num_haptics == 0) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No Haptic devices found!\n");
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No Haptic devices found!");
SDL_free(haptics);
return 1;
}
@@ -96,7 +96,7 @@ int main(int argc, char **argv)
i = (index != -1) ? index : 0;
if (i >= num_haptics) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Index out of range, aborting.\n");
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Index out of range, aborting.");
SDL_free(haptics);
return 1;
}
@@ -110,7 +110,7 @@ int main(int argc, char **argv)
}
if (i >= num_haptics) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to find device matching '%s', aborting.\n", name);
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to find device matching '%s', aborting.", name);
SDL_free(haptics);
return 1;
}
@@ -118,11 +118,11 @@ int main(int argc, char **argv)
haptic = SDL_OpenHaptic(haptics[i]);
if (!haptic) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create the haptic device: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create the haptic device: %s", SDL_GetError());
SDL_free(haptics);
return 1;
}
SDL_Log("Device: %s\n", SDL_GetHapticName(haptic));
SDL_Log("Device: %s", SDL_GetHapticName(haptic));
HapticPrintSupported(haptic);
SDL_free(haptics);
@@ -134,10 +134,11 @@ int main(int argc, char **argv)
nefx = 0;
supported = SDL_GetHapticFeatures(haptic);
SDL_Log("\nUploading effects\n");
SDL_Log("%s", "");
SDL_Log("Uploading effects");
/* First we'll try a SINE effect. */
if (supported & SDL_HAPTIC_SINE) {
SDL_Log(" effect %d: Sine Wave\n", nefx);
SDL_Log(" effect %d: Sine Wave", nefx);
efx[nefx].type = SDL_HAPTIC_SINE;
efx[nefx].periodic.period = 1000;
efx[nefx].periodic.magnitude = -0x2000; /* Negative magnitude and ... */
@@ -147,14 +148,14 @@ int main(int argc, char **argv)
efx[nefx].periodic.fade_length = 1000;
id[nefx] = SDL_CreateHapticEffect(haptic, &efx[nefx]);
if (id[nefx] < 0) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s", SDL_GetError());
abort_execution();
}
nefx++;
}
/* Now we'll try a SAWTOOTHUP */
if (supported & SDL_HAPTIC_SAWTOOTHUP) {
SDL_Log(" effect %d: Sawtooth Up\n", nefx);
SDL_Log(" effect %d: Sawtooth Up", nefx);
efx[nefx].type = SDL_HAPTIC_SAWTOOTHUP;
efx[nefx].periodic.period = 500;
efx[nefx].periodic.magnitude = 0x5000;
@@ -163,7 +164,7 @@ int main(int argc, char **argv)
efx[nefx].periodic.fade_length = 1000;
id[nefx] = SDL_CreateHapticEffect(haptic, &efx[nefx]);
if (id[nefx] < 0) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s", SDL_GetError());
abort_execution();
}
nefx++;
@@ -171,7 +172,7 @@ int main(int argc, char **argv)
/* Now the classical constant effect. */
if (supported & SDL_HAPTIC_CONSTANT) {
SDL_Log(" effect %d: Constant Force\n", nefx);
SDL_Log(" effect %d: Constant Force", nefx);
efx[nefx].type = SDL_HAPTIC_CONSTANT;
efx[nefx].constant.direction.type = SDL_HAPTIC_POLAR;
efx[nefx].constant.direction.dir[0] = 20000; /* Force comes from the south-west. */
@@ -181,7 +182,7 @@ int main(int argc, char **argv)
efx[nefx].constant.fade_length = 1000;
id[nefx] = SDL_CreateHapticEffect(haptic, &efx[nefx]);
if (id[nefx] < 0) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s", SDL_GetError());
abort_execution();
}
nefx++;
@@ -189,7 +190,7 @@ int main(int argc, char **argv)
/* The cute spring effect. */
if (supported & SDL_HAPTIC_SPRING) {
SDL_Log(" effect %d: Condition Spring\n", nefx);
SDL_Log(" effect %d: Condition Spring", nefx);
efx[nefx].type = SDL_HAPTIC_SPRING;
efx[nefx].condition.length = 5000;
for (i = 0; i < SDL_GetNumHapticAxes(haptic); i++) {
@@ -201,14 +202,14 @@ int main(int argc, char **argv)
}
id[nefx] = SDL_CreateHapticEffect(haptic, &efx[nefx]);
if (id[nefx] < 0) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s", SDL_GetError());
abort_execution();
}
nefx++;
}
/* The interesting damper effect. */
if (supported & SDL_HAPTIC_DAMPER) {
SDL_Log(" effect %d: Condition Damper\n", nefx);
SDL_Log(" effect %d: Condition Damper", nefx);
efx[nefx].type = SDL_HAPTIC_DAMPER;
efx[nefx].condition.length = 5000;
for (i = 0; i < SDL_GetNumHapticAxes(haptic); i++) {
@@ -219,14 +220,14 @@ int main(int argc, char **argv)
}
id[nefx] = SDL_CreateHapticEffect(haptic, &efx[nefx]);
if (id[nefx] < 0) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s", SDL_GetError());
abort_execution();
}
nefx++;
}
/* The pretty awesome inertia effect. */
if (supported & SDL_HAPTIC_INERTIA) {
SDL_Log(" effect %d: Condition Inertia\n", nefx);
SDL_Log(" effect %d: Condition Inertia", nefx);
efx[nefx].type = SDL_HAPTIC_INERTIA;
efx[nefx].condition.length = 5000;
for (i = 0; i < SDL_GetNumHapticAxes(haptic); i++) {
@@ -238,14 +239,14 @@ int main(int argc, char **argv)
}
id[nefx] = SDL_CreateHapticEffect(haptic, &efx[nefx]);
if (id[nefx] < 0) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s", SDL_GetError());
abort_execution();
}
nefx++;
}
/* The hot friction effect. */
if (supported & SDL_HAPTIC_FRICTION) {
SDL_Log(" effect %d: Condition Friction\n", nefx);
SDL_Log(" effect %d: Condition Friction", nefx);
efx[nefx].type = SDL_HAPTIC_FRICTION;
efx[nefx].condition.length = 5000;
for (i = 0; i < SDL_GetNumHapticAxes(haptic); i++) {
@@ -256,7 +257,7 @@ int main(int argc, char **argv)
}
id[nefx] = SDL_CreateHapticEffect(haptic, &efx[nefx]);
if (id[nefx] < 0) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s", SDL_GetError());
abort_execution();
}
nefx++;
@@ -264,7 +265,7 @@ int main(int argc, char **argv)
/* Now we'll try a ramp effect */
if (supported & SDL_HAPTIC_RAMP) {
SDL_Log(" effect %d: Ramp\n", nefx);
SDL_Log(" effect %d: Ramp", nefx);
efx[nefx].type = SDL_HAPTIC_RAMP;
efx[nefx].ramp.direction.type = SDL_HAPTIC_CARTESIAN;
efx[nefx].ramp.direction.dir[0] = 1; /* Force comes from */
@@ -276,7 +277,7 @@ int main(int argc, char **argv)
efx[nefx].ramp.fade_length = 1000;
id[nefx] = SDL_CreateHapticEffect(haptic, &efx[nefx]);
if (id[nefx] < 0) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s", SDL_GetError());
abort_execution();
}
nefx++;
@@ -284,22 +285,23 @@ int main(int argc, char **argv)
/* Finally we'll try a left/right effect. */
if (supported & SDL_HAPTIC_LEFTRIGHT) {
SDL_Log(" effect %d: Left/Right\n", nefx);
SDL_Log(" effect %d: Left/Right", nefx);
efx[nefx].type = SDL_HAPTIC_LEFTRIGHT;
efx[nefx].leftright.length = 5000;
efx[nefx].leftright.large_magnitude = 0x3000;
efx[nefx].leftright.small_magnitude = 0xFFFF;
id[nefx] = SDL_CreateHapticEffect(haptic, &efx[nefx]);
if (id[nefx] < 0) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s", SDL_GetError());
abort_execution();
}
nefx++;
}
SDL_Log("\nNow playing effects for 5 seconds each with 1 second delay between\n");
SDL_Log("%s", "");
SDL_Log("Now playing effects for 5 seconds each with 1 second delay between");
for (i = 0; i < nefx; i++) {
SDL_Log(" Playing effect %d\n", i);
SDL_Log(" Playing effect %d", i);
SDL_RunHapticEffect(haptic, id[i], 1);
SDL_Delay(6000); /* Effects only have length 5000 */
}
@@ -320,7 +322,8 @@ int main(int argc, char **argv)
static void
abort_execution(void)
{
SDL_Log("\nAborting program execution.\n");
SDL_Log("%s", "");
SDL_Log("Aborting program execution.");
SDL_CloseHaptic(haptic);
SDL_Quit();
@@ -338,54 +341,54 @@ HapticPrintSupported(SDL_Haptic *ptr)
unsigned int supported;
supported = SDL_GetHapticFeatures(ptr);
SDL_Log(" Supported effects [%d effects, %d playing]:\n",
SDL_Log(" Supported effects [%d effects, %d playing]:",
SDL_GetMaxHapticEffects(ptr), SDL_GetMaxHapticEffectsPlaying(ptr));
if (supported & SDL_HAPTIC_CONSTANT) {
SDL_Log(" constant\n");
SDL_Log(" constant");
}
if (supported & SDL_HAPTIC_SINE) {
SDL_Log(" sine\n");
SDL_Log(" sine");
}
if (supported & SDL_HAPTIC_SQUARE)
SDL_Log(" square\n");
SDL_Log(" square");
if (supported & SDL_HAPTIC_TRIANGLE) {
SDL_Log(" triangle\n");
SDL_Log(" triangle");
}
if (supported & SDL_HAPTIC_SAWTOOTHUP) {
SDL_Log(" sawtoothup\n");
SDL_Log(" sawtoothup");
}
if (supported & SDL_HAPTIC_SAWTOOTHDOWN) {
SDL_Log(" sawtoothdown\n");
SDL_Log(" sawtoothdown");
}
if (supported & SDL_HAPTIC_RAMP) {
SDL_Log(" ramp\n");
SDL_Log(" ramp");
}
if (supported & SDL_HAPTIC_FRICTION) {
SDL_Log(" friction\n");
SDL_Log(" friction");
}
if (supported & SDL_HAPTIC_SPRING) {
SDL_Log(" spring\n");
SDL_Log(" spring");
}
if (supported & SDL_HAPTIC_DAMPER) {
SDL_Log(" damper\n");
SDL_Log(" damper");
}
if (supported & SDL_HAPTIC_INERTIA) {
SDL_Log(" inertia\n");
SDL_Log(" inertia");
}
if (supported & SDL_HAPTIC_CUSTOM) {
SDL_Log(" custom\n");
SDL_Log(" custom");
}
if (supported & SDL_HAPTIC_LEFTRIGHT) {
SDL_Log(" left/right\n");
SDL_Log(" left/right");
}
SDL_Log(" Supported capabilities:\n");
SDL_Log(" Supported capabilities:");
if (supported & SDL_HAPTIC_GAIN) {
SDL_Log(" gain\n");
SDL_Log(" gain");
}
if (supported & SDL_HAPTIC_AUTOCENTER) {
SDL_Log(" autocenter\n");
SDL_Log(" autocenter");
}
if (supported & SDL_HAPTIC_STATUS) {
SDL_Log(" status\n");
SDL_Log(" status");
}
}

View File

@@ -47,14 +47,14 @@ hitTest(SDL_Window *window, const SDL_Point *pt, void *data)
for (i = 0; i < numareas; i++) {
if (SDL_PointInRect(&adj_pt, &areas[i])) {
SDL_Log("HIT-TEST: DRAGGABLE\n");
SDL_Log("HIT-TEST: DRAGGABLE");
return SDL_HITTEST_DRAGGABLE;
}
}
#define REPORT_RESIZE_HIT(name) \
{ \
SDL_Log("HIT-TEST: RESIZE_" #name "\n"); \
SDL_Log("HIT-TEST: RESIZE_" #name ""); \
return SDL_HITTEST_RESIZE_##name; \
}
@@ -76,7 +76,7 @@ hitTest(SDL_Window *window, const SDL_Point *pt, void *data)
REPORT_RESIZE_HIT(LEFT);
}
SDL_Log("HIT-TEST: NORMAL\n");
SDL_Log("HIT-TEST: NORMAL");
return SDL_HITTEST_NORMAL;
}
@@ -130,15 +130,15 @@ int main(int argc, char **argv)
switch (e.type) {
case SDL_EVENT_MOUSE_BUTTON_DOWN:
SDL_Log("button down!\n");
SDL_Log("button down!");
break;
case SDL_EVENT_MOUSE_BUTTON_UP:
SDL_Log("button up!\n");
SDL_Log("button up!");
break;
case SDL_EVENT_WINDOW_MOVED:
SDL_Log("Window event moved to (%d, %d)!\n", (int)e.window.data1, (int)e.window.data2);
SDL_Log("Window event moved to (%d, %d)!", (int)e.window.data1, (int)e.window.data2);
break;
case SDL_EVENT_KEY_DOWN:

View File

@@ -66,7 +66,7 @@ int main(int argc, char *argv[])
/* Initialize SDL (Note: video is required to start event loop) */
if (!SDL_Init(init_subsystems)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s", SDL_GetError());
exit(1);
}
@@ -75,18 +75,18 @@ int main(int argc, char *argv[])
*/
SDL_free(SDL_GetKeyboards(&num_keyboards));
SDL_Log("There are %d keyboards at startup\n", num_keyboards);
SDL_Log("There are %d keyboards at startup", num_keyboards);
SDL_free(SDL_GetMice(&num_mice));
SDL_Log("There are %d mice at startup\n", num_mice);
SDL_Log("There are %d mice at startup", num_mice);
SDL_free(SDL_GetJoysticks(&num_joysticks));
SDL_Log("There are %d joysticks at startup\n", num_joysticks);
SDL_Log("There are %d joysticks at startup", num_joysticks);
if (enable_haptic) {
int num_haptics;
SDL_free(SDL_GetHaptics(&num_haptics));
SDL_Log("There are %d haptic devices at startup\n", num_haptics);
SDL_Log("There are %d haptic devices at startup", num_haptics);
}
while (keepGoing) {
@@ -97,46 +97,46 @@ int main(int argc, char *argv[])
keepGoing = false;
break;
case SDL_EVENT_KEYBOARD_ADDED:
SDL_Log("Keyboard '%s' added : %" SDL_PRIu32 "\n", SDL_GetKeyboardNameForID(event.kdevice.which), event.kdevice.which);
SDL_Log("Keyboard '%s' added : %" SDL_PRIu32, SDL_GetKeyboardNameForID(event.kdevice.which), event.kdevice.which);
break;
case SDL_EVENT_KEYBOARD_REMOVED:
SDL_Log("Keyboard removed: %" SDL_PRIu32 "\n", event.kdevice.which);
SDL_Log("Keyboard removed: %" SDL_PRIu32, event.kdevice.which);
break;
case SDL_EVENT_MOUSE_ADDED:
SDL_Log("Mouse '%s' added : %" SDL_PRIu32 "\n", SDL_GetMouseNameForID(event.mdevice.which), event.mdevice.which);
SDL_Log("Mouse '%s' added : %" SDL_PRIu32, SDL_GetMouseNameForID(event.mdevice.which), event.mdevice.which);
break;
case SDL_EVENT_MOUSE_REMOVED:
SDL_Log("Mouse removed: %" SDL_PRIu32 "\n", event.mdevice.which);
SDL_Log("Mouse removed: %" SDL_PRIu32, event.mdevice.which);
break;
case SDL_EVENT_JOYSTICK_ADDED:
if (joystick) {
SDL_Log("Only one joystick supported by this test\n");
SDL_Log("Only one joystick supported by this test");
} else {
joystick = SDL_OpenJoystick(event.jdevice.which);
instance = event.jdevice.which;
SDL_Log("Joy Added : %" SDL_PRIu32 " : %s\n", event.jdevice.which, SDL_GetJoystickName(joystick));
SDL_Log("Joy Added : %" SDL_PRIu32 " : %s", event.jdevice.which, SDL_GetJoystickName(joystick));
if (enable_haptic) {
if (SDL_IsJoystickHaptic(joystick)) {
haptic = SDL_OpenHapticFromJoystick(joystick);
if (haptic) {
SDL_Log("Joy Haptic Opened\n");
SDL_Log("Joy Haptic Opened");
if (!SDL_InitHapticRumble(haptic)) {
SDL_Log("Could not init Rumble!: %s\n", SDL_GetError());
SDL_Log("Could not init Rumble!: %s", SDL_GetError());
SDL_CloseHaptic(haptic);
haptic = NULL;
}
} else {
SDL_Log("Joy haptic open FAILED!: %s\n", SDL_GetError());
SDL_Log("Joy haptic open FAILED!: %s", SDL_GetError());
}
} else {
SDL_Log("No haptic found\n");
SDL_Log("No haptic found");
}
}
}
break;
case SDL_EVENT_JOYSTICK_REMOVED:
if (instance == event.jdevice.which) {
SDL_Log("Joy Removed: %" SDL_PRIs32 "\n", event.jdevice.which);
SDL_Log("Joy Removed: %" SDL_PRIs32, event.jdevice.which);
instance = 0;
if (enable_haptic && haptic) {
SDL_CloseHaptic(haptic);
@@ -145,29 +145,29 @@ int main(int argc, char *argv[])
SDL_CloseJoystick(joystick);
joystick = NULL;
} else {
SDL_Log("Unknown joystick disconnected\n");
SDL_Log("Unknown joystick disconnected");
}
break;
case SDL_EVENT_JOYSTICK_AXIS_MOTION:
/*
// SDL_Log("Axis Move: %d\n", event.jaxis.axis);
// SDL_Log("Axis Move: %d", event.jaxis.axis);
*/
if (enable_haptic) {
SDL_PlayHapticRumble(haptic, 0.25, 250);
}
break;
case SDL_EVENT_JOYSTICK_BUTTON_DOWN:
SDL_Log("Button Press: %d\n", event.jbutton.button);
SDL_Log("Button Press: %d", event.jbutton.button);
if (enable_haptic && haptic) {
SDL_PlayHapticRumble(haptic, 0.25, 250);
}
if (event.jbutton.button == 0) {
SDL_Log("Exiting due to button press of button 0\n");
SDL_Log("Exiting due to button press of button 0");
keepGoing = false;
}
break;
case SDL_EVENT_JOYSTICK_BUTTON_UP:
SDL_Log("Button Release: %d\n", event.jbutton.button);
SDL_Log("Button Release: %d", event.jbutton.button);
break;
default:
break;

View File

@@ -111,7 +111,7 @@ int main(int argc, char *argv[])
fname = GetResourceFilename(fname, "utf8.txt");
fdata = (Uint8 *) (fname ? SDL_LoadFile(fname, &fdatalen) : NULL);
if (!fdata) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to load %s\n", fname);
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to load %s", fname);
return 1;
}
@@ -126,7 +126,7 @@ int main(int argc, char *argv[])
test[0] = SDL_iconv_string(formats[i], "UCS-4", ucs4, len);
test[1] = SDL_iconv_string("UCS-4", formats[i], test[0], len);
if (!test[1] || SDL_memcmp(test[1], ucs4, len) != 0) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "FAIL: %s\n", formats[i]);
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "FAIL: %s", formats[i]);
++errors;
}
SDL_free(test[0]);
@@ -140,7 +140,7 @@ int main(int argc, char *argv[])
SDL_free(fdata);
SDL_free(fname);
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Total errors: %d\n", errors);
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Total errors: %d", errors);
SDL_Quit();
SDLTest_CommonDestroyState(state);
return errors ? errors + 1 : 0;

View File

@@ -163,7 +163,7 @@ static int unifont_init(const char *fontname)
/* Allocate memory for the glyph data so the file can be closed after initialization. */
unifontGlyph = (struct UnifontGlyph *)SDL_malloc(unifontGlyphSize);
if (!unifontGlyph) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Failed to allocate %d KiB for glyph data.\n", (int)(unifontGlyphSize + 1023) / 1024);
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Failed to allocate %d KiB for glyph data.", (int)(unifontGlyphSize + 1023) / 1024);
return -1;
}
SDL_memset(unifontGlyph, 0, unifontGlyphSize);
@@ -171,20 +171,20 @@ static int unifont_init(const char *fontname)
/* Allocate memory for texture pointers for all renderers. */
unifontTexture = (SDL_Texture **)SDL_malloc(unifontTextureSize);
if (!unifontTexture) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Failed to allocate %d KiB for texture pointer data.\n", (int)(unifontTextureSize + 1023) / 1024);
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Failed to allocate %d KiB for texture pointer data.", (int)(unifontTextureSize + 1023) / 1024);
return -1;
}
SDL_memset(unifontTexture, 0, unifontTextureSize);
filename = GetResourceFilename(NULL, fontname);
if (!filename) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory\n");
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory");
return -1;
}
hexFile = SDL_IOFromFile(filename, "rb");
SDL_free(filename);
if (!hexFile) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Failed to open font file: %s\n", fontname);
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Failed to open font file: %s", fontname);
return -1;
}
@@ -200,7 +200,7 @@ static int unifont_init(const char *fontname)
break; /* EOF */
}
if ((numGlyphs == 0 && bytesRead == 0) || (numGlyphs > 0 && bytesRead < 9)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Unexpected end of hex file.\n");
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Unexpected end of hex file.");
return -1;
}
@@ -214,16 +214,16 @@ static int unifont_init(const char *fontname)
} else if (hexBuffer[8] == ':') {
codepointHexSize = 8;
} else {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Could not find codepoint and glyph data separator symbol in hex file on line %d.\n", lineNumber);
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Could not find codepoint and glyph data separator symbol in hex file on line %d.", lineNumber);
return -1;
}
if (!validate_hex((const char *)hexBuffer, codepointHexSize, &codepoint)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Malformed hexadecimal number in hex file on line %d.\n", lineNumber);
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Malformed hexadecimal number in hex file on line %d.", lineNumber);
return -1;
}
if (codepoint > UNIFONT_MAX_CODEPOINT) {
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "unifont: Codepoint on line %d exceeded limit of 0x%x.\n", lineNumber, UNIFONT_MAX_CODEPOINT);
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "unifont: Codepoint on line %d exceeded limit of 0x%x.", lineNumber, UNIFONT_MAX_CODEPOINT);
}
/* If there was glyph data read in the last file read, move it to the front of the buffer. */
@@ -234,7 +234,7 @@ static int unifont_init(const char *fontname)
bytesRead = SDL_ReadIO(hexFile, hexBuffer + bytesOverread, 33 - bytesOverread);
if (bytesRead < (33 - bytesOverread)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Unexpected end of hex file.\n");
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Unexpected end of hex file.");
return -1;
}
if (hexBuffer[32] == '\n') {
@@ -243,19 +243,19 @@ static int unifont_init(const char *fontname)
glyphWidth = 16;
bytesRead = SDL_ReadIO(hexFile, hexBuffer + 33, 32);
if (bytesRead < 32) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Unexpected end of hex file.\n");
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Unexpected end of hex file.");
return -1;
}
}
if (!validate_hex((const char *)hexBuffer, glyphWidth * 4, NULL)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Malformed hexadecimal glyph data in hex file on line %d.\n", lineNumber);
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Malformed hexadecimal glyph data in hex file on line %d.", lineNumber);
return -1;
}
if (codepoint <= UNIFONT_MAX_CODEPOINT) {
if (unifontGlyph[codepoint].width > 0) {
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "unifont: Ignoring duplicate codepoint 0x%08" SDL_PRIx32 " in hex file on line %d.\n", codepoint, lineNumber);
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "unifont: Ignoring duplicate codepoint 0x%08" SDL_PRIx32 " in hex file on line %d.", codepoint, lineNumber);
} else {
unifontGlyph[codepoint].width = glyphWidth;
/* Pack the hex data into a more compact form. */
@@ -270,7 +270,7 @@ static int unifont_init(const char *fontname)
} while (bytesRead > 0);
SDL_CloseIO(hexFile);
SDL_Log("unifont: Loaded %" SDL_PRIu32 " glyphs.\n", numGlyphs);
SDL_Log("unifont: Loaded %" SDL_PRIu32 " glyphs.", numGlyphs);
return 0;
}
@@ -310,13 +310,13 @@ static int unifont_load_texture(Uint32 textureID)
Uint8 *textureRGBA;
if (textureID >= UNIFONT_NUM_TEXTURES) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Tried to load out of range texture %" SDL_PRIu32 "\n", textureID);
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Tried to load out of range texture %" SDL_PRIu32, textureID);
return -1;
}
textureRGBA = (Uint8 *)SDL_malloc(UNIFONT_TEXTURE_SIZE);
if (!textureRGBA) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Failed to allocate %d MiB for a texture.\n", UNIFONT_TEXTURE_SIZE / 1024 / 1024);
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Failed to allocate %d MiB for a texture.", UNIFONT_TEXTURE_SIZE / 1024 / 1024);
return -1;
}
SDL_memset(textureRGBA, 0, UNIFONT_TEXTURE_SIZE);
@@ -340,13 +340,13 @@ static int unifont_load_texture(Uint32 textureID)
}
tex = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STATIC, UNIFONT_TEXTURE_WIDTH, UNIFONT_TEXTURE_WIDTH);
if (tex == NULL) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Failed to create texture %" SDL_PRIu32 " for renderer %d.\n", textureID, i);
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Failed to create texture %" SDL_PRIu32 " for renderer %d.", textureID, i);
return -1;
}
unifontTexture[UNIFONT_NUM_TEXTURES * i + textureID] = tex;
SDL_SetTextureBlendMode(tex, SDL_BLENDMODE_BLEND);
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_Log("unifont error: Failed to update texture %" SDL_PRIu32 " data for renderer %d.", textureID, i);
}
}
@@ -970,7 +970,7 @@ int main(int argc, char *argv[])
windowstate = (WindowState *)SDL_calloc(state->num_windows, sizeof(*windowstate));
if (!windowstate) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't allocate window state: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't allocate window state: %s", SDL_GetError());
return -1;
}
@@ -980,7 +980,7 @@ int main(int argc, char *argv[])
return -1;
}
SDL_Log("Using font: %s\n", fontname);
SDL_Log("Using font: %s", fontname);
/* Initialize window state */
for (i = 0; i < state->num_windows; ++i) {
@@ -1082,7 +1082,7 @@ int main(int argc, char *argv[])
break;
}
SDL_Log("Keyboard: scancode 0x%08X = %s, keycode 0x%08" SDL_PRIX32 " = %s\n",
SDL_Log("Keyboard: scancode 0x%08X = %s, keycode 0x%08" SDL_PRIX32 " = %s",
event.key.scancode,
SDL_GetScancodeName(event.key.scancode),
SDL_static_cast(Uint32, event.key.key),
@@ -1099,13 +1099,13 @@ int main(int argc, char *argv[])
break;
}
SDL_Log("Keyboard: text input \"%s\"\n", event.text.text);
SDL_Log("Keyboard: text input \"%s\"", event.text.text);
if (SDL_strlen(ctx->text) + SDL_strlen(event.text.text) < sizeof(ctx->text)) {
SDL_strlcat(ctx->text, event.text.text, sizeof(ctx->text));
}
SDL_Log("text inputted: %s\n", ctx->text);
SDL_Log("text inputted: %s", ctx->text);
/* After text inputted, we can clear up markedText because it */
/* is committed */
@@ -1118,7 +1118,7 @@ int main(int argc, char *argv[])
break;
}
SDL_Log("text editing \"%s\", selected range (%" SDL_PRIs32 ", %" SDL_PRIs32 ")\n",
SDL_Log("text editing \"%s\", selected range (%" SDL_PRIs32 ", %" SDL_PRIs32 ")",
event.edit.text, event.edit.start, event.edit.length);
SDL_strlcpy(ctx->markedText, event.edit.text, sizeof(ctx->markedText));
@@ -1132,9 +1132,9 @@ int main(int argc, char *argv[])
break;
}
SDL_Log("text candidates:\n");
SDL_Log("text candidates:");
for (i = 0; i < event.edit_candidates.num_candidates; ++i) {
SDL_Log("%c%s\n", i == event.edit_candidates.selected_candidate ? '>' : ' ', event.edit_candidates.candidates[i]);
SDL_Log("%c%s", i == event.edit_candidates.selected_candidate ? '>' : ' ', event.edit_candidates.candidates[i]);
}
ClearCandidates(ctx);

View File

@@ -92,7 +92,7 @@ static int add_line(float x1, float y1, float x2, float y2)
return 0;
}
SDL_Log("adding line (%g, %g), (%g, %g)\n", x1, y1, x2, y2);
SDL_Log("adding line (%g, %g), (%g, %g)", x1, y1, x2, y2);
lines[num_lines].x = x1;
lines[num_lines].y = y1;
lines[num_lines].w = x2;
@@ -142,7 +142,7 @@ static int add_rect(float x1, float y1, float x2, float y2)
SWAP(float, y1, y2);
}
SDL_Log("adding rect (%g, %g), (%g, %g) [%gx%g]\n", x1, y1, x2, y2,
SDL_Log("adding rect (%g, %g), (%g, %g) [%gx%g]", x1, y1, x2, y2,
x2 - x1, y2 - y1);
rects[num_rects].x = x1;
@@ -385,7 +385,7 @@ int main(int argc, char *argv[])
if (now > then) {
double fps = ((double)frames * 1000) / (now - then);
SDL_Log("%2.2f frames per second\n", fps);
SDL_Log("%2.2f frames per second", fps);
}
return 0;
}

View File

@@ -35,11 +35,11 @@ int main(int argc, char *argv[])
}
if (!SDL_Init(SDL_INIT_VIDEO)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s", SDL_GetError());
exit(1);
}
for (scancode = 0; scancode < SDL_SCANCODE_COUNT; ++scancode) {
SDL_Log("Scancode #%d, \"%s\"\n", scancode,
SDL_Log("Scancode #%d, \"%s\"", scancode,
SDL_GetScancodeName(scancode));
}
SDL_Quit();

View File

@@ -24,8 +24,8 @@ typedef int (*fntype)(const char *);
static void log_usage(char *progname, SDLTest_CommonState *state) {
static const char *options[] = { "library", "functionname|--hello", NULL };
SDLTest_CommonLogUsage(state, progname, options);
SDL_Log("USAGE: %s <library> <functionname>\n", progname);
SDL_Log(" %s <lib with puts()> --hello\n", progname);
SDL_Log("USAGE: %s <library> <functionname>", progname);
SDL_Log(" %s <lib with puts()> --hello", progname);
}
int main(int argc, char *argv[])
@@ -80,28 +80,28 @@ int main(int argc, char *argv[])
/* Initialize SDL */
if (!SDL_Init(0)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s", SDL_GetError());
return 2;
}
lib = SDL_LoadObject(libname);
if (!lib) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_LoadObject('%s') failed: %s\n",
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_LoadObject('%s') failed: %s",
libname, SDL_GetError());
result = 3;
} else {
fn = (fntype)SDL_LoadFunction(lib, symname);
if (!fn) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_LoadFunction('%s') failed: %s\n",
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_LoadFunction('%s') failed: %s",
symname, SDL_GetError());
result = 4;
} else {
SDL_Log("Found %s in %s at %p\n", symname, libname, fn);
SDL_Log("Found %s in %s at %p", symname, libname, fn);
if (hello) {
SDL_Log("Calling function...\n");
SDL_Log("Calling function...");
fn(" HELLO, WORLD!\n");
SDL_Log("...apparently, we survived. :)\n");
SDL_Log("Unloading library...\n");
SDL_Log("...apparently, we survived. :)");
SDL_Log("Unloading library...");
}
}
SDL_UnloadObject(lib);

View File

@@ -42,7 +42,7 @@ SDL_Quit_Wrapper(void)
static void printid(void)
{
SDL_Log("Thread %" SDL_PRIu64 ": exiting\n", SDL_GetCurrentThreadID());
SDL_Log("Thread %" SDL_PRIu64 ": exiting", SDL_GetCurrentThreadID());
}
static void terminate(int sig)
@@ -55,7 +55,7 @@ static void closemutex(int sig)
{
SDL_ThreadID id = SDL_GetCurrentThreadID();
int i;
SDL_Log("Thread %" SDL_PRIu64 ": Cleaning up...\n", id == mainthread ? 0 : id);
SDL_Log("Thread %" SDL_PRIu64 ": Cleaning up...", id == mainthread ? 0 : id);
SDL_SetAtomicInt(&doterminate, 1);
if (threads) {
for (i = 0; i < nb_threads; ++i) {
@@ -81,21 +81,21 @@ Run(void *data)
}
SDL_Log("Thread %" SDL_PRIu64 ": starting up", current_thread);
while (!SDL_GetAtomicInt(&doterminate)) {
SDL_Log("Thread %" SDL_PRIu64 ": ready to work\n", current_thread);
SDL_Log("Thread %" SDL_PRIu64 ": ready to work", current_thread);
SDL_LockMutex(mutex);
SDL_Log("Thread %" SDL_PRIu64 ": start work!\n", current_thread);
SDL_Log("Thread %" SDL_PRIu64 ": start work!", current_thread);
SDL_Delay(1 * worktime);
SDL_Log("Thread %" SDL_PRIu64 ": work done!\n", current_thread);
SDL_Log("Thread %" SDL_PRIu64 ": work done!", current_thread);
SDL_UnlockMutex(mutex);
/* If this sleep isn't done, then threads may starve */
SDL_Delay(10);
}
if (current_thread == mainthread && SDL_GetAtomicInt(&doterminate)) {
SDL_Log("Thread %" SDL_PRIu64 ": raising SIGTERM\n", current_thread);
SDL_Log("Thread %" SDL_PRIu64 ": raising SIGTERM", current_thread);
(void)raise(SIGTERM);
}
SDL_Log("Thread %" SDL_PRIu64 ": exiting!\n", current_thread);
SDL_Log("Thread %" SDL_PRIu64 ": exiting!", current_thread);
return 0;
}
@@ -174,7 +174,7 @@ int main(int argc, char *argv[])
/* Load the SDL library */
if (!SDL_Init(0)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s", SDL_GetError());
exit(1);
}
(void)atexit(SDL_Quit_Wrapper);
@@ -183,19 +183,19 @@ int main(int argc, char *argv[])
mutex = SDL_CreateMutex();
if (!mutex) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create mutex: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create mutex: %s", SDL_GetError());
exit(1);
}
mainthread = SDL_GetCurrentThreadID();
SDL_Log("Main thread: %" SDL_PRIu64 "\n", mainthread);
SDL_Log("Main thread: %" SDL_PRIu64, mainthread);
(void)atexit(printid);
for (i = 0; i < nb_threads; ++i) {
char name[64];
(void)SDL_snprintf(name, sizeof(name), "Worker%d", i);
threads[i] = SDL_CreateThread(Run, name, NULL);
if (threads[i] == NULL) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread!\n");
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread!");
}
}

View File

@@ -64,7 +64,7 @@ button_messagebox(void *eventNumber)
success = SDL_ShowMessageBox(&data, &button);
if (success == -1) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s", SDL_GetError());
if (eventNumber) {
SDL_Event event;
event.type = (Uint32)(intptr_t)eventNumber;
@@ -74,7 +74,7 @@ button_messagebox(void *eventNumber)
quit(2);
}
}
SDL_Log("Pressed button: %d, %s\n", button, button == -1 ? "[closed]" : button == 1 ? "Cancel"
SDL_Log("Pressed button: %d, %s", button, button == -1 ? "[closed]" : button == 1 ? "Cancel"
: "OK");
if (eventNumber) {
@@ -107,7 +107,7 @@ int main(int argc, char *argv[])
"This is a simple error MessageBox",
NULL);
if (!success) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s", SDL_GetError());
quit(1);
}
@@ -116,7 +116,7 @@ int main(int argc, char *argv[])
"This is a simple MessageBox with a newline:\r\nHello world!",
NULL);
if (!success) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s", SDL_GetError());
quit(1);
}
@@ -125,7 +125,7 @@ int main(int argc, char *argv[])
"NULL Title",
NULL);
if (!success) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s", SDL_GetError());
quit(1);
}
@@ -134,7 +134,7 @@ int main(int argc, char *argv[])
NULL,
NULL);
if (!success) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s", SDL_GetError());
quit(1);
}
@@ -144,7 +144,7 @@ int main(int argc, char *argv[])
"Unicode text: '牛肉西蘭花' ...",
NULL);
if (!success) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s", SDL_GetError());
quit(1);
}
@@ -154,7 +154,7 @@ int main(int argc, char *argv[])
"Unicode text and newline:\r\n'牛肉西蘭花'\n'牛肉西蘭花'",
NULL);
if (!success) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s", SDL_GetError());
quit(1);
}
@@ -164,7 +164,7 @@ int main(int argc, char *argv[])
"Unicode text in the title.",
NULL);
if (!success) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s", SDL_GetError());
quit(1);
}
@@ -177,7 +177,7 @@ int main(int argc, char *argv[])
subsystem on the main thread.
*/
if (!SDL_Init(SDL_INIT_VIDEO)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL video subsystem: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL video subsystem: %s", SDL_GetError());
return 1;
}
{
@@ -194,7 +194,7 @@ int main(int argc, char *argv[])
SDL_WaitThread(thread, &status);
SDL_Log("Message box thread return %i\n", status);
SDL_Log("Message box thread return %i", status);
}
/* Test showing a message box with a parent window */
@@ -213,7 +213,7 @@ int main(int argc, char *argv[])
"This is a simple error MessageBox with a parent window. Press a key or close the window after dismissing this messagebox.",
window);
if (!success) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s", SDL_GetError());
quit(1);
}

View File

@@ -52,13 +52,13 @@ int main(int argc, char *argv[])
}
if (!SDL_CreateWindowAndRenderer("Parent Window", 640, 480, 0, &w1, &r1)) {
SDL_Log("Failed to create parent window and/or renderer: %s\n", SDL_GetError());
SDL_Log("Failed to create parent window and/or renderer: %s", SDL_GetError());
exit_code = 1;
goto sdl_quit;
}
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());
SDL_Log("Failed to create parent window and/or renderer: %s", SDL_GetError());
exit_code = 1;
goto sdl_quit;
}
@@ -91,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)) {
SDL_Log("Failed to create modal window and/or renderer: %s\n", SDL_GetError());
SDL_Log("Failed to create modal window and/or renderer: %s", SDL_GetError());
exit_code = 1;
goto sdl_quit;
}

View File

@@ -295,7 +295,7 @@ int main(int argc, char *argv[])
/* Initialize SDL (Note: video is required to start event loop) */
if (!SDL_Init(SDL_INIT_VIDEO)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s", SDL_GetError());
exit(1);
}
@@ -313,7 +313,7 @@ int main(int argc, char *argv[])
window = SDL_CreateWindow("Mouse Test", SCREEN_WIDTH, SCREEN_HEIGHT, 0);
#endif
if (!window) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window: %s", SDL_GetError());
return 0;
}
@@ -321,7 +321,7 @@ int main(int argc, char *argv[])
loop_data.renderer = SDL_CreateRenderer(window, NULL);
if (!loop_data.renderer) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s", SDL_GetError());
SDL_DestroyWindow(window);
return 0;
}

View File

@@ -86,7 +86,7 @@ test_multi_audio(const SDL_AudioDeviceID *devices, int devcount)
}
/* note that Emscripten currently doesn't run this part (but maybe only has a single audio device anyhow?) */
SDL_Log("Playing on all devices...\n");
SDL_Log("Playing on all devices...");
streams = (SDL_AudioStream **) SDL_calloc(devcount, sizeof (SDL_AudioStream *));
if (!streams) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!");
@@ -130,7 +130,7 @@ test_multi_audio(const SDL_AudioDeviceID *devices, int devcount)
SDL_free(streams);
}
SDL_Log("All done!\n");
SDL_Log("All done!");
}
int main(int argc, char **argv)
@@ -169,11 +169,11 @@ int main(int argc, char **argv)
/* Load the SDL library */
if (!SDLTest_CommonInit(state)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s", SDL_GetError());
return 1;
}
SDL_Log("Using audio driver: %s\n", SDL_GetCurrentAudioDriver());
SDL_Log("Using audio driver: %s", SDL_GetCurrentAudioDriver());
filename = GetResourceFilename(filename, "sample.wav");
@@ -186,7 +186,7 @@ int main(int argc, char **argv)
test_multi_audio(devices, devcount);
SDL_free(sound);
} else {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", filename,
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", filename,
SDL_GetError());
}
SDL_free(devices);

View File

@@ -120,7 +120,7 @@ int main(int argc, char *argv[])
}
if (!SDL_Init(SDL_INIT_VIDEO)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL video: %s\n",
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL video: %s",
SDL_GetError());
exit(1);
}
@@ -134,14 +134,14 @@ int main(int argc, char *argv[])
}
}
if (!factory) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't find native window code for %s driver\n",
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't find native window code for %s driver",
driver);
quit(2);
}
SDL_Log("Creating native window for %s driver\n", driver);
SDL_Log("Creating native window for %s driver", driver);
native_window = factory->CreateNativeWindow(WINDOW_W, WINDOW_H);
if (!native_window) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create native window\n");
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create native window");
quit(3);
}
props = SDL_CreateProperties();
@@ -152,7 +152,7 @@ int main(int argc, char *argv[])
window = SDL_CreateWindowWithProperties(props);
SDL_DestroyProperties(props);
if (!window) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create SDL window: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create SDL window: %s", SDL_GetError());
quit(4);
}
SDL_SetWindowTitle(window, "SDL Native Window Test");
@@ -160,7 +160,7 @@ int main(int argc, char *argv[])
/* Create the renderer */
renderer = SDL_CreateRenderer(window, NULL);
if (!renderer) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s", SDL_GetError());
quit(5);
}
@@ -178,7 +178,7 @@ int main(int argc, char *argv[])
positions = (SDL_FRect *)SDL_malloc(NUM_SPRITES * sizeof(*positions));
velocities = (SDL_FRect *)SDL_malloc(NUM_SPRITES * sizeof(*velocities));
if (!positions || !velocities) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n");
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!");
quit(2);
}
for (i = 0; i < NUM_SPRITES; ++i) {

View File

@@ -108,7 +108,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)) {
SDL_Log("Couldn't initialize the offscreen video driver: %s\n",
SDL_Log("Couldn't initialize the offscreen video driver: %s",
SDL_GetError());
return 1;
}
@@ -117,14 +117,14 @@ int main(int argc, char *argv[])
window = SDL_CreateWindow("Offscreen Test", width, height, 0);
if (!window) {
SDL_Log("Couldn't create window: %s\n", SDL_GetError());
SDL_Log("Couldn't create window: %s", SDL_GetError());
return 1;
}
renderer = SDL_CreateRenderer(window, NULL);
if (!renderer) {
SDL_Log("Couldn't create renderer: %s\n",
SDL_Log("Couldn't create renderer: %s",
SDL_GetError());
return 1;
}
@@ -138,7 +138,7 @@ int main(int argc, char *argv[])
done = 0;
#endif
SDL_Log("Rendering %u frames offscreen\n", max_frames);
SDL_Log("Rendering %u frames offscreen", max_frames);
#ifdef SDL_PLATFORM_EMSCRIPTEN
emscripten_set_main_loop(loop, 0, 1);
@@ -152,7 +152,7 @@ int main(int argc, char *argv[])
now = SDL_GetTicks();
if (now > then) {
double fps = ((double)frames * 1000) / (now - then);
SDL_Log("Frames remaining: %" SDL_PRIu32 " rendering at %2.2f frames per second\n", max_frames - frames, fps);
SDL_Log("Frames remaining: %" SDL_PRIu32 " rendering at %2.2f frames per second", max_frames - frames, fps);
}
}
}

View File

@@ -311,7 +311,7 @@ static void loop(void)
/* Print out some timing information */
const Uint64 then = next_fps_check - fps_check_delay;
const double fps = ((double)frames * 1000) / (now - then);
SDL_Log("%2.2f frames per second\n", fps);
SDL_Log("%2.2f frames per second", fps);
next_fps_check = now + fps_check_delay;
frames = 0;
}
@@ -347,15 +347,15 @@ int main(int argc, char **argv)
consumed = 2;
fps = SDL_atoi(argv[i + 1]);
if (fps == 0) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "The --fps option requires an argument [from 1 to 1000], default is 12.\n");
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "The --fps option requires an argument [from 1 to 1000], default is 12.");
quit(10);
}
if ((fps < 0) || (fps > 1000)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "The --fps option must be in range from 1 to 1000, default is 12.\n");
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "The --fps option must be in range from 1 to 1000, default is 12.");
quit(10);
}
} else {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "The --fps option requires an argument [from 1 to 1000], default is 12.\n");
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "The --fps option requires an argument [from 1 to 1000], default is 12.");
quit(10);
}
} else if (SDL_strcmp(argv[i], "--nodelay") == 0) {
@@ -369,15 +369,15 @@ int main(int argc, char **argv)
if (argv[i + 1]) {
scale = SDL_atoi(argv[i + 1]);
if (scale == 0) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "The --scale option requires an argument [from 1 to 50], default is 5.\n");
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "The --scale option requires an argument [from 1 to 50], default is 5.");
quit(10);
}
if ((scale < 0) || (scale > 50)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "The --scale option must be in range from 1 to 50, default is 5.\n");
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "The --scale option must be in range from 1 to 50, default is 5.");
quit(10);
}
} else {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "The --fps option requires an argument [from 1 to 1000], default is 12.\n");
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "The --fps option requires an argument [from 1 to 1000], default is 12.");
quit(10);
}
} else if (SDL_strcmp(argv[i], "--yuvformat") == 0) {
@@ -400,11 +400,11 @@ int main(int argc, char **argv)
} else if (SDL_strcmp(fmt, "NV21") == 0) {
yuv_format = SDL_PIXELFORMAT_NV21;
} else {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "The --yuvformat option requires one of the: YV12 (default), IYUV, YUY2, UYVY, YVYU, NV12, NV21)\n");
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "The --yuvformat option requires one of the: YV12 (default), IYUV, YUY2, UYVY, YVYU, NV12, NV21)");
quit(10);
}
} else {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "The --yuvformat option requires one of the: YV12 (default), IYUV, YUY2, UYVY, YVYU, NV12, NV21)\n");
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "The --yuvformat option requires one of the: YV12 (default), IYUV, YUY2, UYVY, YVYU, NV12, NV21)");
quit(10);
}
}
@@ -435,20 +435,20 @@ int main(int argc, char **argv)
RawMooseData = (Uint8 *)SDL_malloc(MOOSEFRAME_SIZE * MOOSEFRAMES_COUNT);
if (!RawMooseData) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't allocate memory for movie !\n");
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't allocate memory for movie !");
quit(1);
}
/* load the trojan moose images */
filename = GetResourceFilename(NULL, "moose.dat");
if (!filename) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory\n");
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory");
quit(2);
}
handle = SDL_IOFromFile(filename, "rb");
SDL_free(filename);
if (!handle) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't find the file moose.dat !\n");
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't find the file moose.dat !");
quit(2);
}
@@ -461,7 +461,7 @@ int main(int argc, char **argv)
window_h = MOOSEPIC_H * scale;
if (state->num_windows != 1) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Only one window allowed\n");
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Only one window allowed");
quit(1);
}
@@ -471,7 +471,7 @@ int main(int argc, char **argv)
if (streaming) {
MooseTexture = SDL_CreateTexture(renderer, yuv_format, SDL_TEXTUREACCESS_STREAMING, MOOSEPIC_W, MOOSEPIC_H);
if (!MooseTexture) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create texture: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create texture: %s", SDL_GetError());
quit(5);
}
}

View File

@@ -50,36 +50,36 @@ static int TestTypes(bool verbose)
if (badsize(sizeof(bool), 1)) {
if (verbose) {
SDL_Log("sizeof(bool) != 1, instead = %u\n", (unsigned int)sizeof(bool));
SDL_Log("sizeof(bool) != 1, instead = %u", (unsigned int)sizeof(bool));
}
++error;
}
if (badsize(sizeof(Uint8), 1)) {
if (verbose) {
SDL_Log("sizeof(Uint8) != 1, instead = %u\n", (unsigned int)sizeof(Uint8));
SDL_Log("sizeof(Uint8) != 1, instead = %u", (unsigned int)sizeof(Uint8));
}
++error;
}
if (badsize(sizeof(Uint16), 2)) {
if (verbose) {
SDL_Log("sizeof(Uint16) != 2, instead = %u\n", (unsigned int)sizeof(Uint16));
SDL_Log("sizeof(Uint16) != 2, instead = %u", (unsigned int)sizeof(Uint16));
}
++error;
}
if (badsize(sizeof(Uint32), 4)) {
if (verbose) {
SDL_Log("sizeof(Uint32) != 4, instead = %u\n", (unsigned int)sizeof(Uint32));
SDL_Log("sizeof(Uint32) != 4, instead = %u", (unsigned int)sizeof(Uint32));
}
++error;
}
if (badsize(sizeof(Uint64), 8)) {
if (verbose) {
SDL_Log("sizeof(Uint64) != 8, instead = %u\n", (unsigned int)sizeof(Uint64));
SDL_Log("sizeof(Uint64) != 8, instead = %u", (unsigned int)sizeof(Uint64));
}
++error;
}
if (verbose && !error) {
SDL_Log("All data types are the expected size.\n");
SDL_Log("All data types are the expected size.");
}
return error ? 1 : 0;
@@ -112,7 +112,7 @@ static int TestEndian(bool verbose)
value_double.d = 3.141593;
if (verbose) {
SDL_Log("Detected a %s endian machine.\n",
SDL_Log("Detected a %s endian machine.",
(SDL_BYTEORDER == SDL_LIL_ENDIAN) ? "little" : "big");
}
if ((*((char *)&value) >> 4) == 0x1) {
@@ -122,13 +122,13 @@ static int TestEndian(bool verbose)
}
if (real_byteorder != SDL_BYTEORDER) {
if (verbose) {
SDL_Log("Actually a %s endian machine!\n",
SDL_Log("Actually a %s endian machine!",
(real_byteorder == SDL_LIL_ENDIAN) ? "little" : "big");
}
++error;
}
if (verbose) {
SDL_Log("Detected a %s endian float word order machine.\n",
SDL_Log("Detected a %s endian float word order machine.",
(SDL_FLOATWORDORDER == SDL_LIL_ENDIAN) ? "little" : "big");
}
if (value_double.ui32[0] == 0x82c2bd7f && value_double.ui32[1] == 0x400921fb) {
@@ -138,40 +138,40 @@ static int TestEndian(bool verbose)
}
if (real_floatwordorder != SDL_FLOATWORDORDER) {
if (verbose) {
SDL_Log("Actually a %s endian float word order machine!\n",
SDL_Log("Actually a %s endian float word order machine!",
(real_floatwordorder == SDL_LIL_ENDIAN) ? "little" : (real_floatwordorder == SDL_BIG_ENDIAN) ? "big"
: "unknown");
}
++error;
}
if (verbose) {
SDL_Log("Value 16 = 0x%X, swapped = 0x%X\n", value16,
SDL_Log("Value 16 = 0x%X, swapped = 0x%X", value16,
SDL_Swap16(value16));
}
if (SDL_Swap16(value16) != swapped16) {
if (verbose) {
SDL_Log("16 bit value swapped incorrectly!\n");
SDL_Log("16 bit value swapped incorrectly!");
}
++error;
}
if (verbose) {
SDL_Log("Value 32 = 0x%" SDL_PRIX32 ", swapped = 0x%" SDL_PRIX32 "\n",
SDL_Log("Value 32 = 0x%" SDL_PRIX32 ", swapped = 0x%" SDL_PRIX32,
value32,
SDL_Swap32(value32));
}
if (SDL_Swap32(value32) != swapped32) {
if (verbose) {
SDL_Log("32 bit value swapped incorrectly!\n");
SDL_Log("32 bit value swapped incorrectly!");
}
++error;
}
if (verbose) {
SDL_Log("Value 64 = 0x%" SDL_PRIX64 ", swapped = 0x%" SDL_PRIX64 "\n", value64,
SDL_Log("Value 64 = 0x%" SDL_PRIX64 ", swapped = 0x%" SDL_PRIX64, value64,
SDL_Swap64(value64));
}
if (SDL_Swap64(value64) != swapped64) {
if (verbose) {
SDL_Log("64 bit value swapped incorrectly!\n");
SDL_Log("64 bit value swapped incorrectly!");
}
++error;
}
@@ -380,14 +380,14 @@ static int Test64Bit(bool verbose)
if (!t->routine(&t->a, &t->b, t->arg, &result, &t->expected_result)) {
if (verbose) {
SDL_Log("%s(0x%08X%08X, 0x%08X%08X, %3d, produced: 0x%08X%08X, expected: 0x%08X%08X\n", t->operation, al[1], al[0], bl[1], bl[0],
SDL_Log("%s(0x%08X%08X, 0x%08X%08X, %3d, produced: 0x%08X%08X, expected: 0x%08X%08X", t->operation, al[1], al[0], bl[1], bl[0],
t->arg, rl[1], rl[0], el[1], el[0]);
}
++failed;
}
}
if (verbose && (failed == 0)) {
SDL_Log("All 64bit intrinsic tests passed\n");
SDL_Log("All 64bit intrinsic tests passed");
}
return failed ? 1 : 0;
}
@@ -395,23 +395,23 @@ static int Test64Bit(bool verbose)
static int TestCPUInfo(bool verbose)
{
if (verbose) {
SDL_Log("Number of logical CPU cores: %d\n", SDL_GetNumLogicalCPUCores());
SDL_Log("CPU cache line size: %d\n", SDL_GetCPUCacheLineSize());
SDL_Log("AltiVec %s\n", SDL_HasAltiVec() ? "detected" : "not detected");
SDL_Log("MMX %s\n", SDL_HasMMX() ? "detected" : "not detected");
SDL_Log("SSE %s\n", SDL_HasSSE() ? "detected" : "not detected");
SDL_Log("SSE2 %s\n", SDL_HasSSE2() ? "detected" : "not detected");
SDL_Log("SSE3 %s\n", SDL_HasSSE3() ? "detected" : "not detected");
SDL_Log("SSE4.1 %s\n", SDL_HasSSE41() ? "detected" : "not detected");
SDL_Log("SSE4.2 %s\n", SDL_HasSSE42() ? "detected" : "not detected");
SDL_Log("AVX %s\n", SDL_HasAVX() ? "detected" : "not detected");
SDL_Log("AVX2 %s\n", SDL_HasAVX2() ? "detected" : "not detected");
SDL_Log("AVX-512F %s\n", SDL_HasAVX512F() ? "detected" : "not detected");
SDL_Log("ARM SIMD %s\n", SDL_HasARMSIMD() ? "detected" : "not detected");
SDL_Log("NEON %s\n", SDL_HasNEON() ? "detected" : "not detected");
SDL_Log("LSX %s\n", SDL_HasLSX() ? "detected" : "not detected");
SDL_Log("LASX %s\n", SDL_HasLASX() ? "detected" : "not detected");
SDL_Log("System RAM %d MB\n", SDL_GetSystemRAM());
SDL_Log("Number of logical CPU cores: %d", SDL_GetNumLogicalCPUCores());
SDL_Log("CPU cache line size: %d", SDL_GetCPUCacheLineSize());
SDL_Log("AltiVec %s", SDL_HasAltiVec() ? "detected" : "not detected");
SDL_Log("MMX %s", SDL_HasMMX() ? "detected" : "not detected");
SDL_Log("SSE %s", SDL_HasSSE() ? "detected" : "not detected");
SDL_Log("SSE2 %s", SDL_HasSSE2() ? "detected" : "not detected");
SDL_Log("SSE3 %s", SDL_HasSSE3() ? "detected" : "not detected");
SDL_Log("SSE4.1 %s", SDL_HasSSE41() ? "detected" : "not detected");
SDL_Log("SSE4.2 %s", SDL_HasSSE42() ? "detected" : "not detected");
SDL_Log("AVX %s", SDL_HasAVX() ? "detected" : "not detected");
SDL_Log("AVX2 %s", SDL_HasAVX2() ? "detected" : "not detected");
SDL_Log("AVX-512F %s", SDL_HasAVX512F() ? "detected" : "not detected");
SDL_Log("ARM SIMD %s", SDL_HasARMSIMD() ? "detected" : "not detected");
SDL_Log("NEON %s", SDL_HasNEON() ? "detected" : "not detected");
SDL_Log("LSX %s", SDL_HasLSX() ? "detected" : "not detected");
SDL_Log("LASX %s", SDL_HasLASX() ? "detected" : "not detected");
SDL_Log("System RAM %d MB", SDL_GetSystemRAM());
}
return 0;
}
@@ -434,7 +434,7 @@ static int TestAssertions(bool verbose)
{
const SDL_AssertData *item = SDL_GetAssertionReport();
while (item) {
SDL_Log("'%s', %s (%s:%d), triggered %u times, always ignore: %s.\n",
SDL_Log("'%s', %s (%s:%d), triggered %u times, always ignore: %s.",
item->condition, item->function, item->filename,
item->linenum, item->trigger_count,
item->always_ignore ? "yes" : "no");
@@ -478,7 +478,7 @@ int main(int argc, char *argv[])
}
if (verbose) {
SDL_Log("This system is running %s\n", SDL_GetPlatform());
SDL_Log("This system is running %s", SDL_GetPlatform());
}
status += TestTypes(verbose);

View File

@@ -22,7 +22,7 @@ report_power(void)
const SDL_PowerState state = SDL_GetPowerInfo(&seconds, &percent);
const char *statestr = NULL;
SDL_Log("SDL-reported power info...\n");
SDL_Log("SDL-reported power info...");
switch (state) {
case SDL_POWERSTATE_UNKNOWN:
statestr = "Unknown";
@@ -44,18 +44,18 @@ report_power(void)
break;
}
SDL_Log("State: %s\n", statestr);
SDL_Log("State: %s", statestr);
if (percent == -1) {
SDL_Log("Percent left: unknown\n");
SDL_Log("Percent left: unknown");
} else {
SDL_Log("Percent left: %d%%\n", percent);
SDL_Log("Percent left: %d%%", percent);
}
if (seconds == -1) {
SDL_Log("Time left: unknown\n");
SDL_Log("Time left: unknown");
} else {
SDL_Log("Time left: %d minutes, %d seconds\n", seconds / 60, seconds % 60);
SDL_Log("Time left: %d minutes, %d seconds", seconds / 60, seconds % 60);
}
}
@@ -75,7 +75,7 @@ int main(int argc, char *argv[])
}
if (!SDL_Init(0)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init() failed: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init() failed: %s", SDL_GetError());
return 1;
}

View File

@@ -91,7 +91,7 @@ int main(int argc, char *argv[])
seed_seen = 1;
consumed = 1;
} else {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Invalid seed. Use a decimal or hexadecimal number.\n");
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Invalid seed. Use a decimal or hexadecimal number.");
return 1;
}
}
@@ -108,7 +108,7 @@ int main(int argc, char *argv[])
if (!seed_seen) {
seed = SDL_GetPerformanceCounter();
}
SDL_Log("Using random seed 0x%" SDL_PRIx64 "\n", seed);
SDL_Log("Using random seed 0x%" SDL_PRIx64, seed);
for (iteration = 0; iteration < SDL_arraysize(itervals); iteration++) {
const int arraylen = itervals[iteration];

View File

@@ -161,7 +161,7 @@ int main(int argc, char *argv[])
now = SDL_GetTicks();
if (now > then) {
double fps = ((double)frames * 1000) / (now - then);
SDL_Log("%2.2f frames per second\n", fps);
SDL_Log("%2.2f frames per second", fps);
}
SDL_stack_free(drawstates);

View File

@@ -79,7 +79,7 @@ DrawComposite(DrawState *s)
if (surface) {
Uint8 r, g, b, a;
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_Log("Blended pixel: 0x%.2x%.2x%.2x%.2x", r, g, b, a);
}
SDL_DestroySurface(surface);
}
@@ -148,7 +148,7 @@ Draw(DrawState *s)
target = SDL_CreateTexture(s->renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_TARGET, viewport.w, viewport.h);
if (!target) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create render target texture: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create render target texture: %s", SDL_GetError());
return false;
}
SDL_SetRenderTarget(s->renderer, target);
@@ -283,7 +283,7 @@ int main(int argc, char *argv[])
now = SDL_GetTicks();
if (now > then) {
double fps = ((double)frames * 1000) / (now - then);
SDL_Log("%2.2f frames per second\n", fps);
SDL_Log("%2.2f frames per second", fps);
}
SDL_stack_free(drawstates);

View File

@@ -93,20 +93,20 @@ int main(int argc, char **argv)
}
if (!SDL_Init(SDL_INIT_AUDIO)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init() failed: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init() failed: %s", SDL_GetError());
ret = 2;
goto end;
}
if (!SDL_LoadWAV(file_in, &spec, &data, &len)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "failed to load %s: %s\n", file_in, SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "failed to load %s: %s", file_in, SDL_GetError());
ret = 3;
goto end;
}
cvtspec.format = spec.format;
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());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "failed to convert samples: %s", SDL_GetError());
ret = 4;
goto end;
}
@@ -114,7 +114,7 @@ int main(int argc, char **argv)
/* write out a WAV header... */
io = SDL_IOFromFile(file_out, "wb");
if (!io) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "opening '%s' failed: %s\n", file_out, SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "opening '%s' failed: %s", file_out, SDL_GetError());
ret = 5;
goto end;
}
@@ -139,7 +139,7 @@ int main(int argc, char **argv)
SDL_WriteIO(io, dst_buf, dst_len);
if (!SDL_CloseIO(io)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "closing '%s' failed: %s\n", file_out, SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "closing '%s' failed: %s", file_out, SDL_GetError());
ret = 6;
goto end;
}

View File

@@ -72,7 +72,7 @@ int main(int argc, char **argv)
if (consumed <= 0) {
static const char *options[] = { "[device]", NULL };
SDLTest_CommonLogUsage(state, argv[0], options);
SDL_Log("\n");
SDL_Log("%s", "");
SDL_Log("If device is a two-digit number it'll use it as an index, otherwise\n"
"it'll use it as if it were part of the device's name.\n");
return 1;
@@ -84,9 +84,9 @@ int main(int argc, char **argv)
/* Initialize the force feedbackness */
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC);
haptics = SDL_GetHaptics(&num_haptics);
SDL_Log("%d Haptic devices detected.\n", num_haptics);
SDL_Log("%d Haptic devices detected.", num_haptics);
if (num_haptics == 0) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No Haptic devices found!\n");
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No Haptic devices found!");
SDL_free(haptics);
return 1;
}
@@ -96,7 +96,7 @@ int main(int argc, char **argv)
i = (index != -1) ? index : 0;
if (i >= num_haptics) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Index out of range, aborting.\n");
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Index out of range, aborting.");
SDL_free(haptics);
return 1;
}
@@ -110,7 +110,7 @@ int main(int argc, char **argv)
}
if (i >= num_haptics) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to find device matching '%s', aborting.\n", name);
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to find device matching '%s', aborting.", name);
SDL_free(haptics);
return 1;
}
@@ -118,36 +118,36 @@ int main(int argc, char **argv)
haptic = SDL_OpenHaptic(haptics[i]);
if (!haptic) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create the haptic device: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create the haptic device: %s", SDL_GetError());
SDL_free(haptics);
return 1;
}
SDL_Log("Device: %s\n", SDL_GetHapticName(haptic));
SDL_Log("Device: %s", SDL_GetHapticName(haptic));
SDL_free(haptics);
/* We only want force feedback errors. */
SDL_ClearError();
if (!SDL_HapticRumbleSupported(haptic)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Rumble not supported!\n");
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Rumble not supported!");
return 1;
}
if (!SDL_InitHapticRumble(haptic)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to initialize rumble: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to initialize rumble: %s", SDL_GetError());
return 1;
}
SDL_Log("Playing 2 second rumble at 0.5 magnitude.\n");
SDL_Log("Playing 2 second rumble at 0.5 magnitude.");
if (!SDL_PlayHapticRumble(haptic, 0.5, 5000)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to play rumble: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to play rumble: %s", SDL_GetError());
return 1;
}
SDL_Delay(2000);
SDL_Log("Stopping rumble.\n");
SDL_Log("Stopping rumble.");
SDL_StopHapticRumble(haptic);
SDL_Delay(2000);
SDL_Log("Playing 2 second rumble at 0.3 magnitude.\n");
SDL_Log("Playing 2 second rumble at 0.3 magnitude.");
if (!SDL_PlayHapticRumble(haptic, 0.3f, 5000)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to play rumble: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to play rumble: %s", SDL_GetError());
return 1;
}
SDL_Delay(2000);

View File

@@ -34,16 +34,16 @@ static void DoWork(const int workticks) /* "Work" */
const bool is_reader = tid != mainthread;
const char *typestr = is_reader ? "Reader" : "Writer";
SDL_Log("%s Thread %" SDL_PRIu64 ": ready to work\n", typestr, tid);
SDL_Log("%s Thread %" SDL_PRIu64 ": ready to work", typestr, tid);
if (is_reader) {
SDL_LockRWLockForReading(rwlock);
} else {
SDL_LockRWLockForWriting(rwlock);
}
SDL_Log("%s Thread %" SDL_PRIu64 ": start work!\n", typestr, tid);
SDL_Log("%s Thread %" SDL_PRIu64 ": start work!", typestr, tid);
SDL_Delay(workticks);
SDL_Log("%s Thread %" SDL_PRIu64 ": work done!\n", typestr, tid);
SDL_Log("%s Thread %" SDL_PRIu64 ": work done!", typestr, tid);
SDL_UnlockRWLock(rwlock);
/* If this sleep isn't done, then threads may starve */
@@ -57,7 +57,7 @@ ReaderRun(void *data)
while (!SDL_GetAtomicInt(&doterminate)) {
DoWork(worktime);
}
SDL_Log("Reader Thread %" SDL_PRIu64 ": exiting!\n", SDL_GetCurrentThreadID());
SDL_Log("Reader Thread %" SDL_PRIu64 ": exiting!", SDL_GetCurrentThreadID());
return 0;
}
@@ -132,7 +132,7 @@ int main(int argc, char *argv[])
/* Load the SDL library */
if (!SDL_Init(0)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s", SDL_GetError());
return 1;
}
@@ -140,20 +140,20 @@ int main(int argc, char *argv[])
rwlock = SDL_CreateRWLock();
if (!rwlock) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create rwlock: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create rwlock: %s", SDL_GetError());
SDL_Quit();
SDLTest_CommonDestroyState(state);
return 1;
}
mainthread = SDL_GetCurrentThreadID();
SDL_Log("Writer thread: %" SDL_PRIu64 "\n", mainthread);
SDL_Log("Writer thread: %" SDL_PRIu64, mainthread);
for (i = 0; i < nb_threads; ++i) {
char name[64];
(void)SDL_snprintf(name, sizeof(name), "Reader%d", i);
threads[i] = SDL_CreateThread(ReaderRun, name, NULL);
if (threads[i] == NULL) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create reader thread! %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create reader thread! %s", SDL_GetError());
}
}

View File

@@ -153,7 +153,7 @@ int main(int argc, char *argv[])
now = SDL_GetTicks();
if (now > then) {
double fps = ((double)frames * 1000) / (now - then);
SDL_Log("%2.2f frames per second\n", fps);
SDL_Log("%2.2f frames per second", fps);
}
SDL_stack_free(drawstates);

View File

@@ -53,16 +53,16 @@ ThreadFuncRealWorld(void *data)
Thread_State *state = (Thread_State *)data;
while (alive) {
SDL_WaitSemaphore(sem);
SDL_Log("Thread number %d has got the semaphore (value = %" SDL_PRIu32 ")!\n",
SDL_Log("Thread number %d has got the semaphore (value = %" SDL_PRIu32 ")!",
state->number, SDL_GetSemaphoreValue(sem));
SDL_Delay(200);
SDL_SignalSemaphore(sem);
SDL_Log("Thread number %d has released the semaphore (value = %" SDL_PRIu32 ")!\n",
SDL_Log("Thread number %d has released the semaphore (value = %" SDL_PRIu32 ")!",
state->number, SDL_GetSemaphoreValue(sem));
++state->loop_count;
SDL_Delay(1); /* For the scheduler */
}
SDL_Log("Thread number %d exiting.\n", state->number);
SDL_Log("Thread number %d exiting.", state->number);
return 0;
}
@@ -75,7 +75,7 @@ TestRealWorld(int init_sem)
sem = SDL_CreateSemaphore(init_sem);
SDL_Log("Running %d threads, semaphore value = %d\n", NUM_THREADS,
SDL_Log("Running %d threads, semaphore value = %d", NUM_THREADS,
init_sem);
alive = 1;
/* Create all the threads */
@@ -90,14 +90,15 @@ TestRealWorld(int init_sem)
SDL_Delay(10 * 1000);
/* Wait for all threads to finish */
SDL_Log("Waiting for threads to finish\n");
SDL_Log("Waiting for threads to finish");
alive = 0;
loop_count = 0;
for (i = 0; i < NUM_THREADS; ++i) {
SDL_WaitThread(thread_states[i].thread, NULL);
loop_count += thread_states[i].loop_count;
}
SDL_Log("Finished waiting for threads, ran %d loops in total\n\n", loop_count);
SDL_Log("Finished waiting for threads, ran %d loops in total", loop_count);
SDL_Log("%s", "");
SDL_DestroySemaphore(sem);
}
@@ -111,7 +112,7 @@ TestWaitTimeout(void)
bool result;
sem = SDL_CreateSemaphore(0);
SDL_Log("Waiting 2 seconds on semaphore\n");
SDL_Log("Waiting 2 seconds on semaphore");
start_ticks = SDL_GetTicks();
result = SDL_WaitSemaphoreTimeout(sem, 2000);
@@ -120,12 +121,14 @@ TestWaitTimeout(void)
duration = end_ticks - start_ticks;
/* Accept a little offset in the effective wait */
SDL_Log("Wait took %" SDL_PRIu64 " milliseconds\n\n", duration);
SDL_Log("Wait took %" SDL_PRIu64 " milliseconds", duration);
SDL_Log("%s", "");
SDL_assert(duration > 1900 && duration < 2050);
/* Check to make sure the return value indicates timed out */
if (result) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_WaitSemaphoreTimeout returned: %d; expected: false\n\n", result);
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_WaitSemaphoreTimeout returned: %d; expected: false", result);
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s", "");
}
SDL_DestroySemaphore(sem);
@@ -140,7 +143,7 @@ TestOverheadUncontended(void)
int i, j;
sem = SDL_CreateSemaphore(0);
SDL_Log("Doing %d uncontended Post/Wait operations on semaphore\n", NUM_OVERHEAD_OPS * NUM_OVERHEAD_OPS_MULT);
SDL_Log("Doing %d uncontended Post/Wait operations on semaphore", NUM_OVERHEAD_OPS * NUM_OVERHEAD_OPS_MULT);
start_ticks = SDL_GetTicks();
for (i = 0; i < NUM_OVERHEAD_OPS_MULT; i++) {
@@ -154,7 +157,8 @@ TestOverheadUncontended(void)
end_ticks = SDL_GetTicks();
duration = end_ticks - start_ticks;
SDL_Log("Took %" SDL_PRIu64 " milliseconds\n\n", duration);
SDL_Log("Took %" SDL_PRIu64 " milliseconds", duration);
SDL_Log("%s", "");
SDL_DestroySemaphore(sem);
}
@@ -197,7 +201,7 @@ TestOverheadContended(bool try_wait)
size_t len;
sem = SDL_CreateSemaphore(0);
SDL_Log("Doing %d contended %s operations on semaphore using %d threads\n",
SDL_Log("Doing %d contended %s operations on semaphore using %d threads",
NUM_OVERHEAD_OPS * NUM_OVERHEAD_OPS_MULT, try_wait ? "Post/TryWait" : "Post/WaitTimeout", NUM_THREADS);
alive = 1;
/* Create multiple threads to starve the semaphore and cause contention */
@@ -232,7 +236,7 @@ TestOverheadContended(bool try_wait)
SDL_assert_release((loop_count - content_count) == NUM_OVERHEAD_OPS * NUM_OVERHEAD_OPS_MULT);
duration = end_ticks - start_ticks;
SDL_Log("Took %" SDL_PRIu64 " milliseconds, threads %s %d out of %d times in total (%.2f%%)\n",
SDL_Log("Took %" SDL_PRIu64 " milliseconds, threads %s %d out of %d times in total (%.2f%%)",
duration, try_wait ? "where contended" : "timed out", content_count,
loop_count, ((float)content_count * 100) / loop_count);
/* Print how many semaphores where consumed per thread */
@@ -246,8 +250,8 @@ TestOverheadContended(bool try_wait)
(void)SDL_snprintf(textBuffer + len, sizeof(textBuffer) - len, "%d", thread_states[i].loop_count - thread_states[i].content_count);
}
len = SDL_strlen(textBuffer);
(void)SDL_snprintf(textBuffer + len, sizeof(textBuffer) - len, " }\n");
SDL_Log("%s\n", textBuffer);
(void)SDL_snprintf(textBuffer + len, sizeof(textBuffer) - len, " }");
SDL_Log("%s", textBuffer);
SDL_DestroySemaphore(sem);
}
@@ -300,7 +304,7 @@ int main(int argc, char **argv)
/* Load the SDL library */
if (!SDL_Init(0)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s", SDL_GetError());
return 1;
}
(void)signal(SIGTERM, killed);

View File

@@ -39,19 +39,19 @@ static void HandleSensorEvent(SDL_SensorEvent *event)
{
SDL_Sensor *sensor = SDL_GetSensorFromID(event->which);
if (!sensor) {
SDL_Log("Couldn't get sensor for sensor event\n");
SDL_Log("Couldn't get sensor for sensor event");
return;
}
switch (SDL_GetSensorType(sensor)) {
case SDL_SENSOR_ACCEL:
SDL_Log("Accelerometer update: %.2f, %.2f, %.2f\n", event->data[0], event->data[1], event->data[2]);
SDL_Log("Accelerometer update: %.2f, %.2f, %.2f", event->data[0], event->data[1], event->data[2]);
break;
case SDL_SENSOR_GYRO:
SDL_Log("Gyro update: %.2f, %.2f, %.2f\n", event->data[0], event->data[1], event->data[2]);
SDL_Log("Gyro update: %.2f, %.2f, %.2f", event->data[0], event->data[1], event->data[2]);
break;
default:
SDL_Log("Sensor update for sensor type %s\n", GetSensorTypeString(SDL_GetSensorType(sensor)));
SDL_Log("Sensor update for sensor type %s", GetSensorTypeString(SDL_GetSensorType(sensor)));
break;
}
}
@@ -76,7 +76,7 @@ int main(int argc, char **argv)
/* Load the SDL library */
if (!SDL_Init(SDL_INIT_SENSOR)) {
SDL_Log("Couldn't initialize SDL: %s\n", SDL_GetError());
SDL_Log("Couldn't initialize SDL: %s", SDL_GetError());
SDL_Quit();
SDLTest_CommonDestroyState(state);
return 1;
@@ -85,10 +85,10 @@ int main(int argc, char **argv)
sensors = SDL_GetSensors(&num_sensors);
num_opened = 0;
SDL_Log("There are %d sensors available\n", num_sensors);
SDL_Log("There are %d sensors available", num_sensors);
if (sensors) {
for (i = 0; i < num_sensors; ++i) {
SDL_Log("Sensor %" SDL_PRIu32 ": %s, type %s, platform type %d\n",
SDL_Log("Sensor %" SDL_PRIu32 ": %s, type %s, platform type %d",
sensors[i],
SDL_GetSensorNameForID(sensors[i]),
GetSensorTypeString(SDL_GetSensorTypeForID(sensors[i])),
@@ -97,7 +97,7 @@ int main(int argc, char **argv)
if (SDL_GetSensorTypeForID(sensors[i]) != SDL_SENSOR_UNKNOWN) {
SDL_Sensor *sensor = SDL_OpenSensor(sensors[i]);
if (!sensor) {
SDL_Log("Couldn't open sensor %" SDL_PRIu32 ": %s\n", sensors[i], SDL_GetError());
SDL_Log("Couldn't open sensor %" SDL_PRIu32 ": %s", sensors[i], SDL_GetError());
} else {
++num_opened;
}
@@ -105,7 +105,7 @@ int main(int argc, char **argv)
}
SDL_free(sensors);
}
SDL_Log("Opened %d sensors\n", num_opened);
SDL_Log("Opened %d sensors", num_opened);
if (num_opened > 0) {
bool done = false;

View File

@@ -145,7 +145,9 @@ static bool CompileShader(GLhandleARB shader, const char *source)
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!");
} else {
pglGetInfoLogARB(shader, length, NULL, info);
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to compile shader:\n%s\n%s", source, info);
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to compile shader:");
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s", source);
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s", info);
SDL_free(info);
}
return false;
@@ -173,7 +175,8 @@ static bool LinkProgram(ShaderData *data)
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!");
} else {
pglGetInfoLogARB(data->program, length, NULL, info);
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to link program:\n%s", info);
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to link program:");
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s", info);
SDL_free(info);
}
return false;
@@ -279,7 +282,7 @@ static bool InitShaders(void)
/* Compile all the shaders */
for (i = 0; i < NUM_SHADERS; ++i) {
if (!CompileShaderProgram(&shaders[i])) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to compile shader!\n");
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to compile shader!");
return false;
}
}
@@ -480,20 +483,20 @@ int main(int argc, char **argv)
/* Initialize SDL for video output */
if (!SDL_Init(SDL_INIT_VIDEO)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to initialize SDL: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to initialize SDL: %s", SDL_GetError());
exit(1);
}
/* Create a 640x480 OpenGL screen */
window = SDL_CreateWindow("Shader Demo", 640, 480, SDL_WINDOW_OPENGL);
if (!window) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create OpenGL window: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create OpenGL window: %s", SDL_GetError());
SDL_Quit();
exit(2);
}
if (!SDL_GL_CreateContext(window)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create OpenGL context: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create OpenGL context: %s", SDL_GetError());
SDL_Quit();
exit(2);
}
@@ -503,7 +506,7 @@ int main(int argc, char **argv)
SDL_free(filename);
if (!surface) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to load icon.bmp: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to load icon.bmp: %s", SDL_GetError());
SDL_Quit();
exit(3);
}
@@ -513,9 +516,9 @@ int main(int argc, char **argv)
/* Loop, drawing and checking events */
InitGL(640, 480);
if (InitShaders()) {
SDL_Log("Shaders supported, press SPACE to cycle them.\n");
SDL_Log("Shaders supported, press SPACE to cycle them.");
} else {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Shaders not supported!\n");
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Shaders not supported!");
}
done = 0;
while (!done) {
@@ -549,7 +552,7 @@ int main(int argc, char **argv)
int main(int argc, char *argv[])
{
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No OpenGL support on this system\n");
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No OpenGL support on this system");
return 1;
}

View File

@@ -48,7 +48,7 @@ int main(int argc, char *argv[])
} else if (!image_file) {
image_file = argv[i];
} else {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Usage: %s [--resizable] [shape.bmp]\n", argv[0]);
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Usage: %s [--resizable] [shape.bmp]", argv[0]);
goto quit;
}
}
@@ -56,18 +56,18 @@ int main(int argc, char *argv[])
if (image_file) {
shape = SDL_LoadBMP(image_file);
if (!shape) {
SDL_Log("Couldn't load %s: %s\n", image_file, SDL_GetError());
SDL_Log("Couldn't load %s: %s", image_file, SDL_GetError());
goto quit;
}
} else {
SDL_IOStream *stream = SDL_IOFromConstMem(glass_bmp, sizeof(glass_bmp));
if (!stream) {
SDL_Log("Couldn't create iostream for glass.bmp: %s\n", SDL_GetError());
SDL_Log("Couldn't create iostream for glass.bmp: %s", SDL_GetError());
goto quit;
}
shape = SDL_LoadBMP_IO(stream, true);
if (!shape) {
SDL_Log("Couldn't load glass.bmp: %s\n", SDL_GetError());
SDL_Log("Couldn't load glass.bmp: %s", SDL_GetError());
goto quit;
}
}
@@ -81,13 +81,13 @@ int main(int argc, char *argv[])
}
window = SDL_CreateWindow("SDL Shape Test", shape->w, shape->h, flags);
if (!window) {
SDL_Log("Couldn't create transparent window: %s\n", SDL_GetError());
SDL_Log("Couldn't create transparent window: %s", SDL_GetError());
goto quit;
}
renderer = SDL_CreateRenderer(window, NULL);
if (!renderer) {
SDL_Log("Couldn't create renderer: %s\n", SDL_GetError());
SDL_Log("Couldn't create renderer: %s", SDL_GetError());
goto quit;
}
@@ -102,7 +102,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)) {
SDL_Log("Couldn't set hit test callback: %s\n", SDL_GetError());
SDL_Log("Couldn't set hit test callback: %s", SDL_GetError());
goto quit;
}
}

View File

@@ -67,7 +67,7 @@ static int LoadSprite(const char *file)
return -1;
}
if (!SDL_SetTextureBlendMode(sprites[i], blendMode)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set blend mode: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set blend mode: %s", SDL_GetError());
SDL_DestroyTexture(sprites[i]);
return -1;
}
@@ -502,7 +502,7 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
sprites =
(SDL_Texture **)SDL_malloc(state->num_windows * sizeof(*sprites));
if (!sprites) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n");
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!");
return SDL_APP_FAILURE;
}
for (i = 0; i < state->num_windows; ++i) {
@@ -518,7 +518,7 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
positions = (SDL_FRect *)SDL_malloc(num_sprites * sizeof(*positions));
velocities = (SDL_FRect *)SDL_malloc(num_sprites * sizeof(*velocities));
if (!positions || !velocities) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n");
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!");
return SDL_APP_FAILURE;
}
@@ -588,7 +588,7 @@ SDL_AppResult SDL_AppIterate(void *appstate)
/* Print out some timing information */
const Uint64 then = next_fps_check - fps_check_delay;
const double fps = ((double)frames * 1000) / (now - then);
SDL_Log("%2.2f frames per second\n", fps);
SDL_Log("%2.2f frames per second", fps);
next_fps_check = now + fps_check_delay;
frames = 0;
}

View File

@@ -113,7 +113,7 @@ int main(int argc, char *argv[])
int i;
if (argc > 1) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "USAGE: %s\n", argv[0]);
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "USAGE: %s", argv[0]);
return_code = 1;
goto quit;
}

View File

@@ -106,7 +106,7 @@ int main(int argc, char *argv[])
int i;
if (argc > 1) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "USAGE: %s\n", argv[0]);
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "USAGE: %s", argv[0]);
return_code = 1;
goto quit;
}

View File

@@ -86,7 +86,7 @@ static void UpdateTexture(SDL_Texture *texture)
int pitch;
if (!SDL_LockTexture(texture, NULL, &pixels, &pitch)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't lock texture: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't lock texture: %s", SDL_GetError());
quit(5);
}
src = MooseFrames[frame];
@@ -152,20 +152,20 @@ int main(int argc, char **argv)
}
if (!SDL_Init(SDL_INIT_VIDEO)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s", SDL_GetError());
return 1;
}
/* load the moose images */
filename = GetResourceFilename(NULL, "moose.dat");
if (!filename) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory\n");
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory");
return -1;
}
handle = SDL_IOFromFile(filename, "rb");
SDL_free(filename);
if (!handle) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't find the file moose.dat !\n");
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't find the file moose.dat !");
quit(2);
}
SDL_ReadIO(handle, MooseFrames, MOOSEFRAME_SIZE * MOOSEFRAMES_COUNT);
@@ -174,19 +174,19 @@ int main(int argc, char **argv)
/* Create the window and renderer */
window = SDL_CreateWindow("Happy Moose", MOOSEPIC_W * 4, MOOSEPIC_H * 4, SDL_WINDOW_RESIZABLE);
if (!window) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create window: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create window: %s", SDL_GetError());
quit(3);
}
renderer = SDL_CreateRenderer(window, NULL);
if (!renderer) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create renderer: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create renderer: %s", SDL_GetError());
quit(4);
}
MooseTexture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, MOOSEPIC_W, MOOSEPIC_H);
if (!MooseTexture) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create texture: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create texture: %s", SDL_GetError());
quit(5);
}

View File

@@ -209,7 +209,7 @@ int main(int argc, char *argv[])
}
if (!SDL_Init(SDL_INIT_AUDIO)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s", SDL_GetError());
return 1;
}
@@ -219,11 +219,11 @@ int main(int argc, char *argv[])
SDL_Log("%i: %s", i, SDL_GetAudioDriver(i));
}
SDL_Log("Using audio driver: %s\n", SDL_GetCurrentAudioDriver());
SDL_Log("Using audio driver: %s", SDL_GetCurrentAudioDriver());
devices = SDL_GetAudioPlaybackDevices(&devcount);
if (!devices) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_GetAudioPlaybackDevices() failed: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_GetAudioPlaybackDevices() failed: %s", SDL_GetError());
}
SDL_Log("Available audio devices:");
@@ -237,14 +237,14 @@ int main(int argc, char *argv[])
int j;
SDL_AudioSpec spec;
SDL_Log("Testing audio device: %s\n", devname);
SDL_Log("Testing audio device: %s", devname);
if (!SDL_GetAudioDeviceFormat(devices[i], &spec, NULL)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_GetAudioDeviceFormat() failed: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_GetAudioDeviceFormat() failed: %s", SDL_GetError());
continue;
}
SDL_Log(" (%d channels)\n", spec.channels);
SDL_Log(" (%d channels)", spec.channels);
spec.freq = SAMPLE_RATE_HZ;
spec.format = SDL_AUDIO_S16;
@@ -255,7 +255,7 @@ int main(int argc, char *argv[])
stream = SDL_OpenAudioDeviceStream(devices[i], &spec, fill_buffer, NULL);
if (!stream) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_OpenAudioDeviceStream() failed: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_OpenAudioDeviceStream() failed: %s", SDL_GetError());
continue;
}
SDL_ResumeAudioStreamDevice(stream);
@@ -263,7 +263,7 @@ int main(int argc, char *argv[])
for (j = 0; j < total_channels; j++) {
const int sine_freq = is_lfe_channel(j, total_channels) ? LFE_SINE_FREQ_HZ : SINE_FREQ_HZ;
SDL_Log("Playing %d Hz test tone on channel: %s\n", sine_freq, get_channel_name(j, total_channels));
SDL_Log("Playing %d Hz test tone on channel: %s", sine_freq, get_channel_name(j, total_channels));
/* fill_buffer() will increment the active channel */
if (SDL_GetEnvironmentVariable(SDL_GetEnvironment(), "SDL_TESTS_QUICK") != NULL) {

View File

@@ -60,13 +60,13 @@ ThreadFunc(void *data)
SDL_ThreadPriority prio = SDL_THREAD_PRIORITY_NORMAL;
SDL_SetTLS(&tls, "baby thread", NULL);
SDL_Log("Started thread %s: My thread id is %" SDL_PRIu64 ", thread data = %s\n",
SDL_Log("Started thread %s: My thread id is %" SDL_PRIu64 ", thread data = %s",
(char *)data, SDL_GetCurrentThreadID(), (const char *)SDL_GetTLS(&tls));
while (SDL_GetAtomicInt(&alive)) {
SDL_Log("Thread '%s' is alive!\n", (char *)data);
SDL_Log("Thread '%s' is alive!", (char *)data);
if (testprio) {
SDL_Log("SDL_SetCurrentThreadPriority(%s):%d\n", getprioritystr(prio), SDL_SetCurrentThreadPriority(prio));
SDL_Log("SDL_SetCurrentThreadPriority(%s):%d", getprioritystr(prio), SDL_SetCurrentThreadPriority(prio));
if (++prio > SDL_THREAD_PRIORITY_TIME_CRITICAL) {
prio = SDL_THREAD_PRIORITY_LOW;
}
@@ -74,14 +74,14 @@ ThreadFunc(void *data)
SDL_Delay(1 * 1000);
}
SDL_Log("Thread '%s' exiting!\n", (char *)data);
SDL_Log("Thread '%s' exiting!", (char *)data);
return 0;
}
static void
killed(int sig)
{
SDL_Log("Killed with SIGTERM, waiting 5 seconds to exit\n");
SDL_Log("Killed with SIGTERM, waiting 5 seconds to exit");
SDL_Delay(5 * 1000);
SDL_SetAtomicInt(&alive, 0);
SDL_WaitThread(thread, NULL);
@@ -120,7 +120,7 @@ int main(int argc, char *argv[])
/* Load the SDL library */
if (!SDL_Init(0)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s", SDL_GetError());
return 1;
}
@@ -131,26 +131,26 @@ int main(int argc, char *argv[])
}
SDL_SetTLS(&tls, "main thread", NULL);
SDL_Log("Main thread data initially: %s\n", (const char *)SDL_GetTLS(&tls));
SDL_Log("Main thread data initially: %s", (const char *)SDL_GetTLS(&tls));
SDL_SetAtomicInt(&alive, 1);
thread = SDL_CreateThread(ThreadFunc, "One", "#1");
if (!thread) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s", SDL_GetError());
quit(1);
}
SDL_Delay(5 * 1000);
SDL_Log("Waiting for thread #1\n");
SDL_Log("Waiting for thread #1");
SDL_SetAtomicInt(&alive, 0);
SDL_WaitThread(thread, NULL);
SDL_Log("Main thread data finally: %s\n", (const char *)SDL_GetTLS(&tls));
SDL_Log("Main thread data finally: %s", (const char *)SDL_GetTLS(&tls));
SDL_SetAtomicInt(&alive, 1);
(void)signal(SIGTERM, killed);
thread = SDL_CreateThread(ThreadFunc, "Two", "#2");
if (!thread) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s", SDL_GetError());
quit(1);
}
(void)raise(SIGTERM);

View File

@@ -68,7 +68,7 @@ callback(void *param, SDL_TimerID timerID, Uint32 interval)
{
int value = (int)(uintptr_t)param;
SDL_assert( value == 1 || value == 2 || value == 3 );
SDL_Log("Timer %" SDL_PRIu32 " : param = %d\n", interval, value);
SDL_Log("Timer %" SDL_PRIu32 " : param = %d", interval, value);
return interval;
}
@@ -123,13 +123,13 @@ int main(int argc, char *argv[])
}
/* Verify SDL_GetTicks* acts monotonically increasing, and not erratic. */
SDL_Log("Sanity-checking GetTicks\n");
SDL_Log("Sanity-checking GetTicks");
for (i = 0; i < 1000; ++i) {
start = SDL_GetTicks();
SDL_Delay(1);
now = SDL_GetTicks() - start;
if (now > 100) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "testtimer.c: Delta time erratic at iter %d. Delay 1ms = %d ms in ticks\n", i, (int)now);
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "testtimer.c: Delta time erratic at iter %d. Delay 1ms = %d ms in ticks", i, (int)now);
SDL_Quit();
return 1;
}
@@ -143,7 +143,7 @@ int main(int argc, char *argv[])
t1 = SDL_AddTimer(desired, ticktock, NULL);
/* Wait 1 seconds */
SDL_Log("Waiting 1 seconds for millisecond timer\n");
SDL_Log("Waiting 1 seconds for millisecond timer");
SDL_Delay(1 * 1000);
/* Stop the timer */
@@ -151,7 +151,7 @@ int main(int argc, char *argv[])
/* Print the results */
if (ticks) {
SDL_Log("Millisecond timer resolution: desired = %d ms, actual = %f ms\n",
SDL_Log("Millisecond timer resolution: desired = %d ms, actual = %f ms",
desired, (double)(10 * 1000) / ticks);
}
@@ -163,7 +163,7 @@ int main(int argc, char *argv[])
t1 = SDL_AddTimerNS(desired, ticktockNS, NULL);
/* Wait 1 seconds */
SDL_Log("Waiting 1 seconds for nanosecond timer\n");
SDL_Log("Waiting 1 seconds for nanosecond timer");
SDL_Delay(1 * 1000);
/* Stop the timer */
@@ -171,7 +171,7 @@ int main(int argc, char *argv[])
/* Print the results */
if (ticks) {
SDL_Log("Nanosecond timer resolution: desired = %d ns, actual = %f ns\n",
SDL_Log("Nanosecond timer resolution: desired = %d ns, actual = %f ns",
desired, (double)(10 * 1000000) / ticks);
}
@@ -188,9 +188,9 @@ int main(int argc, char *argv[])
SDL_DelayNS(1);
now = SDL_GetTicksNS();
actual_delay = (now - start);
SDL_Log("Minimum nanosecond delay: %" SDL_PRIu64 " ns\n", actual_delay);
SDL_Log("Minimum nanosecond delay: %" SDL_PRIu64 " ns", actual_delay);
SDL_Log("Timing 100 frames at 60 FPS\n");
SDL_Log("Timing 100 frames at 60 FPS");
for (i = 0; i < 100; ++i) {
start = SDL_GetTicksNS();
SDL_DelayNS(desired_delay);
@@ -200,7 +200,7 @@ int main(int argc, char *argv[])
total_overslept += (actual_delay - desired_delay);
}
}
SDL_Log("Overslept %.2f ms\n", (double)total_overslept / SDL_NS_PER_MS);
SDL_Log("Overslept %.2f ms", (double)total_overslept / SDL_NS_PER_MS);
}
/* Wait for the results to be seen */
@@ -216,9 +216,9 @@ int main(int argc, char *argv[])
SDL_DelayPrecise(1);
now = SDL_GetTicksNS();
actual_delay = (now - start);
SDL_Log("Minimum precise delay: %" SDL_PRIu64 " ns\n", actual_delay);
SDL_Log("Minimum precise delay: %" SDL_PRIu64 " ns", actual_delay);
SDL_Log("Timing 100 frames at 60 FPS\n");
SDL_Log("Timing 100 frames at 60 FPS");
for (i = 0; i < 100; ++i) {
start = SDL_GetTicksNS();
SDL_DelayPrecise(desired_delay);
@@ -228,32 +228,32 @@ int main(int argc, char *argv[])
total_overslept += (actual_delay - desired_delay);
}
}
SDL_Log("Overslept %.2f ms\n", (double)total_overslept / SDL_NS_PER_MS);
SDL_Log("Overslept %.2f ms", (double)total_overslept / SDL_NS_PER_MS);
}
/* Wait for the results to be seen */
SDL_Delay(1 * 1000);
/* Test multiple timers */
SDL_Log("Testing multiple timers...\n");
SDL_Log("Testing multiple timers...");
t1 = SDL_AddTimer(100, callback, (void *)1);
if (!t1) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not create timer 1: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not create timer 1: %s", SDL_GetError());
}
t2 = SDL_AddTimer(50, callback, (void *)2);
if (!t2) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not create timer 2: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not create timer 2: %s", SDL_GetError());
}
t3 = SDL_AddTimer(233, callback, (void *)3);
if (!t3) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not create timer 3: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not create timer 3: %s", SDL_GetError());
}
/* Wait 3 seconds */
SDL_Log("Waiting 3 seconds\n");
SDL_Log("Waiting 3 seconds");
SDL_Delay(3 * 1000);
SDL_Log("Removing timer 1 and waiting 3 more seconds\n");
SDL_Log("Removing timer 1 and waiting 3 more seconds");
SDL_RemoveTimer(t1);
SDL_Delay(3 * 1000);
@@ -267,15 +267,15 @@ int main(int argc, char *argv[])
ticktock(NULL, 0, 0);
}
now_perf = SDL_GetPerformanceCounter();
SDL_Log("1 million iterations of ticktock took %f ms\n", (double)((now_perf - start_perf) * 1000) / SDL_GetPerformanceFrequency());
SDL_Log("1 million iterations of ticktock took %f ms", (double)((now_perf - start_perf) * 1000) / SDL_GetPerformanceFrequency());
SDL_Log("Performance counter frequency: %" SDL_PRIu64 "\n", SDL_GetPerformanceFrequency());
SDL_Log("Performance counter frequency: %" SDL_PRIu64, SDL_GetPerformanceFrequency());
start = SDL_GetTicks();
start_perf = SDL_GetPerformanceCounter();
SDL_Delay(1000);
now_perf = SDL_GetPerformanceCounter();
now = SDL_GetTicks();
SDL_Log("Delay 1 second = %d ms in ticks, %f ms according to performance counter\n", (int)(now - start), (double)((now_perf - start_perf) * 1000) / SDL_GetPerformanceFrequency());
SDL_Log("Delay 1 second = %d ms in ticks, %f ms according to performance counter", (int)(now - start), (double)((now_perf - start_perf) * 1000) / SDL_GetPerformanceFrequency());
if (run_interactive_tests) {
return_code = test_sdl_delay_within_bounds();

View File

@@ -52,7 +52,7 @@ static void SDLCALL change_icon(void *ptr, SDL_TrayEntry *entry)
static void SDLCALL print_entry(void *ptr, SDL_TrayEntry *entry)
{
SDL_Log("Clicked on button '%s'\n", SDL_GetTrayEntryLabel(entry));
SDL_Log("Clicked on button '%s'", SDL_GetTrayEntryLabel(entry));
}
static void SDLCALL set_entry_enabled(void *ptr, SDL_TrayEntry *entry)
@@ -88,7 +88,7 @@ static void SDLCALL remove_entry(void *ptr, SDL_TrayEntry *entry)
SDL_TrayEntry *ctrl_entry = SDL_GetTrayMenuParentEntry(ctrl_submenu);
if (!ctrl_entry) {
SDL_Log("Attempt to remove a menu that isn't a submenu. This shouldn't happen.\n");
SDL_Log("Attempt to remove a menu that isn't a submenu. This shouldn't happen.");
return;
}
@@ -108,7 +108,7 @@ static void SDLCALL append_button_to(void *ptr, SDL_TrayEntry *entry)
new_ctrl = SDL_InsertTrayEntryAt(SDL_GetTrayEntryParent(entry), -1, "New button", SDL_TRAYENTRY_SUBMENU);
if (!new_ctrl) {
SDL_Log("Couldn't insert entry in control tray: %s\n", SDL_GetError());
SDL_Log("Couldn't insert entry in control tray: %s", SDL_GetError());
return;
}
@@ -117,7 +117,7 @@ static void SDLCALL append_button_to(void *ptr, SDL_TrayEntry *entry)
submenu = SDL_CreateTraySubmenu(new_ctrl);
if (!new_ctrl) {
SDL_Log("Couldn't create control tray entry submenu: %s\n", SDL_GetError());
SDL_Log("Couldn't create control tray entry submenu: %s", SDL_GetError());
SDL_RemoveTrayEntry(new_ctrl);
return;
}
@@ -127,7 +127,7 @@ static void SDLCALL append_button_to(void *ptr, SDL_TrayEntry *entry)
new_example = SDL_InsertTrayEntryAt(menu, -1, "New button", SDL_TRAYENTRY_BUTTON);
if (new_example == NULL) {
SDL_Log("Couldn't insert entry in example tray: %s\n", SDL_GetError());
SDL_Log("Couldn't insert entry in example tray: %s", SDL_GetError());
SDL_RemoveTrayEntry(new_ctrl);
return;
}
@@ -139,7 +139,7 @@ static void SDLCALL append_button_to(void *ptr, SDL_TrayEntry *entry)
new_ctrl_remove = SDL_InsertTrayEntryAt(submenu, -1, "Remove", SDL_TRAYENTRY_BUTTON);
if (new_ctrl_remove == NULL) {
SDL_Log("Couldn't insert new_ctrl_remove: %s\n", SDL_GetError());
SDL_Log("Couldn't insert new_ctrl_remove: %s", SDL_GetError());
SDL_RemoveTrayEntry(new_ctrl);
SDL_RemoveTrayEntry(new_example);
return;
@@ -152,7 +152,7 @@ static void SDLCALL append_button_to(void *ptr, SDL_TrayEntry *entry)
new_ctrl_enabled = SDL_InsertTrayEntryAt(submenu, -1, "Enable", SDL_TRAYENTRY_BUTTON);
if (new_ctrl_enabled == NULL) {
SDL_Log("Couldn't insert new_ctrl_enabled: %s\n", SDL_GetError());
SDL_Log("Couldn't insert new_ctrl_enabled: %s", SDL_GetError());
SDL_RemoveTrayEntry(new_ctrl);
SDL_RemoveTrayEntry(new_example);
return;
@@ -165,7 +165,7 @@ static void SDLCALL append_button_to(void *ptr, SDL_TrayEntry *entry)
new_ctrl_disabled = SDL_InsertTrayEntryAt(submenu, -1, "Disable", SDL_TRAYENTRY_BUTTON);
if (new_ctrl_disabled == NULL) {
SDL_Log("Couldn't insert new_ctrl_disabled: %s\n", SDL_GetError());
SDL_Log("Couldn't insert new_ctrl_disabled: %s", SDL_GetError());
SDL_RemoveTrayEntry(new_ctrl);
SDL_RemoveTrayEntry(new_example);
return;
@@ -189,7 +189,7 @@ static void SDLCALL append_checkbox_to(void *ptr, SDL_TrayEntry *entry)
new_ctrl = SDL_InsertTrayEntryAt(SDL_GetTrayEntryParent(entry), -1, "New checkbox", SDL_TRAYENTRY_SUBMENU);
if (!new_ctrl) {
SDL_Log("Couldn't insert entry in control tray: %s\n", SDL_GetError());
SDL_Log("Couldn't insert entry in control tray: %s", SDL_GetError());
return;
}
@@ -198,7 +198,7 @@ static void SDLCALL append_checkbox_to(void *ptr, SDL_TrayEntry *entry)
submenu = SDL_CreateTraySubmenu(new_ctrl);
if (!new_ctrl) {
SDL_Log("Couldn't create control tray entry submenu: %s\n", SDL_GetError());
SDL_Log("Couldn't create control tray entry submenu: %s", SDL_GetError());
SDL_RemoveTrayEntry(new_ctrl);
return;
}
@@ -208,7 +208,7 @@ static void SDLCALL append_checkbox_to(void *ptr, SDL_TrayEntry *entry)
new_example = SDL_InsertTrayEntryAt(menu, -1, "New checkbox", SDL_TRAYENTRY_CHECKBOX);
if (new_example == NULL) {
SDL_Log("Couldn't insert entry in example tray: %s\n", SDL_GetError());
SDL_Log("Couldn't insert entry in example tray: %s", SDL_GetError());
SDL_RemoveTrayEntry(new_ctrl);
return;
}
@@ -220,7 +220,7 @@ static void SDLCALL append_checkbox_to(void *ptr, SDL_TrayEntry *entry)
new_ctrl_remove = SDL_InsertTrayEntryAt(submenu, -1, "Remove", SDL_TRAYENTRY_BUTTON);
if (new_ctrl_remove == NULL) {
SDL_Log("Couldn't insert new_ctrl_remove: %s\n", SDL_GetError());
SDL_Log("Couldn't insert new_ctrl_remove: %s", SDL_GetError());
SDL_RemoveTrayEntry(new_ctrl);
SDL_RemoveTrayEntry(new_example);
return;
@@ -233,7 +233,7 @@ static void SDLCALL append_checkbox_to(void *ptr, SDL_TrayEntry *entry)
new_ctrl_enabled = SDL_InsertTrayEntryAt(submenu, -1, "Enable", SDL_TRAYENTRY_BUTTON);
if (new_ctrl_enabled == NULL) {
SDL_Log("Couldn't insert new_ctrl_enabled: %s\n", SDL_GetError());
SDL_Log("Couldn't insert new_ctrl_enabled: %s", SDL_GetError());
SDL_RemoveTrayEntry(new_ctrl);
SDL_RemoveTrayEntry(new_example);
return;
@@ -246,7 +246,7 @@ static void SDLCALL append_checkbox_to(void *ptr, SDL_TrayEntry *entry)
new_ctrl_disabled = SDL_InsertTrayEntryAt(submenu, -1, "Disable", SDL_TRAYENTRY_BUTTON);
if (new_ctrl_disabled == NULL) {
SDL_Log("Couldn't insert new_ctrl_disabled: %s\n", SDL_GetError());
SDL_Log("Couldn't insert new_ctrl_disabled: %s", SDL_GetError());
SDL_RemoveTrayEntry(new_ctrl);
SDL_RemoveTrayEntry(new_example);
return;
@@ -259,7 +259,7 @@ static void SDLCALL append_checkbox_to(void *ptr, SDL_TrayEntry *entry)
new_ctrl_checked = SDL_InsertTrayEntryAt(submenu, -1, "Check", SDL_TRAYENTRY_BUTTON);
if (new_ctrl_checked == NULL) {
SDL_Log("Couldn't insert new_ctrl_checked: %s\n", SDL_GetError());
SDL_Log("Couldn't insert new_ctrl_checked: %s", SDL_GetError());
SDL_RemoveTrayEntry(new_ctrl);
SDL_RemoveTrayEntry(new_example);
return;
@@ -272,7 +272,7 @@ static void SDLCALL append_checkbox_to(void *ptr, SDL_TrayEntry *entry)
new_ctrl_unchecked = SDL_InsertTrayEntryAt(submenu, -1, "Uncheck", SDL_TRAYENTRY_BUTTON);
if (new_ctrl_unchecked == NULL) {
SDL_Log("Couldn't insert new_ctrl_unchecked: %s\n", SDL_GetError());
SDL_Log("Couldn't insert new_ctrl_unchecked: %s", SDL_GetError());
SDL_RemoveTrayEntry(new_ctrl);
SDL_RemoveTrayEntry(new_example);
return;
@@ -292,7 +292,7 @@ static void SDLCALL append_separator_to(void *ptr, SDL_TrayEntry *entry)
new_ctrl = SDL_InsertTrayEntryAt(SDL_GetTrayEntryParent(entry), -1, "[Separator]", SDL_TRAYENTRY_SUBMENU);
if (!new_ctrl) {
SDL_Log("Couldn't insert entry in control tray: %s\n", SDL_GetError());
SDL_Log("Couldn't insert entry in control tray: %s", SDL_GetError());
return;
}
@@ -301,7 +301,7 @@ static void SDLCALL append_separator_to(void *ptr, SDL_TrayEntry *entry)
submenu = SDL_CreateTraySubmenu(new_ctrl);
if (!new_ctrl) {
SDL_Log("Couldn't create control tray entry submenu: %s\n", SDL_GetError());
SDL_Log("Couldn't create control tray entry submenu: %s", SDL_GetError());
SDL_RemoveTrayEntry(new_ctrl);
return;
}
@@ -311,7 +311,7 @@ static void SDLCALL append_separator_to(void *ptr, SDL_TrayEntry *entry)
new_example = SDL_InsertTrayEntryAt(menu, -1, NULL, SDL_TRAYENTRY_BUTTON);
if (new_example == NULL) {
SDL_Log("Couldn't insert separator in example tray: %s\n", SDL_GetError());
SDL_Log("Couldn't insert separator in example tray: %s", SDL_GetError());
SDL_RemoveTrayEntry(new_ctrl);
return;
}
@@ -321,7 +321,7 @@ static void SDLCALL append_separator_to(void *ptr, SDL_TrayEntry *entry)
new_ctrl_remove = SDL_InsertTrayEntryAt(submenu, -1, "Remove", SDL_TRAYENTRY_BUTTON);
if (new_ctrl_remove == NULL) {
SDL_Log("Couldn't insert new_ctrl_remove: %s\n", SDL_GetError());
SDL_Log("Couldn't insert new_ctrl_remove: %s", SDL_GetError());
SDL_RemoveTrayEntry(new_ctrl);
SDL_RemoveTrayEntry(new_example);
return;
@@ -344,7 +344,7 @@ static void SDLCALL append_submenu_to(void *ptr, SDL_TrayEntry *entry)
new_ctrl = SDL_InsertTrayEntryAt(SDL_GetTrayEntryParent(entry), -1, "New submenu", SDL_TRAYENTRY_SUBMENU);
if (!new_ctrl) {
SDL_Log("Couldn't insert entry in control tray: %s\n", SDL_GetError());
SDL_Log("Couldn't insert entry in control tray: %s", SDL_GetError());
return;
}
@@ -353,7 +353,7 @@ static void SDLCALL append_submenu_to(void *ptr, SDL_TrayEntry *entry)
submenu = SDL_CreateTraySubmenu(new_ctrl);
if (!new_ctrl) {
SDL_Log("Couldn't create control tray entry submenu: %s\n", SDL_GetError());
SDL_Log("Couldn't create control tray entry submenu: %s", SDL_GetError());
SDL_RemoveTrayEntry(new_ctrl);
return;
}
@@ -363,7 +363,7 @@ static void SDLCALL append_submenu_to(void *ptr, SDL_TrayEntry *entry)
new_example = SDL_InsertTrayEntryAt(menu, -1, "New submenu", SDL_TRAYENTRY_SUBMENU);
if (new_example == NULL) {
SDL_Log("Couldn't insert entry in example tray: %s\n", SDL_GetError());
SDL_Log("Couldn't insert entry in example tray: %s", SDL_GetError());
SDL_RemoveTrayEntry(new_ctrl);
return;
}
@@ -375,7 +375,7 @@ static void SDLCALL append_submenu_to(void *ptr, SDL_TrayEntry *entry)
entry_submenu = SDL_CreateTraySubmenu(new_example);
if (entry_submenu == NULL) {
SDL_Log("Couldn't create new entry submenu: %s\n", SDL_GetError());
SDL_Log("Couldn't create new entry submenu: %s", SDL_GetError());
SDL_RemoveTrayEntry(new_ctrl);
SDL_RemoveTrayEntry(new_example);
return;
@@ -386,7 +386,7 @@ static void SDLCALL append_submenu_to(void *ptr, SDL_TrayEntry *entry)
new_ctrl_remove = SDL_InsertTrayEntryAt(submenu, -1, "Remove", SDL_TRAYENTRY_BUTTON);
if (new_ctrl_remove == NULL) {
SDL_Log("Couldn't insert new_ctrl_remove: %s\n", SDL_GetError());
SDL_Log("Couldn't insert new_ctrl_remove: %s", SDL_GetError());
SDL_RemoveTrayEntry(new_ctrl);
SDL_RemoveTrayEntry(new_example);
return;
@@ -399,7 +399,7 @@ static void SDLCALL append_submenu_to(void *ptr, SDL_TrayEntry *entry)
new_ctrl_enabled = SDL_InsertTrayEntryAt(submenu, -1, "Enable", SDL_TRAYENTRY_BUTTON);
if (new_ctrl_enabled == NULL) {
SDL_Log("Couldn't insert new_ctrl_enabled: %s\n", SDL_GetError());
SDL_Log("Couldn't insert new_ctrl_enabled: %s", SDL_GetError());
SDL_RemoveTrayEntry(new_ctrl);
SDL_RemoveTrayEntry(new_example);
return;
@@ -412,7 +412,7 @@ static void SDLCALL append_submenu_to(void *ptr, SDL_TrayEntry *entry)
new_ctrl_disabled = SDL_InsertTrayEntryAt(submenu, -1, "Disable", SDL_TRAYENTRY_BUTTON);
if (new_ctrl_disabled == NULL) {
SDL_Log("Couldn't insert new_ctrl_disabled: %s\n", SDL_GetError());
SDL_Log("Couldn't insert new_ctrl_disabled: %s", SDL_GetError());
SDL_RemoveTrayEntry(new_ctrl);
SDL_RemoveTrayEntry(new_example);
return;
@@ -429,7 +429,7 @@ static void SDLCALL append_submenu_to(void *ptr, SDL_TrayEntry *entry)
SDL_TrayEntry *entry_newbtn = SDL_InsertTrayEntryAt(submenu, -1, "Create button", SDL_TRAYENTRY_BUTTON);
if (entry_newbtn == NULL) {
SDL_Log("Couldn't insert entry_newbtn: %s\n", SDL_GetError());
SDL_Log("Couldn't insert entry_newbtn: %s", SDL_GetError());
SDL_RemoveTrayEntry(new_ctrl);
SDL_RemoveTrayEntry(new_example);
return;
@@ -442,7 +442,7 @@ static void SDLCALL append_submenu_to(void *ptr, SDL_TrayEntry *entry)
SDL_TrayEntry *entry_newchk = SDL_InsertTrayEntryAt(submenu, -1, "Create checkbox", SDL_TRAYENTRY_BUTTON);
if (entry_newchk == NULL) {
SDL_Log("Couldn't insert entry_newchk: %s\n", SDL_GetError());
SDL_Log("Couldn't insert entry_newchk: %s", SDL_GetError());
SDL_RemoveTrayEntry(new_ctrl);
SDL_RemoveTrayEntry(new_example);
return;
@@ -455,7 +455,7 @@ static void SDLCALL append_submenu_to(void *ptr, SDL_TrayEntry *entry)
SDL_TrayEntry *entry_newsub = SDL_InsertTrayEntryAt(submenu, -1, "Create submenu", SDL_TRAYENTRY_BUTTON);
if (entry_newsub == NULL) {
SDL_Log("Couldn't insert entry_newsub: %s\n", SDL_GetError());
SDL_Log("Couldn't insert entry_newsub: %s", SDL_GetError());
SDL_RemoveTrayEntry(new_ctrl);
SDL_RemoveTrayEntry(new_example);
return;
@@ -468,7 +468,7 @@ static void SDLCALL append_submenu_to(void *ptr, SDL_TrayEntry *entry)
SDL_TrayEntry *entry_newsep = SDL_InsertTrayEntryAt(submenu, -1, "Create separator", SDL_TRAYENTRY_BUTTON);
if (entry_newsep == NULL) {
SDL_Log("Couldn't insert entry_newsep: %s\n", SDL_GetError());
SDL_Log("Couldn't insert entry_newsep: %s", SDL_GetError());
SDL_RemoveTrayEntry(new_ctrl);
SDL_RemoveTrayEntry(new_example);
return;

View File

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

View File

@@ -127,7 +127,7 @@ SDL_Texture *LoadTexture(SDL_Renderer *renderer, const char *file, bool transpar
texture = SDL_CreateTextureFromSurface(renderer, temp);
if (!texture) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s", SDL_GetError());
}
}
SDL_DestroySurface(temp);

View File

@@ -25,15 +25,15 @@ int main(int argc, char *argv[])
}
#if SDL_VERSION_ATLEAST(3, 0, 0)
SDL_Log("Compiled with SDL 3.0 or newer\n");
SDL_Log("Compiled with SDL 3.0 or newer");
#else
SDL_Log("Compiled with SDL older than 3.0\n");
SDL_Log("Compiled with SDL older than 3.0");
#endif
SDL_Log("Compiled version: %d.%d.%d (%s)\n",
SDL_Log("Compiled version: %d.%d.%d (%s)",
SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_MICRO_VERSION,
SDL_REVISION);
int version = SDL_GetVersion();
SDL_Log("Runtime version: %d.%d.%d (%s)\n",
SDL_Log("Runtime version: %d.%d.%d (%s)",
SDL_VERSIONNUM_MAJOR(version), SDL_VERSIONNUM_MINOR(version), SDL_VERSIONNUM_MICRO(version),
SDL_GetRevision());
SDL_Quit();

View File

@@ -227,7 +227,7 @@ int main(int argc, char *argv[])
now = SDL_GetTicks();
if (now > then) {
double fps = ((double)frames * 1000) / (now - then);
SDL_Log("%2.2f frames per second\n", fps);
SDL_Log("%2.2f frames per second", fps);
}
quit(0);
return 0;

View File

@@ -18,7 +18,7 @@
int main(int argc, char *argv[])
{
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No Vulkan support on this system\n");
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No Vulkan support on this system");
return 1;
}
@@ -264,7 +264,7 @@ static void createSurface(void)
{
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());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Vulkan_CreateSurface(): %s", SDL_GetError());
quit(2);
}
}
@@ -478,7 +478,7 @@ static void createDevice(void)
result = vkCreateDevice(vulkanContext->physicalDevice, &deviceCreateInfo, NULL, &vulkanContext->device);
if (result != VK_SUCCESS) {
vulkanContext->device = VK_NULL_HANDLE;
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "vkCreateDevice(): %s\n", getVulkanResultString(result));
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "vkCreateDevice(): %s", getVulkanResultString(result));
quit(2);
}
}
@@ -1040,12 +1040,12 @@ static bool render(void)
}
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));
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "vkWaitForFences(): %s", getVulkanResultString(rc));
quit(2);
}
rc = vkResetFences(vulkanContext->device, 1, &vulkanContext->fences[frameIndex]);
if (rc != VK_SUCCESS) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "vkResetFences(): %s\n", getVulkanResultString(rc));
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "vkResetFences(): %s", getVulkanResultString(rc));
quit(2);
}
currentTime = (double)SDL_GetPerformanceCounter() / SDL_GetPerformanceFrequency();
@@ -1065,7 +1065,7 @@ static bool render(void)
rc = vkQueueSubmit(vulkanContext->graphicsQueue, 1, &submitInfo, vulkanContext->fences[frameIndex]);
if (rc != VK_SUCCESS) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "vkQueueSubmit(): %s\n", getVulkanResultString(rc));
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "vkQueueSubmit(): %s", getVulkanResultString(rc));
quit(2);
}
presentInfo.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
@@ -1118,13 +1118,13 @@ int main(int argc, char **argv)
mode = SDL_GetCurrentDisplayMode(SDL_GetPrimaryDisplay());
if (mode) {
SDL_Log("Screen BPP : %d\n", SDL_BITSPERPIXEL(mode->format));
SDL_Log("Screen BPP : %d", SDL_BITSPERPIXEL(mode->format));
}
SDL_GetWindowSize(state->windows[0], &dw, &dh);
SDL_Log("Window Size : %d,%d\n", dw, dh);
SDL_Log("Window Size : %d,%d", dw, dh);
SDL_GetWindowSizeInPixels(state->windows[0], &dw, &dh);
SDL_Log("Draw Size : %d,%d\n", dw, dh);
SDL_Log("\n");
SDL_Log("Draw Size : %d,%d", dw, dh);
SDL_Log("%s", "");
initVulkan();
@@ -1159,7 +1159,7 @@ int main(int argc, char **argv)
/* Print out some timing information */
now = SDL_GetTicks();
if (now > then) {
SDL_Log("%2.2f frames per second\n", ((double)frames * 1000) / (now - then));
SDL_Log("%2.2f frames per second", ((double)frames * 1000) / (now - then));
}
shutdownVulkan(true);

View File

@@ -157,10 +157,10 @@ static void loop(void)
/* Wait up to 20 ms for input, as a test */
Uint64 then = SDL_GetTicks();
if (SDL_WaitEventTimeout(NULL, 20)) {
SDL_Log("Got an event!\n");
SDL_Log("Got an event!");
}
Uint64 now = SDL_GetTicks();
SDL_Log("Waited %d ms for events\n", (int)(now - then));
SDL_Log("Waited %d ms for events", (int)(now - then));
#endif
while (SDL_PollEvent(&event)) {
@@ -170,7 +170,7 @@ static void loop(void)
if (event.type == SDL_EVENT_WINDOW_RESIZED) {
SDL_Window *window = SDL_GetWindowFromEvent(&event);
if (window) {
SDL_Log("Window %" SDL_PRIu32 " resized to %" SDL_PRIs32 "x%" SDL_PRIs32 "\n",
SDL_Log("Window %" SDL_PRIu32 " resized to %" SDL_PRIs32 "x%" SDL_PRIs32,
event.window.windowID,
event.window.data1,
event.window.data2);
@@ -179,7 +179,7 @@ static void loop(void)
if (event.type == SDL_EVENT_WINDOW_MOVED) {
SDL_Window *window = SDL_GetWindowFromEvent(&event);
if (window) {
SDL_Log("Window %" SDL_PRIu32 " moved to %" SDL_PRIs32 ",%" SDL_PRIs32 " (display %s)\n",
SDL_Log("Window %" SDL_PRIu32 " moved to %" SDL_PRIs32 ",%" SDL_PRIs32 " (display %s)",
event.window.windowID,
event.window.data1,
event.window.data2,

View File

@@ -89,7 +89,7 @@ static bool verify_yuv_data(Uint32 format, SDL_Colorspace colorspace, const Uint
int deltaB = (int)actual[2] - expected[2];
int distance = (deltaR * deltaR + deltaG * deltaG + deltaB * deltaB);
if (distance > tolerance) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Pixel at %d,%d was 0x%.2x,0x%.2x,0x%.2x, expected 0x%.2x,0x%.2x,0x%.2x, distance = %d\n", x, y, actual[0], actual[1], actual[2], expected[0], expected[1], expected[2], distance);
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Pixel at %d,%d was 0x%.2x,0x%.2x,0x%.2x, expected 0x%.2x,0x%.2x,0x%.2x, distance = %d", x, y, actual[0], actual[1], actual[2], expected[0], expected[1], expected[2], distance);
result = false;
}
actual += 3;
@@ -97,7 +97,7 @@ static bool verify_yuv_data(Uint32 format, SDL_Colorspace colorspace, const Uint
}
}
} else {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't convert %s to %s: %s\n", SDL_GetPixelFormatName(format), SDL_GetPixelFormatName(surface->format), SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't convert %s to %s: %s", SDL_GetPixelFormatName(format), SDL_GetPixelFormatName(surface->format), SDL_GetError());
}
SDL_free(rgb);
@@ -138,12 +138,12 @@ static bool run_automated_tests(int pattern_size, int extra_pitch)
/* Verify conversion from YUV formats */
for (i = 0; i < SDL_arraysize(formats); ++i) {
if (!ConvertRGBtoYUV(formats[i], pattern->pixels, pattern->pitch, yuv1, pattern->w, pattern->h, mode, 0, 100)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "ConvertRGBtoYUV() doesn't support converting to %s\n", SDL_GetPixelFormatName(formats[i]));
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "ConvertRGBtoYUV() doesn't support converting to %s", SDL_GetPixelFormatName(formats[i]));
goto done;
}
yuv1_pitch = CalculateYUVPitch(formats[i], pattern->w);
if (!verify_yuv_data(formats[i], colorspace, yuv1, yuv1_pitch, pattern, tight_tolerance)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed conversion from %s to RGB\n", SDL_GetPixelFormatName(formats[i]));
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed conversion from %s to RGB", SDL_GetPixelFormatName(formats[i]));
goto done;
}
}
@@ -152,11 +152,11 @@ static bool run_automated_tests(int pattern_size, int extra_pitch)
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)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't convert %s to %s: %s\n", SDL_GetPixelFormatName(pattern->format), SDL_GetPixelFormatName(formats[i]), SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't convert %s to %s: %s", SDL_GetPixelFormatName(pattern->format), SDL_GetPixelFormatName(formats[i]), SDL_GetError());
goto done;
}
if (!verify_yuv_data(formats[i], colorspace, yuv1, yuv1_pitch, pattern, tight_tolerance)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed conversion from RGB to %s\n", SDL_GetPixelFormatName(formats[i]));
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed conversion from RGB to %s", SDL_GetPixelFormatName(formats[i]));
goto done;
}
}
@@ -167,15 +167,15 @@ static bool 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)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't convert %s to %s: %s\n", SDL_GetPixelFormatName(pattern->format), SDL_GetPixelFormatName(formats[i]), SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't convert %s to %s: %s", 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)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't convert %s to %s: %s\n", SDL_GetPixelFormatName(formats[i]), SDL_GetPixelFormatName(formats[j]), SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't convert %s to %s: %s", SDL_GetPixelFormatName(formats[i]), SDL_GetPixelFormatName(formats[j]), SDL_GetError());
goto done;
}
if (!verify_yuv_data(formats[j], colorspace, yuv2, yuv2_pitch, pattern, tight_tolerance)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed conversion from %s to %s\n", SDL_GetPixelFormatName(formats[i]), SDL_GetPixelFormatName(formats[j]));
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed conversion from %s to %s", SDL_GetPixelFormatName(formats[i]), SDL_GetPixelFormatName(formats[j]));
goto done;
}
}
@@ -192,15 +192,15 @@ static bool 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)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't convert %s to %s: %s\n", SDL_GetPixelFormatName(pattern->format), SDL_GetPixelFormatName(formats[i]), SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't convert %s to %s: %s", 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)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't convert %s to %s: %s\n", SDL_GetPixelFormatName(formats[i]), SDL_GetPixelFormatName(formats[j]), SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't convert %s to %s: %s", SDL_GetPixelFormatName(formats[i]), SDL_GetPixelFormatName(formats[j]), SDL_GetError());
goto done;
}
if (!verify_yuv_data(formats[j], colorspace, yuv1, yuv2_pitch, pattern, tight_tolerance)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed conversion from %s to %s\n", SDL_GetPixelFormatName(formats[i]), SDL_GetPixelFormatName(formats[j]));
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed conversion from %s to %s", SDL_GetPixelFormatName(formats[i]), SDL_GetPixelFormatName(formats[j]));
goto done;
}
}
@@ -209,24 +209,24 @@ static bool run_automated_tests(int pattern_size, int extra_pitch)
/* Verify round trip through BT.2020 */
colorspace = SDL_COLORSPACE_BT2020_FULL;
if (!ConvertRGBtoYUV(SDL_PIXELFORMAT_P010, pattern->pixels, pattern->pitch, yuv1, pattern->w, pattern->h, YUV_CONVERSION_BT2020, 0, 100)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "ConvertRGBtoYUV() doesn't support converting to %s\n", SDL_GetPixelFormatName(SDL_PIXELFORMAT_P010));
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "ConvertRGBtoYUV() doesn't support converting to %s", SDL_GetPixelFormatName(SDL_PIXELFORMAT_P010));
goto done;
}
yuv1_pitch = CalculateYUVPitch(SDL_PIXELFORMAT_P010, pattern->w);
if (!verify_yuv_data(SDL_PIXELFORMAT_P010, colorspace, yuv1, yuv1_pitch, pattern, tight_tolerance)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed conversion from %s to RGB\n", SDL_GetPixelFormatName(SDL_PIXELFORMAT_P010));
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed conversion from %s to RGB", SDL_GetPixelFormatName(SDL_PIXELFORMAT_P010));
goto done;
}
/* 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)) {
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());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't convert %s to %s: %s", SDL_GetPixelFormatName(pattern->format), SDL_GetPixelFormatName(SDL_PIXELFORMAT_P010), SDL_GetError());
goto done;
}
/* Going through XRGB2101010 format during P010 conversion is slightly lossy, so use looser tolerance here */
if (!verify_yuv_data(SDL_PIXELFORMAT_P010, colorspace, yuv1, yuv1_pitch, pattern, loose_tolerance)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed conversion from RGB to %s\n", SDL_GetPixelFormatName(SDL_PIXELFORMAT_P010));
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed conversion from RGB to %s", SDL_GetPixelFormatName(SDL_PIXELFORMAT_P010));
goto done;
}
@@ -265,13 +265,13 @@ static bool run_colorspace_test(void)
int i;
if (!SDL_CreateWindowAndRenderer("testyuv", 320, 240, 0, &window, &renderer)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window and renderer: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window and renderer: %s", SDL_GetError());
goto done;
}
rgb = SDL_CreateSurface(32, 32, SDL_PIXELFORMAT_XRGB8888);
if (!rgb) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create RGB surface: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create RGB surface: %s", SDL_GetError());
goto done;
}
SDL_FillSurfaceRect(rgb, NULL, SDL_MapSurfaceRGB(rgb, 255, 0, 0));
@@ -280,28 +280,28 @@ static bool run_colorspace_test(void)
bool next = false;
Uint8 r, g, b, a;
SDL_Log("Checking colorspace %s\n", colorspaces[i].name);
SDL_Log("Checking colorspace %s", colorspaces[i].name);
yuv = SDL_ConvertSurfaceAndColorspace(rgb, SDL_PIXELFORMAT_NV12, NULL, colorspaces[i].colorspace, 0);
if (!yuv) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create YUV surface: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create YUV surface: %s", SDL_GetError());
goto done;
}
if (!SDL_ReadSurfacePixel(yuv, 0, 0, &r, &g, &b, &a)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't read YUV surface: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't read YUV surface: %s", SDL_GetError());
goto done;
}
if (SDL_abs((int)r - 255) > allowed_error ||
SDL_abs((int)g - 0) > allowed_error ||
SDL_abs((int)b - 0) > allowed_error) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed color conversion, expected 255,0,0, got %d,%d,%d\n", r, g, b);
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed color conversion, expected 255,0,0, got %d,%d,%d", r, g, b);
}
texture = SDL_CreateTextureFromSurface(renderer, yuv);
if (!texture) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create YUV texture: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create YUV texture: %s", SDL_GetError());
goto done;
}
@@ -312,14 +312,14 @@ static bool run_colorspace_test(void)
yuv = SDL_RenderReadPixels(renderer, NULL);
if (!SDL_ReadSurfacePixel(yuv, 0, 0, &r, &g, &b, &a)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't read YUV surface: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't read YUV surface: %s", SDL_GetError());
goto done;
}
if (SDL_abs((int)r - 255) > allowed_error ||
SDL_abs((int)g - 0) > allowed_error ||
SDL_abs((int)b - 0) > allowed_error) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed renderer color conversion, expected 255,0,0, got %d,%d,%d\n", r, g, b);
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed renderer color conversion, expected 255,0,0, got %d,%d,%d", r, g, b);
}
while (!next) {
@@ -530,7 +530,7 @@ int main(int argc, char **argv)
/* Run automated tests */
if (should_run_automated_tests) {
for (i = 0; i < (int)SDL_arraysize(automated_test_params); ++i) {
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Running automated test, pattern size %d, extra pitch %d, intrinsics %s\n",
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Running automated test, pattern size %d, extra pitch %d, intrinsics %s",
automated_test_params[i].pattern_size,
automated_test_params[i].extra_pitch,
automated_test_params[i].enable_intrinsics ? "enabled" : "disabled");
@@ -553,7 +553,7 @@ int main(int argc, char **argv)
original = SDL_ConvertSurface(bmp, SDL_PIXELFORMAT_RGB24);
SDL_DestroySurface(bmp);
if (!original) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", filename, SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", filename, SDL_GetError());
return 3;
}
@@ -586,7 +586,7 @@ int main(int argc, char **argv)
converted = SDL_CreateSurface(original->w, original->h, rgb_format);
if (!converted) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create converted surface: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create converted surface: %s", SDL_GetError());
return 3;
}
@@ -595,17 +595,17 @@ int main(int argc, char **argv)
SDL_ConvertPixelsAndColorspace(original->w, original->h, yuv_format, yuv_colorspace, 0, raw_yuv, pitch, rgb_format, rgb_colorspace, 0, converted->pixels, converted->pitch);
}
now = SDL_GetTicks();
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "%d iterations in %" SDL_PRIu64 " ms, %.2fms each\n", iterations, (now - then), (float)(now - then) / iterations);
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "%d iterations in %" SDL_PRIu64 " ms, %.2fms each", iterations, (now - then), (float)(now - then) / iterations);
window = SDL_CreateWindow("YUV test", original->w, original->h, 0);
if (!window) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window: %s", SDL_GetError());
return 4;
}
renderer = SDL_CreateRenderer(window, NULL);
if (!renderer) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s", SDL_GetError());
return 4;
}
@@ -620,7 +620,7 @@ int main(int argc, char **argv)
output[2] = SDL_CreateTextureWithProperties(renderer, props);
SDL_DestroyProperties(props);
if (!output[0] || !output[1] || !output[2]) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create texture: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create texture: %s", SDL_GetError());
return 5;
}
SDL_UpdateTexture(output[2], NULL, raw_yuv, pitch);

View File

@@ -52,7 +52,7 @@ ThreadFunc(void *data)
int i;
int tid = (int)(uintptr_t)data;
SDL_Log("Creating Thread %d\n", tid);
SDL_Log("Creating Thread %d", tid);
for (i = 0; i < NUMTHREADS; i++) {
char name[64];
@@ -61,18 +61,18 @@ ThreadFunc(void *data)
sub_threads[i] = SDL_CreateThread(SubThreadFunc, name, &flags[i]);
}
SDL_Log("Thread '%d' waiting for signal\n", tid);
SDL_Log("Thread '%d' waiting for signal", tid);
while (SDL_GetAtomicInt(&time_for_threads_to_die[tid]) != 1) {
; /* do nothing */
}
SDL_Log("Thread '%d' sending signals to subthreads\n", tid);
SDL_Log("Thread '%d' sending signals to subthreads", tid);
for (i = 0; i < NUMTHREADS; i++) {
SDL_SetAtomicInt(&flags[i], 1);
SDL_WaitThread(sub_threads[i], NULL);
}
SDL_Log("Thread '%d' exiting!\n", tid);
SDL_Log("Thread '%d' exiting!", tid);
return 0;
}
@@ -103,7 +103,7 @@ int main(int argc, char *argv[])
threads[i] = SDL_CreateThread(ThreadFunc, name, (void *)(uintptr_t)i);
if (threads[i] == NULL) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s", SDL_GetError());
quit(1);
}
}