mirror of
https://github.com/love2d/love-android.git
synced 2026-08-19 20:20:25 +02:00
updated to latest SDL2 (f9244b2a151)
This commit is contained in:
@@ -10,6 +10,8 @@ LIBS = @LIBS@
|
||||
TARGETS = \
|
||||
checkkeys$(EXE) \
|
||||
loopwave$(EXE) \
|
||||
loopwavequeue$(EXE) \
|
||||
testatomic$(EXE) \
|
||||
testaudioinfo$(EXE) \
|
||||
testautomation$(EXE) \
|
||||
testdraw2$(EXE) \
|
||||
@@ -23,6 +25,7 @@ TARGETS = \
|
||||
testgles$(EXE) \
|
||||
testgles2$(EXE) \
|
||||
testhaptic$(EXE) \
|
||||
testhittesting$(EXE) \
|
||||
testrumble$(EXE) \
|
||||
testhotplug$(EXE) \
|
||||
testthread$(EXE) \
|
||||
@@ -69,6 +72,9 @@ checkkeys$(EXE): $(srcdir)/checkkeys.c
|
||||
loopwave$(EXE): $(srcdir)/loopwave.c
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
|
||||
|
||||
loopwavequeue$(EXE): $(srcdir)/loopwavequeue.c
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
|
||||
|
||||
testresample$(EXE): $(srcdir)/testresample.c
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
|
||||
|
||||
@@ -92,7 +98,8 @@ testautomation$(EXE): $(srcdir)/testautomation.c \
|
||||
$(srcdir)/testautomation_surface.c \
|
||||
$(srcdir)/testautomation_syswm.c \
|
||||
$(srcdir)/testautomation_timer.c \
|
||||
$(srcdir)/testautomation_video.c
|
||||
$(srcdir)/testautomation_video.c \
|
||||
$(srcdir)/testautomation_hints.c
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
|
||||
|
||||
testmultiaudio$(EXE): $(srcdir)/testmultiaudio.c
|
||||
@@ -107,6 +114,9 @@ testintersections$(EXE): $(srcdir)/testintersections.c
|
||||
testrelative$(EXE): $(srcdir)/testrelative.c
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
|
||||
|
||||
testhittesting$(EXE): $(srcdir)/testhittesting.c
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
|
||||
|
||||
testdraw2$(EXE): $(srcdir)/testdraw2.c
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ These are test programs for the SDL library:
|
||||
|
||||
checkkeys Watch the key events to check the keyboard
|
||||
loopwave Audio test -- loop playing a WAV file
|
||||
loopwavequeue Audio test -- loop playing a WAV file with SDL_QueueAudio
|
||||
testaudioinfo Lists audio device capabilities
|
||||
testcdrom Sample audio CD control program
|
||||
testerror Tests multi-threaded error handling
|
||||
|
||||
@@ -109,9 +109,9 @@ WatchJoystick(SDL_Joystick * joystick)
|
||||
SDL_Rect dst;
|
||||
int s, _s;
|
||||
Uint8 alpha=200, alpha_step = -1;
|
||||
Uint32 alpha_ticks;
|
||||
Uint32 alpha_ticks = 0;
|
||||
char mapping[4096], temp[4096];
|
||||
MappingStep *step;
|
||||
MappingStep *step, *prev_step;
|
||||
MappingStep steps[] = {
|
||||
{342, 132, 0.0, MARKER_BUTTON, "x", -1, -1, -1, -1, ""},
|
||||
{387, 167, 0.0, MARKER_BUTTON, "a", -1, -1, -1, -1, ""},
|
||||
@@ -251,6 +251,9 @@ WatchJoystick(SDL_Joystick * joystick)
|
||||
|
||||
break;
|
||||
case SDL_JOYHATMOTION:
|
||||
if (event.jhat.value == SDL_HAT_CENTERED) {
|
||||
break; /* ignore centering, we're probably just coming back to the center from the previous item we set. */
|
||||
}
|
||||
for (_s = 0; _s < s; _s++) {
|
||||
if (steps[_s].hat == event.jhat.hat && steps[_s].hat_value == event.jhat.value) {
|
||||
break;
|
||||
@@ -293,8 +296,8 @@ WatchJoystick(SDL_Joystick * joystick)
|
||||
if (event.key.keysym.sym == SDLK_BACKSPACE || event.key.keysym.sym == SDLK_AC_BACK) {
|
||||
/* Undo! */
|
||||
if (s > 0) {
|
||||
SDL_strlcpy(mapping, step->mapping, SDL_arraysize(step->mapping));
|
||||
s--;
|
||||
prev_step = &steps[--s];
|
||||
SDL_strlcpy(mapping, prev_step->mapping, SDL_arraysize(prev_step->mapping));
|
||||
next = SDL_TRUE;
|
||||
}
|
||||
break;
|
||||
@@ -373,7 +376,7 @@ main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ANDROID
|
||||
#ifdef __ANDROID__
|
||||
if (SDL_NumJoysticks() > 0) {
|
||||
#else
|
||||
if (argv[1]) {
|
||||
@@ -382,7 +385,7 @@ main(int argc, char *argv[])
|
||||
SDL_bool keepGoing = SDL_TRUE;
|
||||
SDL_Event event;
|
||||
int device;
|
||||
#ifdef ANDROID
|
||||
#ifdef __ANDROID__
|
||||
device = 0;
|
||||
#else
|
||||
device = atoi(argv[1]);
|
||||
|
||||
@@ -90,14 +90,14 @@ main(int argc, char *argv[])
|
||||
return (1);
|
||||
}
|
||||
|
||||
if (argc >= 1) {
|
||||
if (argc > 1) {
|
||||
SDL_strlcpy(filename, argv[1], sizeof(filename));
|
||||
} else {
|
||||
SDL_strlcpy(filename, "sample.wav", sizeof(filename));
|
||||
}
|
||||
/* Load the wave file into memory */
|
||||
if (SDL_LoadWAV(filename, &wave.spec, &wave.sound, &wave.soundlen) == NULL) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", argv[1], SDL_GetError());
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", filename, SDL_GetError());
|
||||
quit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,12 +15,12 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "SDL.h"
|
||||
|
||||
#if HAVE_SIGNAL_H
|
||||
#include <signal.h>
|
||||
#endif
|
||||
|
||||
#include "SDL.h"
|
||||
|
||||
struct
|
||||
{
|
||||
SDL_AudioSpec spec;
|
||||
|
||||
@@ -306,6 +306,7 @@ static void InitEventQueue(SDL_EventQueue *queue)
|
||||
#ifdef TEST_SPINLOCK_FIFO
|
||||
queue->lock = 0;
|
||||
SDL_AtomicSet(&queue->rwcount, 0);
|
||||
SDL_AtomicSet(&queue->watcher, 0);
|
||||
#endif
|
||||
queue->active = SDL_TRUE;
|
||||
}
|
||||
@@ -699,7 +700,7 @@ static void RunFIFOTest(SDL_bool lock_free)
|
||||
}
|
||||
len = SDL_strlen(textBuffer);
|
||||
SDL_snprintf(textBuffer + len, sizeof(textBuffer) - len, " }\n");
|
||||
SDL_Log(textBuffer);
|
||||
SDL_Log("%s", textBuffer);
|
||||
}
|
||||
SDL_Log("Readers read %d total events\n", grand_total);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
* New/updated tests: aschiffler at ferzkopp dot net
|
||||
*/
|
||||
|
||||
/* quiet windows compiler warnings */
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -25,11 +28,29 @@ _audioSetUp(void *arg)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_audioTearDown(void *arg)
|
||||
{
|
||||
/* Remove a possibly created file from SDL disk writer audio driver; ignore errors */
|
||||
remove("sdlaudio.raw");
|
||||
|
||||
SDLTest_AssertPass("Cleanup of test files completed");
|
||||
}
|
||||
|
||||
|
||||
/* Global counter for callback invocation */
|
||||
int _audio_testCallbackCounter;
|
||||
|
||||
/* Global accumulator for total callback length */
|
||||
int _audio_testCallbackLength;
|
||||
|
||||
|
||||
/* Test callback function */
|
||||
void _audio_testCallback(void *userdata, Uint8 *stream, int len)
|
||||
{
|
||||
/* TODO: add tracking if callback was called */
|
||||
/* track that callback was called */
|
||||
_audio_testCallbackCounter++;
|
||||
_audio_testCallbackLength += len;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,8 +59,8 @@ void _audio_testCallback(void *userdata, Uint8 *stream, int len)
|
||||
/**
|
||||
* \brief Stop and restart audio subsystem
|
||||
*
|
||||
* \sa http://wiki.libsdl.org/moin.cgi/SDL_QuitSubSystem
|
||||
* \sa http://wiki.libsdl.org/moin.cgi/SDL_InitSubSystem
|
||||
* \sa https://wiki.libsdl.org/SDL_QuitSubSystem
|
||||
* \sa https://wiki.libsdl.org/SDL_InitSubSystem
|
||||
*/
|
||||
int audio_quitInitAudioSubSystem()
|
||||
{
|
||||
@@ -56,8 +77,8 @@ int audio_quitInitAudioSubSystem()
|
||||
/**
|
||||
* \brief Start and stop audio directly
|
||||
*
|
||||
* \sa http://wiki.libsdl.org/moin.cgi/SDL_InitAudio
|
||||
* \sa http://wiki.libsdl.org/moin.cgi/SDL_QuitAudio
|
||||
* \sa https://wiki.libsdl.org/SDL_InitAudio
|
||||
* \sa https://wiki.libsdl.org/SDL_QuitAudio
|
||||
*/
|
||||
int audio_initQuitAudio()
|
||||
{
|
||||
@@ -110,15 +131,104 @@ int audio_initQuitAudio()
|
||||
/**
|
||||
* \brief Start, open, close and stop audio
|
||||
*
|
||||
* \sa http://wiki.libsdl.org/moin.cgi/SDL_InitAudio
|
||||
* \sa http://wiki.libsdl.org/moin.cgi/SDL_OpenAudio
|
||||
* \sa http://wiki.libsdl.org/moin.cgi/SDL_CloseAudio
|
||||
* \sa http://wiki.libsdl.org/moin.cgi/SDL_QuitAudio
|
||||
* \sa https://wiki.libsdl.org/SDL_InitAudio
|
||||
* \sa https://wiki.libsdl.org/SDL_OpenAudio
|
||||
* \sa https://wiki.libsdl.org/SDL_CloseAudio
|
||||
* \sa https://wiki.libsdl.org/SDL_QuitAudio
|
||||
*/
|
||||
int audio_initOpenCloseQuitAudio()
|
||||
{
|
||||
int result, expectedResult;
|
||||
int i, iMax, j, k;
|
||||
const char* audioDriver;
|
||||
SDL_AudioSpec desired;
|
||||
|
||||
/* Stop SDL audio subsystem */
|
||||
SDL_QuitSubSystem( SDL_INIT_AUDIO );
|
||||
SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_AUDIO)");
|
||||
|
||||
/* Loop over all available audio drivers */
|
||||
iMax = SDL_GetNumAudioDrivers();
|
||||
SDLTest_AssertPass("Call to SDL_GetNumAudioDrivers");
|
||||
SDLTest_AssertCheck(iMax > 0, "Validate number of audio drivers; expected: >0 got: %d", iMax);
|
||||
for (i = 0; i < iMax; i++) {
|
||||
audioDriver = SDL_GetAudioDriver(i);
|
||||
SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i);
|
||||
SDLTest_AssertCheck(audioDriver != NULL, "Audio driver name is not NULL");
|
||||
SDLTest_AssertCheck(audioDriver[0] != '\0', "Audio driver name is not empty; got: %s", audioDriver);
|
||||
|
||||
/* Change specs */
|
||||
for (j = 0; j < 2; j++) {
|
||||
|
||||
/* Call Init */
|
||||
result = SDL_AudioInit(audioDriver);
|
||||
SDLTest_AssertPass("Call to SDL_AudioInit('%s')", audioDriver);
|
||||
SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0 got: %d", result);
|
||||
|
||||
/* Set spec */
|
||||
SDL_memset(&desired, 0, sizeof(desired));
|
||||
switch (j) {
|
||||
case 0:
|
||||
/* Set standard desired spec */
|
||||
desired.freq = 22050;
|
||||
desired.format = AUDIO_S16SYS;
|
||||
desired.channels = 2;
|
||||
desired.samples = 4096;
|
||||
desired.callback = _audio_testCallback;
|
||||
desired.userdata = NULL;
|
||||
|
||||
case 1:
|
||||
/* Set custom desired spec */
|
||||
desired.freq = 48000;
|
||||
desired.format = AUDIO_F32SYS;
|
||||
desired.channels = 2;
|
||||
desired.samples = 2048;
|
||||
desired.callback = _audio_testCallback;
|
||||
desired.userdata = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Call Open (maybe multiple times) */
|
||||
for (k=0; k <= j; k++) {
|
||||
result = SDL_OpenAudio(&desired, NULL);
|
||||
SDLTest_AssertPass("Call to SDL_OpenAudio(desired_spec_%d, NULL), call %d", j, k+1);
|
||||
expectedResult = (k==0) ? 0 : -1;
|
||||
SDLTest_AssertCheck(result == expectedResult, "Verify return value; expected: %d, got: %d", expectedResult, result);
|
||||
}
|
||||
|
||||
/* Call Close (maybe multiple times) */
|
||||
for (k=0; k <= j; k++) {
|
||||
SDL_CloseAudio();
|
||||
SDLTest_AssertPass("Call to SDL_CloseAudio(), call %d", k+1);
|
||||
}
|
||||
|
||||
/* Call Quit (maybe multiple times) */
|
||||
for (k=0; k <= j; k++) {
|
||||
SDL_AudioQuit();
|
||||
SDLTest_AssertPass("Call to SDL_AudioQuit(), call %d", k+1);
|
||||
}
|
||||
|
||||
} /* spec loop */
|
||||
} /* driver loop */
|
||||
|
||||
/* Restart audio again */
|
||||
_audioSetUp(NULL);
|
||||
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Pause and unpause audio
|
||||
*
|
||||
* \sa https://wiki.libsdl.org/SDL_PauseAudio
|
||||
*/
|
||||
int audio_pauseUnpauseAudio()
|
||||
{
|
||||
int result;
|
||||
int i, iMax, j;
|
||||
int i, iMax, j, k, l;
|
||||
int totalDelay;
|
||||
int pause_on;
|
||||
int originalCounter;
|
||||
const char* audioDriver;
|
||||
SDL_AudioSpec desired;
|
||||
|
||||
@@ -172,9 +282,47 @@ int audio_initOpenCloseQuitAudio()
|
||||
SDLTest_AssertPass("Call to SDL_OpenAudio(desired_spec_%d, NULL)", j);
|
||||
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0 got: %d", result);
|
||||
|
||||
/* Start and stop audio multiple times */
|
||||
for (l=0; l<3; l++) {
|
||||
SDLTest_Log("Pause/Unpause iteration: %d", l+1);
|
||||
|
||||
/* Reset callback counters */
|
||||
_audio_testCallbackCounter = 0;
|
||||
_audio_testCallbackLength = 0;
|
||||
|
||||
/* Un-pause audio to start playing (maybe multiple times) */
|
||||
pause_on = 0;
|
||||
for (k=0; k <= j; k++) {
|
||||
SDL_PauseAudio(pause_on);
|
||||
SDLTest_AssertPass("Call to SDL_PauseAudio(%d), call %d", pause_on, k+1);
|
||||
}
|
||||
|
||||
/* Wait for callback */
|
||||
totalDelay = 0;
|
||||
do {
|
||||
SDL_Delay(10);
|
||||
totalDelay += 10;
|
||||
}
|
||||
while (_audio_testCallbackCounter == 0 && totalDelay < 1000);
|
||||
SDLTest_AssertCheck(_audio_testCallbackCounter > 0, "Verify callback counter; expected: >0 got: %d", _audio_testCallbackCounter);
|
||||
SDLTest_AssertCheck(_audio_testCallbackLength > 0, "Verify callback length; expected: >0 got: %d", _audio_testCallbackLength);
|
||||
|
||||
/* Pause audio to stop playing (maybe multiple times) */
|
||||
for (k=0; k <= j; k++) {
|
||||
pause_on = (k==0) ? 1 : SDLTest_RandomIntegerInRange(99, 9999);
|
||||
SDL_PauseAudio(pause_on);
|
||||
SDLTest_AssertPass("Call to SDL_PauseAudio(%d), call %d", pause_on, k+1);
|
||||
}
|
||||
|
||||
/* Ensure callback is not called again */
|
||||
originalCounter = _audio_testCallbackCounter;
|
||||
SDL_Delay(totalDelay + 10);
|
||||
SDLTest_AssertCheck(originalCounter == _audio_testCallbackCounter, "Verify callback counter; expected: %d, got: %d", originalCounter, _audio_testCallbackCounter);
|
||||
}
|
||||
|
||||
/* Call Close */
|
||||
SDL_CloseAudio();
|
||||
SDLTest_AssertPass("Call to SDL_CloseAudio()");
|
||||
SDL_CloseAudio();
|
||||
SDLTest_AssertPass("Call to SDL_CloseAudio()");
|
||||
|
||||
/* Call Quit */
|
||||
SDL_AudioQuit();
|
||||
@@ -183,8 +331,8 @@ int audio_initOpenCloseQuitAudio()
|
||||
} /* spec loop */
|
||||
} /* driver loop */
|
||||
|
||||
/* Restart audio again */
|
||||
_audioSetUp(NULL);
|
||||
/* Restart audio again */
|
||||
_audioSetUp(NULL);
|
||||
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
@@ -192,8 +340,8 @@ int audio_initOpenCloseQuitAudio()
|
||||
/**
|
||||
* \brief Enumerate and name available audio devices (output and capture).
|
||||
*
|
||||
* \sa http://wiki.libsdl.org/moin.cgi/SDL_GetNumAudioDevices
|
||||
* \sa http://wiki.libsdl.org/moin.cgi/SDL_GetAudioDeviceName
|
||||
* \sa https://wiki.libsdl.org/SDL_GetNumAudioDevices
|
||||
* \sa https://wiki.libsdl.org/SDL_GetAudioDeviceName
|
||||
*/
|
||||
int audio_enumerateAndNameAudioDevices()
|
||||
{
|
||||
@@ -250,8 +398,8 @@ int audio_enumerateAndNameAudioDevices()
|
||||
/**
|
||||
* \brief Negative tests around enumeration and naming of audio devices.
|
||||
*
|
||||
* \sa http://wiki.libsdl.org/moin.cgi/SDL_GetNumAudioDevices
|
||||
* \sa http://wiki.libsdl.org/moin.cgi/SDL_GetAudioDeviceName
|
||||
* \sa https://wiki.libsdl.org/SDL_GetNumAudioDevices
|
||||
* \sa https://wiki.libsdl.org/SDL_GetAudioDeviceName
|
||||
*/
|
||||
int audio_enumerateAndNameAudioDevicesNegativeTests()
|
||||
{
|
||||
@@ -297,8 +445,8 @@ int audio_enumerateAndNameAudioDevicesNegativeTests()
|
||||
/**
|
||||
* \brief Checks available audio driver names.
|
||||
*
|
||||
* \sa http://wiki.libsdl.org/moin.cgi/SDL_GetNumAudioDrivers
|
||||
* \sa http://wiki.libsdl.org/moin.cgi/SDL_GetAudioDriver
|
||||
* \sa https://wiki.libsdl.org/SDL_GetNumAudioDrivers
|
||||
* \sa https://wiki.libsdl.org/SDL_GetAudioDriver
|
||||
*/
|
||||
int audio_printAudioDrivers()
|
||||
{
|
||||
@@ -330,7 +478,7 @@ int audio_printAudioDrivers()
|
||||
/**
|
||||
* \brief Checks current audio driver name with initialized audio.
|
||||
*
|
||||
* \sa http://wiki.libsdl.org/moin.cgi/SDL_GetCurrentAudioDriver
|
||||
* \sa https://wiki.libsdl.org/SDL_GetCurrentAudioDriver
|
||||
*/
|
||||
int audio_printCurrentAudioDriver()
|
||||
{
|
||||
@@ -362,7 +510,7 @@ int _audioFrequencies[] = { 11025, 22050, 44100, 48000 };
|
||||
/**
|
||||
* \brief Builds various audio conversion structures
|
||||
*
|
||||
* \sa http://wiki.libsdl.org/moin.cgi/SDL_BuildAudioCVT
|
||||
* \sa https://wiki.libsdl.org/SDL_BuildAudioCVT
|
||||
*/
|
||||
int audio_buildAudioCVT()
|
||||
{
|
||||
@@ -412,7 +560,7 @@ int audio_buildAudioCVT()
|
||||
i, _audioFormatsVerbose[i], spec1.format, j, spec1.channels, k, spec1.freq, ii, _audioFormatsVerbose[ii], spec2.format, jj, spec2.channels, kk, spec2.freq);
|
||||
SDLTest_AssertCheck(result == 0 || result == 1, "Verify result value; expected: 0 or 1, got: %i", result);
|
||||
if (result<0) {
|
||||
SDLTest_LogError(SDL_GetError());
|
||||
SDLTest_LogError("%s", SDL_GetError());
|
||||
} else {
|
||||
SDLTest_AssertCheck(cvt.len_mult > 0, "Verify that cvt.len_mult value; expected: >0, got: %i", cvt.len_mult);
|
||||
}
|
||||
@@ -426,7 +574,7 @@ int audio_buildAudioCVT()
|
||||
/**
|
||||
* \brief Checkes calls with invalid input to SDL_BuildAudioCVT
|
||||
*
|
||||
* \sa http://wiki.libsdl.org/moin.cgi/SDL_BuildAudioCVT
|
||||
* \sa https://wiki.libsdl.org/SDL_BuildAudioCVT
|
||||
*/
|
||||
int audio_buildAudioCVTNegative()
|
||||
{
|
||||
@@ -502,7 +650,7 @@ int audio_buildAudioCVTNegative()
|
||||
SDL_strlcat(message, " spec2.freq", 256);
|
||||
spec2.freq = 0;
|
||||
}
|
||||
SDLTest_Log(message);
|
||||
SDLTest_Log("%s", message);
|
||||
result = SDL_BuildAudioCVT(&cvt, spec1.format, spec1.channels, spec1.freq,
|
||||
spec2.format, spec2.channels, spec2.freq);
|
||||
SDLTest_AssertPass("Call to SDL_BuildAudioCVT(spec1 ==> spec2)");
|
||||
@@ -521,7 +669,7 @@ int audio_buildAudioCVTNegative()
|
||||
/**
|
||||
* \brief Checks current audio status.
|
||||
*
|
||||
* \sa http://wiki.libsdl.org/moin.cgi/SDL_GetAudioStatus
|
||||
* \sa https://wiki.libsdl.org/SDL_GetAudioStatus
|
||||
*/
|
||||
int audio_getAudioStatus()
|
||||
{
|
||||
@@ -542,7 +690,7 @@ int audio_getAudioStatus()
|
||||
/**
|
||||
* \brief Opens, checks current audio status, and closes a device.
|
||||
*
|
||||
* \sa http://wiki.libsdl.org/moin.cgi/SDL_GetAudioStatus
|
||||
* \sa https://wiki.libsdl.org/SDL_GetAudioStatus
|
||||
*/
|
||||
int audio_openCloseAndGetAudioStatus()
|
||||
{
|
||||
@@ -600,8 +748,8 @@ int audio_openCloseAndGetAudioStatus()
|
||||
/**
|
||||
* \brief Locks and unlocks open audio device.
|
||||
*
|
||||
* \sa http://wiki.libsdl.org/moin.cgi/SDL_LockAudioDevice
|
||||
* \sa http://wiki.libsdl.org/moin.cgi/SDL_UnlockAudioDevice
|
||||
* \sa https://wiki.libsdl.org/SDL_LockAudioDevice
|
||||
* \sa https://wiki.libsdl.org/SDL_UnlockAudioDevice
|
||||
*/
|
||||
int audio_lockUnlockOpenAudioDevice()
|
||||
{
|
||||
@@ -663,8 +811,8 @@ int audio_lockUnlockOpenAudioDevice()
|
||||
/**
|
||||
* \brief Convert audio using various conversion structures
|
||||
*
|
||||
* \sa http://wiki.libsdl.org/moin.cgi/SDL_BuildAudioCVT
|
||||
* \sa http://wiki.libsdl.org/moin.cgi/SDL_ConvertAudio
|
||||
* \sa https://wiki.libsdl.org/SDL_BuildAudioCVT
|
||||
* \sa https://wiki.libsdl.org/SDL_ConvertAudio
|
||||
*/
|
||||
int audio_convertAudio()
|
||||
{
|
||||
@@ -688,7 +836,7 @@ int audio_convertAudio()
|
||||
if (c & 4) {
|
||||
SDL_strlcat(message, " Frequencies", 128);
|
||||
}
|
||||
SDLTest_Log(message);
|
||||
SDLTest_Log("%s", message);
|
||||
/* All source conversions with random conversion targets */
|
||||
for (i = 0; i < _numAudioFormats; i++) {
|
||||
for (j = 0; j < _numAudioChannels; j++) {
|
||||
@@ -725,7 +873,7 @@ int audio_convertAudio()
|
||||
i, _audioFormatsVerbose[i], spec1.format, j, spec1.channels, k, spec1.freq, ii, _audioFormatsVerbose[ii], spec2.format, jj, spec2.channels, kk, spec2.freq);
|
||||
SDLTest_AssertCheck(result == 1, "Verify result value; expected: 1, got: %i", result);
|
||||
if (result != 1) {
|
||||
SDLTest_LogError(SDL_GetError());
|
||||
SDLTest_LogError("%s", SDL_GetError());
|
||||
} else {
|
||||
SDLTest_AssertCheck(cvt.len_mult > 0, "Verify that cvt.len_mult value; expected: >0, got: %i", cvt.len_mult);
|
||||
if (cvt.len_mult < 1) return TEST_ABORTED;
|
||||
@@ -762,7 +910,7 @@ int audio_convertAudio()
|
||||
/**
|
||||
* \brief Opens, checks current connected status, and closes a device.
|
||||
*
|
||||
* \sa http://wiki.libsdl.org/moin.cgi/SDL_AudioDeviceConnected
|
||||
* \sa https://wiki.libsdl.org/SDL_AudioDeviceConnected
|
||||
*/
|
||||
int audio_openCloseAudioDeviceConnected()
|
||||
{
|
||||
@@ -865,23 +1013,20 @@ static const SDLTest_TestCaseReference audioTest11 =
|
||||
static const SDLTest_TestCaseReference audioTest12 =
|
||||
{ (SDLTest_TestCaseFp)audio_quitInitAudioSubSystem, "audio_quitInitAudioSubSystem", "Quit and re-init audio subsystem.", TEST_ENABLED };
|
||||
|
||||
/* TODO: enable when bugs 1343 and 1396 are fixed. */
|
||||
/* For debugging, test case can be run manually using --filter audio_initQuitAudio */
|
||||
|
||||
static const SDLTest_TestCaseReference audioTest13 =
|
||||
{ (SDLTest_TestCaseFp)audio_initQuitAudio, "audio_initQuitAudio", "Init and quit audio drivers directly.", TEST_DISABLED };
|
||||
|
||||
/* TODO: enable when bugs 1343 and 1396 are fixed. */
|
||||
/* For debugging, test case can be run manually using --filter audio_initOpenCloseQuitAudio */
|
||||
{ (SDLTest_TestCaseFp)audio_initQuitAudio, "audio_initQuitAudio", "Init and quit audio drivers directly.", TEST_ENABLED };
|
||||
|
||||
static const SDLTest_TestCaseReference audioTest14 =
|
||||
{ (SDLTest_TestCaseFp)audio_initOpenCloseQuitAudio, "audio_initOpenCloseQuitAudio", "Cycle through init, open, close and quit with various audio specs.", TEST_DISABLED };
|
||||
{ (SDLTest_TestCaseFp)audio_initOpenCloseQuitAudio, "audio_initOpenCloseQuitAudio", "Cycle through init, open, close and quit with various audio specs.", TEST_ENABLED };
|
||||
|
||||
static const SDLTest_TestCaseReference audioTest15 =
|
||||
{ (SDLTest_TestCaseFp)audio_pauseUnpauseAudio, "audio_pauseUnpauseAudio", "Pause and Unpause audio for various audio specs while testing callback.", TEST_ENABLED };
|
||||
|
||||
/* Sequence of Audio test cases */
|
||||
static const SDLTest_TestCaseReference *audioTests[] = {
|
||||
&audioTest1, &audioTest2, &audioTest3, &audioTest4, &audioTest5, &audioTest6,
|
||||
&audioTest7, &audioTest8, &audioTest9, &audioTest10, &audioTest11,
|
||||
&audioTest12, &audioTest13, &audioTest14, NULL
|
||||
&audioTest12, &audioTest13, &audioTest14, &audioTest15, NULL
|
||||
};
|
||||
|
||||
/* Audio test suite (global) */
|
||||
@@ -889,5 +1034,5 @@ SDLTest_TestSuiteReference audioTestSuite = {
|
||||
"Audio",
|
||||
_audioSetUp,
|
||||
audioTests,
|
||||
NULL
|
||||
_audioTearDown
|
||||
};
|
||||
|
||||
@@ -79,14 +79,16 @@ char* _RGBPixelFormatsVerbose[] =
|
||||
};
|
||||
|
||||
/* Definition of all Non-RGB formats used to test pixel conversions */
|
||||
const int _numNonRGBPixelFormats = 5;
|
||||
const int _numNonRGBPixelFormats = 7;
|
||||
Uint32 _nonRGBPixelFormats[] =
|
||||
{
|
||||
SDL_PIXELFORMAT_YV12,
|
||||
SDL_PIXELFORMAT_IYUV,
|
||||
SDL_PIXELFORMAT_YUY2,
|
||||
SDL_PIXELFORMAT_UYVY,
|
||||
SDL_PIXELFORMAT_YVYU
|
||||
SDL_PIXELFORMAT_YVYU,
|
||||
SDL_PIXELFORMAT_NV12,
|
||||
SDL_PIXELFORMAT_NV21
|
||||
};
|
||||
char* _nonRGBPixelFormatsVerbose[] =
|
||||
{
|
||||
@@ -94,7 +96,9 @@ char* _nonRGBPixelFormatsVerbose[] =
|
||||
"SDL_PIXELFORMAT_IYUV",
|
||||
"SDL_PIXELFORMAT_YUY2",
|
||||
"SDL_PIXELFORMAT_UYVY",
|
||||
"SDL_PIXELFORMAT_YVYU"
|
||||
"SDL_PIXELFORMAT_YVYU",
|
||||
"SDL_PIXELFORMAT_NV12",
|
||||
"SDL_PIXELFORMAT_NV21"
|
||||
};
|
||||
|
||||
/* Definition of some invalid formats for negative tests */
|
||||
|
||||
@@ -309,7 +309,7 @@ rwops_testFileRead(void)
|
||||
if (rw == NULL) return TEST_ABORTED;
|
||||
|
||||
/* Check type */
|
||||
#if defined(ANDROID)
|
||||
#if defined(__ANDROID__)
|
||||
SDLTest_AssertCheck(
|
||||
rw->type == SDL_RWOPS_STDFILE || rw->type == SDL_RWOPS_JNIFILE,
|
||||
"Verify RWops type is SDL_RWOPS_STDFILE or SDL_RWOPS_JNIFILE; expected: %d|%d, got: %d", SDL_RWOPS_STDFILE, SDL_RWOPS_JNIFILE, rw->type);
|
||||
@@ -356,7 +356,7 @@ rwops_testFileWrite(void)
|
||||
if (rw == NULL) return TEST_ABORTED;
|
||||
|
||||
/* Check type */
|
||||
#if defined(ANDROID)
|
||||
#if defined(__ANDROID__)
|
||||
SDLTest_AssertCheck(
|
||||
rw->type == SDL_RWOPS_STDFILE || rw->type == SDL_RWOPS_JNIFILE,
|
||||
"Verify RWops type is SDL_RWOPS_STDFILE or SDL_RWOPS_JNIFILE; expected: %d|%d, got: %d", SDL_RWOPS_STDFILE, SDL_RWOPS_JNIFILE, rw->type);
|
||||
|
||||
@@ -119,6 +119,140 @@ stdlib_snprintf(void *arg)
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Call to SDL_getenv and SDL_setenv
|
||||
*/
|
||||
int
|
||||
stdlib_getsetenv(void *arg)
|
||||
{
|
||||
const int nameLen = 16;
|
||||
char name[17];
|
||||
int counter;
|
||||
int result;
|
||||
char * value1;
|
||||
char * value2;
|
||||
char * expected;
|
||||
int overwrite;
|
||||
char * text;
|
||||
|
||||
/* Create a random name. This tests SDL_getenv, since we need to */
|
||||
/* make sure the variable is not set yet (it shouldn't). */
|
||||
do {
|
||||
for(counter = 0; counter < nameLen; counter++) {
|
||||
name[counter] = (char)SDLTest_RandomIntegerInRange(65, 90);
|
||||
}
|
||||
name[nameLen] = '\0';
|
||||
|
||||
text = SDL_getenv(name);
|
||||
SDLTest_AssertPass("Call to SDL_getenv('%s')", name);
|
||||
if (text != NULL) {
|
||||
SDLTest_Log("Expected: NULL, Got: '%s' (%i)", text, SDL_strlen(text));
|
||||
}
|
||||
} while (text != NULL);
|
||||
|
||||
/* Create random values to set */
|
||||
value1 = SDLTest_RandomAsciiStringOfSize(10);
|
||||
value2 = SDLTest_RandomAsciiStringOfSize(10);
|
||||
|
||||
/* Set value 1 without overwrite */
|
||||
overwrite = 0;
|
||||
expected = value1;
|
||||
result = SDL_setenv(name, value1, overwrite);
|
||||
SDLTest_AssertPass("Call to SDL_setenv('%s','%s', %i)", name, value1, overwrite);
|
||||
SDLTest_AssertCheck(result == 0, "Check result, expected: 0, got: %i", result);
|
||||
|
||||
/* Check value */
|
||||
text = SDL_getenv(name);
|
||||
SDLTest_AssertPass("Call to SDL_getenv('%s')", name);
|
||||
SDLTest_AssertCheck(text != NULL, "Verify returned text is not NULL");
|
||||
if (text != NULL) {
|
||||
SDLTest_AssertCheck(
|
||||
SDL_strcmp(text, expected) == 0,
|
||||
"Verify returned text, expected: %s, got: %s",
|
||||
expected,
|
||||
text);
|
||||
}
|
||||
|
||||
/* Set value 2 with overwrite */
|
||||
overwrite = 1;
|
||||
expected = value2;
|
||||
result = SDL_setenv(name, value2, overwrite);
|
||||
SDLTest_AssertPass("Call to SDL_setenv('%s','%s', %i)", name, value2, overwrite);
|
||||
SDLTest_AssertCheck(result == 0, "Check result, expected: 0, got: %i", result);
|
||||
|
||||
/* Check value */
|
||||
text = SDL_getenv(name);
|
||||
SDLTest_AssertPass("Call to SDL_getenv('%s')", name);
|
||||
SDLTest_AssertCheck(text != NULL, "Verify returned text is not NULL");
|
||||
if (text != NULL) {
|
||||
SDLTest_AssertCheck(
|
||||
SDL_strcmp(text, expected) == 0,
|
||||
"Verify returned text, expected: %s, got: %s",
|
||||
expected,
|
||||
text);
|
||||
}
|
||||
|
||||
/* Set value 1 without overwrite */
|
||||
overwrite = 0;
|
||||
expected = value2;
|
||||
result = SDL_setenv(name, value1, overwrite);
|
||||
SDLTest_AssertPass("Call to SDL_setenv('%s','%s', %i)", name, value1, overwrite);
|
||||
SDLTest_AssertCheck(result == 0, "Check result, expected: 0, got: %i", result);
|
||||
|
||||
/* Check value */
|
||||
text = SDL_getenv(name);
|
||||
SDLTest_AssertPass("Call to SDL_getenv('%s')", name);
|
||||
SDLTest_AssertCheck(text != NULL, "Verify returned text is not NULL");
|
||||
if (text != NULL) {
|
||||
SDLTest_AssertCheck(
|
||||
SDL_strcmp(text, expected) == 0,
|
||||
"Verify returned text, expected: %s, got: %s",
|
||||
expected,
|
||||
text);
|
||||
}
|
||||
|
||||
/* Set value 1 without overwrite */
|
||||
overwrite = 1;
|
||||
expected = value1;
|
||||
result = SDL_setenv(name, value1, overwrite);
|
||||
SDLTest_AssertPass("Call to SDL_setenv('%s','%s', %i)", name, value1, overwrite);
|
||||
SDLTest_AssertCheck(result == 0, "Check result, expected: 0, got: %i", result);
|
||||
|
||||
/* Check value */
|
||||
text = SDL_getenv(name);
|
||||
SDLTest_AssertPass("Call to SDL_getenv('%s')", name);
|
||||
SDLTest_AssertCheck(text != NULL, "Verify returned text is not NULL");
|
||||
if (text != NULL) {
|
||||
SDLTest_AssertCheck(
|
||||
SDL_strcmp(text, expected) == 0,
|
||||
"Verify returned text, expected: %s, got: %s",
|
||||
expected,
|
||||
text);
|
||||
}
|
||||
|
||||
/* Negative cases */
|
||||
for (overwrite=0; overwrite <= 1; overwrite++) {
|
||||
result = SDL_setenv(NULL, value1, overwrite);
|
||||
SDLTest_AssertPass("Call to SDL_setenv(NULL,'%s', %i)", value1, overwrite);
|
||||
SDLTest_AssertCheck(result == -1, "Check result, expected: -1, got: %i", result);
|
||||
result = SDL_setenv("", value1, overwrite);
|
||||
SDLTest_AssertPass("Call to SDL_setenv('','%s', %i)", value1, overwrite);
|
||||
SDLTest_AssertCheck(result == -1, "Check result, expected: -1, got: %i", result);
|
||||
result = SDL_setenv("=", value1, overwrite);
|
||||
SDLTest_AssertPass("Call to SDL_setenv('=','%s', %i)", value1, overwrite);
|
||||
SDLTest_AssertCheck(result == -1, "Check result, expected: -1, got: %i", result);
|
||||
result = SDL_setenv(name, NULL, overwrite);
|
||||
SDLTest_AssertPass("Call to SDL_setenv('%s', NULL, %i)", name, overwrite);
|
||||
SDLTest_AssertCheck(result == -1, "Check result, expected: -1, got: %i", result);
|
||||
}
|
||||
|
||||
/* Clean up */
|
||||
SDL_free(value1);
|
||||
SDL_free(value2);
|
||||
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
/* ================= Test References ================== */
|
||||
|
||||
/* Standard C routine test cases */
|
||||
@@ -128,14 +262,17 @@ static const SDLTest_TestCaseReference stdlibTest1 =
|
||||
static const SDLTest_TestCaseReference stdlibTest2 =
|
||||
{ (SDLTest_TestCaseFp)stdlib_snprintf, "stdlib_snprintf", "Call to SDL_snprintf", TEST_ENABLED };
|
||||
|
||||
static const SDLTest_TestCaseReference stdlibTest3 =
|
||||
{ (SDLTest_TestCaseFp)stdlib_getsetenv, "stdlib_getsetenv", "Call to SDL_getenv and SDL_setenv", TEST_ENABLED };
|
||||
|
||||
/* Sequence of Standard C routine test cases */
|
||||
static const SDLTest_TestCaseReference *stdlibTests[] = {
|
||||
&stdlibTest1, &stdlibTest2, NULL
|
||||
&stdlibTest1, &stdlibTest2, &stdlibTest3, NULL
|
||||
};
|
||||
|
||||
/* Timer test suite (global) */
|
||||
SDLTest_TestSuiteReference stdlibTestSuite = {
|
||||
"Standard C routines",
|
||||
"Stdlib",
|
||||
NULL,
|
||||
stdlibTests,
|
||||
NULL
|
||||
|
||||
@@ -26,6 +26,7 @@ extern SDLTest_TestSuiteReference surfaceTestSuite;
|
||||
extern SDLTest_TestSuiteReference syswmTestSuite;
|
||||
extern SDLTest_TestSuiteReference timerTestSuite;
|
||||
extern SDLTest_TestSuiteReference videoTestSuite;
|
||||
extern SDLTest_TestSuiteReference hintsTestSuite;
|
||||
|
||||
/* All test suites */
|
||||
SDLTest_TestSuiteReference *testSuites[] = {
|
||||
@@ -46,6 +47,7 @@ SDLTest_TestSuiteReference *testSuites[] = {
|
||||
&syswmTestSuite,
|
||||
&timerTestSuite,
|
||||
&videoTestSuite,
|
||||
&hintsTestSuite,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
@@ -13,6 +13,10 @@
|
||||
#include "SDL.h"
|
||||
#include "SDL_test.h"
|
||||
|
||||
#ifdef __MACOSX__
|
||||
#include <unistd.h> /* For unlink() */
|
||||
#endif
|
||||
|
||||
/* ================= Test Case Implementation ================== */
|
||||
|
||||
/* Shared test surface */
|
||||
|
||||
@@ -14,25 +14,22 @@
|
||||
|
||||
/* Sample program: Draw a Chess Board by using SDL_CreateSoftwareRenderer API */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "SDL.h"
|
||||
|
||||
void
|
||||
DrawChessBoard(SDL_Renderer * renderer)
|
||||
{
|
||||
int row = 0,coloum = 0,x = 0;
|
||||
int row = 0,column = 0,x = 0;
|
||||
SDL_Rect rect, darea;
|
||||
|
||||
/* Get the Size of drawing surface */
|
||||
SDL_RenderGetViewport(renderer, &darea);
|
||||
|
||||
for(row; row < 8; row++)
|
||||
for( ; row < 8; row++)
|
||||
{
|
||||
coloum = row%2;
|
||||
x = x + coloum;
|
||||
for(coloum; coloum < 4+(row%2); coloum++)
|
||||
column = row%2;
|
||||
x = x + column;
|
||||
for( ; column < 4+(row%2); column++)
|
||||
{
|
||||
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0xFF);
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ main(int argc, char *argv[])
|
||||
int consumed;
|
||||
|
||||
consumed = SDLTest_CommonArg(state, i);
|
||||
// needed vodoo to allow app to launch via OS X Finder
|
||||
/* needed voodoo to allow app to launch via OS X Finder */
|
||||
if (SDL_strncmp(argv[i], "-psn", 4)==0) {
|
||||
consumed = 1;
|
||||
}
|
||||
|
||||
@@ -28,51 +28,6 @@
|
||||
#define SCREEN_HEIGHT 317
|
||||
#endif
|
||||
|
||||
static const char *
|
||||
ControllerAxisName(const SDL_GameControllerAxis axis)
|
||||
{
|
||||
switch (axis)
|
||||
{
|
||||
#define AXIS_CASE(ax) case SDL_CONTROLLER_AXIS_##ax: return #ax
|
||||
AXIS_CASE(INVALID);
|
||||
AXIS_CASE(LEFTX);
|
||||
AXIS_CASE(LEFTY);
|
||||
AXIS_CASE(RIGHTX);
|
||||
AXIS_CASE(RIGHTY);
|
||||
AXIS_CASE(TRIGGERLEFT);
|
||||
AXIS_CASE(TRIGGERRIGHT);
|
||||
#undef AXIS_CASE
|
||||
default: return "???";
|
||||
}
|
||||
}
|
||||
|
||||
static const char *
|
||||
ControllerButtonName(const SDL_GameControllerButton button)
|
||||
{
|
||||
switch (button)
|
||||
{
|
||||
#define BUTTON_CASE(btn) case SDL_CONTROLLER_BUTTON_##btn: return #btn
|
||||
BUTTON_CASE(INVALID);
|
||||
BUTTON_CASE(A);
|
||||
BUTTON_CASE(B);
|
||||
BUTTON_CASE(X);
|
||||
BUTTON_CASE(Y);
|
||||
BUTTON_CASE(BACK);
|
||||
BUTTON_CASE(GUIDE);
|
||||
BUTTON_CASE(START);
|
||||
BUTTON_CASE(LEFTSTICK);
|
||||
BUTTON_CASE(RIGHTSTICK);
|
||||
BUTTON_CASE(LEFTSHOULDER);
|
||||
BUTTON_CASE(RIGHTSHOULDER);
|
||||
BUTTON_CASE(DPAD_UP);
|
||||
BUTTON_CASE(DPAD_DOWN);
|
||||
BUTTON_CASE(DPAD_LEFT);
|
||||
BUTTON_CASE(DPAD_RIGHT);
|
||||
#undef BUTTON_CASE
|
||||
default: return "???";
|
||||
}
|
||||
}
|
||||
|
||||
static SDL_Texture *
|
||||
LoadTexture(SDL_Renderer *renderer, char *file, SDL_bool transparent)
|
||||
{
|
||||
@@ -85,9 +40,13 @@ LoadTexture(SDL_Renderer *renderer, char *file, SDL_bool transparent)
|
||||
} else {
|
||||
/* Set transparent pixel as the pixel at (0,0) */
|
||||
if (transparent) {
|
||||
SDL_assert(!temp->format->palette);
|
||||
SDL_assert(temp->format->BitsPerPixel == 24);
|
||||
SDL_SetColorKey(temp, SDL_TRUE, (*(Uint32 *) temp->pixels) & 0x00FFFFFF);
|
||||
if (temp->format->BytesPerPixel == 1) {
|
||||
SDL_SetColorKey(temp, SDL_TRUE, *(Uint8 *)temp->pixels);
|
||||
} else {
|
||||
SDL_assert(!temp->format->palette);
|
||||
SDL_assert(temp->format->BitsPerPixel == 24);
|
||||
SDL_SetColorKey(temp, SDL_TRUE, (*(Uint32 *)temp->pixels) & 0x00FFFFFF);
|
||||
}
|
||||
}
|
||||
|
||||
texture = SDL_CreateTextureFromSurface(renderer, temp);
|
||||
|
||||
@@ -22,28 +22,6 @@
|
||||
#include "SDL_touch.h"
|
||||
#include "SDL_gesture.h"
|
||||
|
||||
/* Make sure we have good macros for printing 32 and 64 bit values */
|
||||
#ifndef PRIs32
|
||||
#define PRIs32 "d"
|
||||
#endif
|
||||
#ifndef PRIu32
|
||||
#define PRIu32 "u"
|
||||
#endif
|
||||
#ifndef PRIs64
|
||||
#ifdef __WIN32__
|
||||
#define PRIs64 "I64"
|
||||
#else
|
||||
#define PRIs64 "lld"
|
||||
#endif
|
||||
#endif
|
||||
#ifndef PRIu64
|
||||
#ifdef __WIN32__
|
||||
#define PRIu64 "I64u"
|
||||
#else
|
||||
#define PRIu64 "llu"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define WIDTH 640
|
||||
#define HEIGHT 480
|
||||
#define BPP 4
|
||||
@@ -266,19 +244,19 @@ int main(int argc, char* argv[])
|
||||
break;
|
||||
case SDL_FINGERMOTION:
|
||||
#if VERBOSE
|
||||
SDL_Log("Finger: %i,x: %i, y: %i",event.tfinger.fingerId,
|
||||
SDL_Log("Finger: %"SDL_PRIs64",x: %f, y: %f",event.tfinger.fingerId,
|
||||
event.tfinger.x,event.tfinger.y);
|
||||
#endif
|
||||
break;
|
||||
case SDL_FINGERDOWN:
|
||||
#if VERBOSE
|
||||
SDL_Log("Finger: %"PRIs64" down - x: %i, y: %i",
|
||||
SDL_Log("Finger: %"SDL_PRIs64" down - x: %f, y: %f",
|
||||
event.tfinger.fingerId,event.tfinger.x,event.tfinger.y);
|
||||
#endif
|
||||
break;
|
||||
case SDL_FINGERUP:
|
||||
#if VERBOSE
|
||||
SDL_Log("Finger: %"PRIs64" up - x: %i, y: %i",
|
||||
SDL_Log("Finger: %"SDL_PRIs64" up - x: %f, y: %f",
|
||||
event.tfinger.fingerId,event.tfinger.x,event.tfinger.y);
|
||||
#endif
|
||||
break;
|
||||
@@ -297,12 +275,12 @@ int main(int argc, char* argv[])
|
||||
knob.r += event.mgesture.dDist;
|
||||
break;
|
||||
case SDL_DOLLARGESTURE:
|
||||
SDL_Log("Gesture %"PRIs64" performed, error: %f",
|
||||
SDL_Log("Gesture %"SDL_PRIs64" performed, error: %f",
|
||||
event.dgesture.gestureId,
|
||||
event.dgesture.error);
|
||||
break;
|
||||
case SDL_DOLLARRECORD:
|
||||
SDL_Log("Recorded gesture: %"PRIs64"",event.dgesture.gestureId);
|
||||
SDL_Log("Recorded gesture: %"SDL_PRIs64"",event.dgesture.gestureId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
#include "SDL_test_common.h"
|
||||
|
||||
#if defined(__IPHONEOS__) || defined(__ANDROID__)
|
||||
#if defined(__IPHONEOS__) || defined(__ANDROID__) || defined(__NACL__)
|
||||
#define HAVE_OPENGLES2
|
||||
#endif
|
||||
|
||||
@@ -99,19 +99,19 @@ quit(int rc)
|
||||
* order.
|
||||
*/
|
||||
static void
|
||||
rotate_matrix(double angle, double x, double y, double z, float *r)
|
||||
rotate_matrix(float angle, float x, float y, float z, float *r)
|
||||
{
|
||||
double radians, c, s, c1, u[3], length;
|
||||
float radians, c, s, c1, u[3], length;
|
||||
int i, j;
|
||||
|
||||
radians = (angle * M_PI) / 180.0;
|
||||
radians = (float)(angle * M_PI) / 180.0f;
|
||||
|
||||
c = cos(radians);
|
||||
s = sin(radians);
|
||||
c = SDL_cosf(radians);
|
||||
s = SDL_sinf(radians);
|
||||
|
||||
c1 = 1.0 - cos(radians);
|
||||
c1 = 1.0f - SDL_cosf(radians);
|
||||
|
||||
length = sqrt(x * x + y * y + z * z);
|
||||
length = (float)SDL_sqrt(x * x + y * y + z * z);
|
||||
|
||||
u[0] = x / length;
|
||||
u[1] = y / length;
|
||||
@@ -130,7 +130,7 @@ rotate_matrix(double angle, double x, double y, double z, float *r)
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
for (j = 0; j < 3; j++) {
|
||||
r[i * 4 + j] += c1 * u[i] * u[j] + (i == j ? c : 0.0);
|
||||
r[i * 4 + j] += c1 * u[i] * u[j] + (i == j ? c : 0.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -139,12 +139,12 @@ rotate_matrix(double angle, double x, double y, double z, float *r)
|
||||
* Simulates gluPerspectiveMatrix
|
||||
*/
|
||||
static void
|
||||
perspective_matrix(double fovy, double aspect, double znear, double zfar, float *r)
|
||||
perspective_matrix(float fovy, float aspect, float znear, float zfar, float *r)
|
||||
{
|
||||
int i;
|
||||
double f;
|
||||
float f;
|
||||
|
||||
f = 1.0/tan(fovy * 0.5);
|
||||
f = 1.0f/SDL_tanf(fovy * 0.5f);
|
||||
|
||||
for (i = 0; i < 16; i++) {
|
||||
r[i] = 0.0;
|
||||
@@ -153,9 +153,9 @@ perspective_matrix(double fovy, double aspect, double znear, double zfar, float
|
||||
r[0] = f / aspect;
|
||||
r[5] = f;
|
||||
r[10] = (znear + zfar) / (znear - zfar);
|
||||
r[11] = -1.0;
|
||||
r[14] = (2.0 * znear * zfar) / (znear - zfar);
|
||||
r[15] = 0.0;
|
||||
r[11] = -1.0f;
|
||||
r[14] = (2.0f * znear * zfar) / (znear - zfar);
|
||||
r[15] = 0.0f;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -195,6 +195,8 @@ process_shader(GLuint *shader, const char * source, GLint shader_type)
|
||||
{
|
||||
GLint status = GL_FALSE;
|
||||
const char *shaders[1] = { NULL };
|
||||
char buffer[1024];
|
||||
GLsizei length;
|
||||
|
||||
/* Create shader and load into GL. */
|
||||
*shader = GL_CHECK(ctx.glCreateShader(shader_type));
|
||||
@@ -210,9 +212,11 @@ process_shader(GLuint *shader, const char * source, GLint shader_type)
|
||||
GL_CHECK(ctx.glCompileShader(*shader));
|
||||
GL_CHECK(ctx.glGetShaderiv(*shader, GL_COMPILE_STATUS, &status));
|
||||
|
||||
// Dump debug info (source and log) if compilation failed.
|
||||
/* Dump debug info (source and log) if compilation failed. */
|
||||
if(status != GL_TRUE) {
|
||||
SDL_Log("Shader compilation failed");
|
||||
ctx.glGetProgramInfoLog(*shader, sizeof(buffer), &length, &buffer[0]);
|
||||
buffer[length] = '\0';
|
||||
SDL_Log("Shader compilation failed: %s", buffer);fflush(stderr);
|
||||
quit(-1);
|
||||
}
|
||||
}
|
||||
@@ -372,19 +376,19 @@ Render(unsigned int width, unsigned int height, shader_data* data)
|
||||
* Do some rotation with Euler angles. It is not a fixed axis as
|
||||
* quaterions would be, but the effect is cool.
|
||||
*/
|
||||
rotate_matrix(data->angle_x, 1.0, 0.0, 0.0, matrix_modelview);
|
||||
rotate_matrix(data->angle_y, 0.0, 1.0, 0.0, matrix_rotate);
|
||||
rotate_matrix((float)data->angle_x, 1.0f, 0.0f, 0.0f, matrix_modelview);
|
||||
rotate_matrix((float)data->angle_y, 0.0f, 1.0f, 0.0f, matrix_rotate);
|
||||
|
||||
multiply_matrix(matrix_rotate, matrix_modelview, matrix_modelview);
|
||||
|
||||
rotate_matrix(data->angle_z, 0.0, 1.0, 0.0, matrix_rotate);
|
||||
rotate_matrix((float)data->angle_z, 0.0f, 1.0f, 0.0f, matrix_rotate);
|
||||
|
||||
multiply_matrix(matrix_rotate, matrix_modelview, matrix_modelview);
|
||||
|
||||
/* Pull the camera back from the cube */
|
||||
matrix_modelview[14] -= 2.5;
|
||||
|
||||
perspective_matrix(45.0, (double)width/(double)height, 0.01, 100.0, matrix_perspective);
|
||||
perspective_matrix(45.0f, (float)width/height, 0.01f, 100.0f, matrix_perspective);
|
||||
multiply_matrix(matrix_perspective, matrix_modelview, matrix_mvp);
|
||||
|
||||
GL_CHECK(ctx.glUniformMatrix4fv(data->attr_mvp, 1, GL_FALSE, matrix_mvp));
|
||||
@@ -675,7 +679,7 @@ main(int argc, char *argv[])
|
||||
SDL_Log("%2.2f frames per second\n",
|
||||
((double) frames * 1000) / (now - then));
|
||||
}
|
||||
#if !defined(__ANDROID__)
|
||||
#if !defined(__ANDROID__) && !defined(__NACL__)
|
||||
quit(0);
|
||||
#endif
|
||||
return 0;
|
||||
|
||||
@@ -1,14 +1,3 @@
|
||||
/*
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely.
|
||||
*/
|
||||
/*
|
||||
Copyright (c) 2008, Edgar Simo Serra
|
||||
All rights reserved.
|
||||
@@ -56,8 +45,8 @@ main(int argc, char **argv)
|
||||
int i;
|
||||
char *name;
|
||||
int index;
|
||||
SDL_HapticEffect efx[5];
|
||||
int id[5];
|
||||
SDL_HapticEffect efx[9];
|
||||
int id[9];
|
||||
int nefx;
|
||||
unsigned int supported;
|
||||
|
||||
@@ -133,7 +122,8 @@ main(int argc, char **argv)
|
||||
SDL_Log(" effect %d: Sine Wave\n", nefx);
|
||||
efx[nefx].type = SDL_HAPTIC_SINE;
|
||||
efx[nefx].periodic.period = 1000;
|
||||
efx[nefx].periodic.magnitude = 0x4000;
|
||||
efx[nefx].periodic.magnitude = -0x2000; /* Negative magnitude and ... */
|
||||
efx[nefx].periodic.phase = 18000; /* ... 180 degrees phase shift => cancel eachother */
|
||||
efx[nefx].periodic.length = 5000;
|
||||
efx[nefx].periodic.attack_length = 1000;
|
||||
efx[nefx].periodic.fade_length = 1000;
|
||||
@@ -160,6 +150,7 @@ main(int argc, char **argv)
|
||||
}
|
||||
nefx++;
|
||||
}
|
||||
|
||||
/* Now the classical constant effect. */
|
||||
if (supported & SDL_HAPTIC_CONSTANT) {
|
||||
SDL_Log(" effect %d: Constant Force\n", nefx);
|
||||
@@ -177,14 +168,15 @@ main(int argc, char **argv)
|
||||
}
|
||||
nefx++;
|
||||
}
|
||||
|
||||
/* The cute spring effect. */
|
||||
if (supported & SDL_HAPTIC_SPRING) {
|
||||
SDL_Log(" effect %d: Condition Spring\n", nefx);
|
||||
efx[nefx].type = SDL_HAPTIC_SPRING;
|
||||
efx[nefx].condition.length = 5000;
|
||||
for (i = 0; i < SDL_HapticNumAxes(haptic); i++) {
|
||||
efx[nefx].condition.right_sat[i] = 0x7FFF;
|
||||
efx[nefx].condition.left_sat[i] = 0x7FFF;
|
||||
efx[nefx].condition.right_sat[i] = 0xFFFF;
|
||||
efx[nefx].condition.left_sat[i] = 0xFFFF;
|
||||
efx[nefx].condition.right_coeff[i] = 0x2000;
|
||||
efx[nefx].condition.left_coeff[i] = 0x2000;
|
||||
efx[nefx].condition.center[i] = 0x1000; /* Displace the center for it to move. */
|
||||
@@ -196,14 +188,14 @@ main(int argc, char **argv)
|
||||
}
|
||||
nefx++;
|
||||
}
|
||||
/* The pretty awesome inertia effect. */
|
||||
if (supported & SDL_HAPTIC_INERTIA) {
|
||||
SDL_Log(" effect %d: Condition Inertia\n", nefx);
|
||||
efx[nefx].type = SDL_HAPTIC_SPRING;
|
||||
/* The interesting damper effect. */
|
||||
if (supported & SDL_HAPTIC_DAMPER) {
|
||||
SDL_Log(" effect %d: Condition Damper\n", nefx);
|
||||
efx[nefx].type = SDL_HAPTIC_DAMPER;
|
||||
efx[nefx].condition.length = 5000;
|
||||
for (i = 0; i < SDL_HapticNumAxes(haptic); i++) {
|
||||
efx[nefx].condition.right_sat[i] = 0x7FFF;
|
||||
efx[nefx].condition.left_sat[i] = 0x7FFF;
|
||||
efx[nefx].condition.right_sat[i] = 0xFFFF;
|
||||
efx[nefx].condition.left_sat[i] = 0xFFFF;
|
||||
efx[nefx].condition.right_coeff[i] = 0x2000;
|
||||
efx[nefx].condition.left_coeff[i] = 0x2000;
|
||||
}
|
||||
@@ -214,6 +206,63 @@ main(int argc, char **argv)
|
||||
}
|
||||
nefx++;
|
||||
}
|
||||
/* The pretty awesome inertia effect. */
|
||||
if (supported & SDL_HAPTIC_INERTIA) {
|
||||
SDL_Log(" effect %d: Condition Inertia\n", nefx);
|
||||
efx[nefx].type = SDL_HAPTIC_INERTIA;
|
||||
efx[nefx].condition.length = 5000;
|
||||
for (i = 0; i < SDL_HapticNumAxes(haptic); i++) {
|
||||
efx[nefx].condition.right_sat[i] = 0xFFFF;
|
||||
efx[nefx].condition.left_sat[i] = 0xFFFF;
|
||||
efx[nefx].condition.right_coeff[i] = 0x2000;
|
||||
efx[nefx].condition.left_coeff[i] = 0x2000;
|
||||
efx[nefx].condition.deadband[i] = 0x1000; /* 1/16th of axis-range around the center is 'dead'. */
|
||||
}
|
||||
id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]);
|
||||
if (id[nefx] < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
|
||||
abort_execution();
|
||||
}
|
||||
nefx++;
|
||||
}
|
||||
/* The hot friction effect. */
|
||||
if (supported & SDL_HAPTIC_FRICTION) {
|
||||
SDL_Log(" effect %d: Condition Friction\n", nefx);
|
||||
efx[nefx].type = SDL_HAPTIC_FRICTION;
|
||||
efx[nefx].condition.length = 5000;
|
||||
for (i = 0; i < SDL_HapticNumAxes(haptic); i++) {
|
||||
efx[nefx].condition.right_sat[i] = 0xFFFF;
|
||||
efx[nefx].condition.left_sat[i] = 0xFFFF;
|
||||
efx[nefx].condition.right_coeff[i] = 0x2000;
|
||||
efx[nefx].condition.left_coeff[i] = 0x2000;
|
||||
}
|
||||
id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]);
|
||||
if (id[nefx] < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
|
||||
abort_execution();
|
||||
}
|
||||
nefx++;
|
||||
}
|
||||
|
||||
/* Now we'll try a ramp effect */
|
||||
if (supported & SDL_HAPTIC_RAMP) {
|
||||
SDL_Log(" effect %d: Ramp\n", 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 */
|
||||
efx[nefx].ramp.direction.dir[1] = -1; /* the north-east. */
|
||||
efx[nefx].ramp.length = 5000;
|
||||
efx[nefx].ramp.start = 0x4000;
|
||||
efx[nefx].ramp.end = -0x4000;
|
||||
efx[nefx].ramp.attack_length = 1000;
|
||||
efx[nefx].ramp.fade_length = 1000;
|
||||
id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]);
|
||||
if (id[nefx] < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
|
||||
abort_execution();
|
||||
}
|
||||
nefx++;
|
||||
}
|
||||
|
||||
/* Finally we'll try a left/right effect. */
|
||||
if (supported & SDL_HAPTIC_LEFTRIGHT) {
|
||||
|
||||
@@ -53,7 +53,9 @@ main(int argc, char *argv[])
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/*
|
||||
//SDL_CreateWindow("Dummy", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 128, 128, 0);
|
||||
*/
|
||||
|
||||
SDL_Log("There are %d joysticks at startup\n", SDL_NumJoysticks());
|
||||
if (enable_haptic)
|
||||
@@ -121,7 +123,9 @@ main(int argc, char *argv[])
|
||||
}
|
||||
break;
|
||||
case SDL_JOYAXISMOTION:
|
||||
/*
|
||||
// SDL_Log("Axis Move: %d\n", event.jaxis.axis);
|
||||
*/
|
||||
if (enable_haptic)
|
||||
SDL_HapticRumblePlay(haptic, 0.25, 250);
|
||||
break;
|
||||
|
||||
@@ -243,7 +243,7 @@ main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ANDROID
|
||||
#ifdef __ANDROID__
|
||||
if (SDL_NumJoysticks() > 0) {
|
||||
#else
|
||||
if (argv[1]) {
|
||||
@@ -252,7 +252,7 @@ main(int argc, char *argv[])
|
||||
SDL_bool keepGoing = SDL_TRUE;
|
||||
SDL_Event event;
|
||||
int device;
|
||||
#ifdef ANDROID
|
||||
#ifdef __ANDROID__
|
||||
device = 0;
|
||||
#else
|
||||
device = atoi(argv[1]);
|
||||
|
||||
@@ -19,8 +19,6 @@
|
||||
#include "SDL.h"
|
||||
#include "SDL_thread.h"
|
||||
|
||||
static int alive = 0;
|
||||
|
||||
/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
|
||||
static void
|
||||
quit(int rc)
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
*/
|
||||
#include "SDL.h"
|
||||
|
||||
#include <stdio.h> /* for fflush() and stdout */
|
||||
|
||||
static SDL_AudioSpec spec;
|
||||
static Uint8 *sound = NULL; /* Pointer to wave data */
|
||||
static Uint32 soundlen = 0; /* Length of wave data */
|
||||
@@ -48,6 +50,12 @@ test_multi_audio(int devcount)
|
||||
callback_data cbd[64];
|
||||
int keep_going = 1;
|
||||
int i;
|
||||
|
||||
#ifdef __ANDROID__
|
||||
SDL_Event event;
|
||||
|
||||
SDL_CreateWindow("testmultiaudio", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 320, 240, 0);
|
||||
#endif
|
||||
|
||||
if (devcount > 64) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Too many devices (%d), clamping to 64...\n",
|
||||
@@ -69,8 +77,12 @@ test_multi_audio(int devcount)
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Open device failed: %s\n", SDL_GetError());
|
||||
} else {
|
||||
SDL_PauseAudioDevice(cbd[0].dev, 0);
|
||||
while (!cbd[0].done)
|
||||
while (!cbd[0].done) {
|
||||
#ifdef __ANDROID__
|
||||
while (SDL_PollEvent(&event)){}
|
||||
#endif
|
||||
SDL_Delay(100);
|
||||
}
|
||||
SDL_PauseAudioDevice(cbd[0].dev, 1);
|
||||
SDL_Log("done.\n");
|
||||
SDL_CloseAudioDevice(cbd[0].dev);
|
||||
@@ -102,6 +114,9 @@ test_multi_audio(int devcount)
|
||||
keep_going = 1;
|
||||
}
|
||||
}
|
||||
#ifdef __ANDROID__
|
||||
while (SDL_PollEvent(&event)){}
|
||||
#endif
|
||||
SDL_Delay(100);
|
||||
}
|
||||
|
||||
@@ -131,7 +146,7 @@ main(int argc, char **argv)
|
||||
}
|
||||
|
||||
SDL_Log("Using audio driver: %s\n", SDL_GetCurrentAudioDriver());
|
||||
|
||||
|
||||
devcount = SDL_GetNumAudioDevices(0);
|
||||
if (devcount < 1) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Don't see any specific audio devices!\n");
|
||||
|
||||
@@ -206,6 +206,29 @@ ConvertRGBtoYV12(Uint8 *rgb, Uint8 *out, int w, int h,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ConvertRGBtoNV12(Uint8 *rgb, Uint8 *out, int w, int h,
|
||||
int monochrome, int luminance)
|
||||
{
|
||||
int x, y;
|
||||
int yuv[3];
|
||||
Uint8 *op[2];
|
||||
|
||||
op[0] = out;
|
||||
op[1] = op[0] + w*h;
|
||||
for (y = 0; y < h; ++y) {
|
||||
for (x = 0; x < w; ++x) {
|
||||
RGBtoYUV(rgb, yuv, monochrome, luminance);
|
||||
*(op[0]++) = yuv[0];
|
||||
if (x % 2 == 0 && y % 2 == 0) {
|
||||
*(op[1]++) = yuv[1];
|
||||
*(op[1]++) = yuv[2];
|
||||
}
|
||||
rgb += 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
PrintUsage(char *argv0)
|
||||
{
|
||||
@@ -241,7 +264,11 @@ main(int argc, char **argv)
|
||||
int fps = 12;
|
||||
int fpsdelay;
|
||||
int nodelay = 0;
|
||||
#ifdef TEST_NV12
|
||||
Uint32 pixel_format = SDL_PIXELFORMAT_NV12;
|
||||
#else
|
||||
Uint32 pixel_format = SDL_PIXELFORMAT_YV12;
|
||||
#endif
|
||||
int scale = 5;
|
||||
SDL_bool done = SDL_FALSE;
|
||||
|
||||
@@ -371,7 +398,17 @@ main(int argc, char **argv)
|
||||
rgb[2] = MooseColors[frame[j]].b;
|
||||
rgb += 3;
|
||||
}
|
||||
ConvertRGBtoYV12(MooseFrameRGB, MooseFrame[i], MOOSEPIC_W, MOOSEPIC_H, 0, 100);
|
||||
switch (pixel_format) {
|
||||
case SDL_PIXELFORMAT_YV12:
|
||||
ConvertRGBtoYV12(MooseFrameRGB, MooseFrame[i], MOOSEPIC_W, MOOSEPIC_H, 0, 100);
|
||||
break;
|
||||
case SDL_PIXELFORMAT_NV12:
|
||||
ConvertRGBtoNV12(MooseFrameRGB, MooseFrame[i], MOOSEPIC_W, MOOSEPIC_H, 0, 100);
|
||||
break;
|
||||
default:
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unsupported pixel format\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
free(RawMooseData);
|
||||
|
||||
@@ -20,22 +20,22 @@
|
||||
|
||||
|
||||
static SDLTest_CommonState *state;
|
||||
static SDL_Rect rect;
|
||||
|
||||
static void
|
||||
DrawRects(SDL_Renderer * renderer)
|
||||
DrawRects(SDL_Renderer * renderer, SDL_Rect * rect)
|
||||
{
|
||||
SDL_SetRenderDrawColor(renderer, 255, 127, 0, 255);
|
||||
SDL_RenderFillRect(renderer,&rect);
|
||||
SDL_RenderFillRect(renderer, rect);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int i, done;
|
||||
SDL_Rect rect;
|
||||
SDL_Event event;
|
||||
|
||||
/* Enable standard application logging */
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
|
||||
/* Initialize test framework */
|
||||
@@ -43,7 +43,7 @@ main(int argc, char *argv[])
|
||||
if (!state) {
|
||||
return 1;
|
||||
}
|
||||
for (i = 1; i < argc;i++) {
|
||||
for (i = 1; i < argc; ++i) {
|
||||
SDLTest_CommonArg(state, i);
|
||||
}
|
||||
if (!SDLTest_CommonInit(state)) {
|
||||
@@ -89,7 +89,7 @@ main(int argc, char *argv[])
|
||||
SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF);
|
||||
SDL_RenderClear(renderer);
|
||||
|
||||
DrawRects(renderer);
|
||||
DrawRects(renderer, &rect);
|
||||
|
||||
SDL_RenderPresent(renderer);
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ int main(int argc,char** argv)
|
||||
int button_down;
|
||||
Uint32 pixelFormat = 0;
|
||||
int access = 0;
|
||||
SDL_Rect texture_dimensions;;
|
||||
SDL_Rect texture_dimensions;
|
||||
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
|
||||
@@ -27,27 +27,27 @@
|
||||
#define MOOSEFRAMES_COUNT 10
|
||||
|
||||
SDL_Color MooseColors[84] = {
|
||||
{49, 49, 49}, {66, 24, 0}, {66, 33, 0}, {66, 66, 66},
|
||||
{66, 115, 49}, {74, 33, 0}, {74, 41, 16}, {82, 33, 8},
|
||||
{82, 41, 8}, {82, 49, 16}, {82, 82, 82}, {90, 41, 8},
|
||||
{90, 41, 16}, {90, 57, 24}, {99, 49, 16}, {99, 66, 24},
|
||||
{99, 66, 33}, {99, 74, 33}, {107, 57, 24}, {107, 82, 41},
|
||||
{115, 57, 33}, {115, 66, 33}, {115, 66, 41}, {115, 74, 0},
|
||||
{115, 90, 49}, {115, 115, 115}, {123, 82, 0}, {123, 99, 57},
|
||||
{132, 66, 41}, {132, 74, 41}, {132, 90, 8}, {132, 99, 33},
|
||||
{132, 99, 66}, {132, 107, 66}, {140, 74, 49}, {140, 99, 16},
|
||||
{140, 107, 74}, {140, 115, 74}, {148, 107, 24}, {148, 115, 82},
|
||||
{148, 123, 74}, {148, 123, 90}, {156, 115, 33}, {156, 115, 90},
|
||||
{156, 123, 82}, {156, 132, 82}, {156, 132, 99}, {156, 156, 156},
|
||||
{165, 123, 49}, {165, 123, 90}, {165, 132, 82}, {165, 132, 90},
|
||||
{165, 132, 99}, {165, 140, 90}, {173, 132, 57}, {173, 132, 99},
|
||||
{173, 140, 107}, {173, 140, 115}, {173, 148, 99}, {173, 173, 173},
|
||||
{181, 140, 74}, {181, 148, 115}, {181, 148, 123}, {181, 156, 107},
|
||||
{189, 148, 123}, {189, 156, 82}, {189, 156, 123}, {189, 156, 132},
|
||||
{189, 189, 189}, {198, 156, 123}, {198, 165, 132}, {206, 165, 99},
|
||||
{206, 165, 132}, {206, 173, 140}, {206, 206, 206}, {214, 173, 115},
|
||||
{214, 173, 140}, {222, 181, 148}, {222, 189, 132}, {222, 189, 156},
|
||||
{222, 222, 222}, {231, 198, 165}, {231, 231, 231}, {239, 206, 173}
|
||||
{49, 49, 49, 255}, {66, 24, 0, 255}, {66, 33, 0, 255}, {66, 66, 66, 255},
|
||||
{66, 115, 49, 255}, {74, 33, 0, 255}, {74, 41, 16, 255}, {82, 33, 8, 255},
|
||||
{82, 41, 8, 255}, {82, 49, 16, 255}, {82, 82, 82, 255}, {90, 41, 8, 255},
|
||||
{90, 41, 16, 255}, {90, 57, 24, 255}, {99, 49, 16, 255}, {99, 66, 24, 255},
|
||||
{99, 66, 33, 255}, {99, 74, 33, 255}, {107, 57, 24, 255}, {107, 82, 41, 255},
|
||||
{115, 57, 33, 255}, {115, 66, 33, 255}, {115, 66, 41, 255}, {115, 74, 0, 255},
|
||||
{115, 90, 49, 255}, {115, 115, 115, 255}, {123, 82, 0, 255}, {123, 99, 57, 255},
|
||||
{132, 66, 41, 255}, {132, 74, 41, 255}, {132, 90, 8, 255}, {132, 99, 33, 255},
|
||||
{132, 99, 66, 255}, {132, 107, 66, 255}, {140, 74, 49, 255}, {140, 99, 16, 255},
|
||||
{140, 107, 74, 255}, {140, 115, 74, 255}, {148, 107, 24, 255}, {148, 115, 82, 255},
|
||||
{148, 123, 74, 255}, {148, 123, 90, 255}, {156, 115, 33, 255}, {156, 115, 90, 255},
|
||||
{156, 123, 82, 255}, {156, 132, 82, 255}, {156, 132, 99, 255}, {156, 156, 156, 255},
|
||||
{165, 123, 49, 255}, {165, 123, 90, 255}, {165, 132, 82, 255}, {165, 132, 90, 255},
|
||||
{165, 132, 99, 255}, {165, 140, 90, 255}, {173, 132, 57, 255}, {173, 132, 99, 255},
|
||||
{173, 140, 107, 255}, {173, 140, 115, 255}, {173, 148, 99, 255}, {173, 173, 173, 255},
|
||||
{181, 140, 74, 255}, {181, 148, 115, 255}, {181, 148, 123, 255}, {181, 156, 107, 255},
|
||||
{189, 148, 123, 255}, {189, 156, 82, 255}, {189, 156, 123, 255}, {189, 156, 132, 255},
|
||||
{189, 189, 189, 255}, {198, 156, 123, 255}, {198, 165, 132, 255}, {206, 165, 99, 255},
|
||||
{206, 165, 132, 255}, {206, 173, 140, 255}, {206, 206, 206, 255}, {214, 173, 115, 255},
|
||||
{214, 173, 140, 255}, {222, 181, 148, 255}, {222, 189, 132, 255}, {222, 189, 156, 255},
|
||||
{222, 222, 222, 255}, {231, 198, 165, 255}, {231, 231, 231, 255}, {239, 206, 173, 255}
|
||||
};
|
||||
|
||||
Uint8 MooseFrames[MOOSEFRAMES_COUNT][MOOSEFRAME_SIZE];
|
||||
|
||||
Reference in New Issue
Block a user