mirror of
https://github.com/encounter/SDL.git
synced 2025-12-21 10:49:12 +00:00
test: Add some common code to load test resources
As well as reducing duplication, this lets the tests load their resources from the SDL_GetBasePath() on platforms that support it, which is useful if the tests are compiled along with the rest of SDL and installed below /usr as manual tests, similar to GNOME's installed-tests convention. Thanks to Ozkan Sezer for the OS/2 build glue. Co-authored-by: Ozkan Sezer <sezeroz@gmail.com> Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
committed by
Sam Lantinga
parent
ecf1e15fec
commit
76a7b629bf
@@ -23,6 +23,7 @@
|
||||
#endif
|
||||
|
||||
#include "SDL.h"
|
||||
#include "testutils.h"
|
||||
|
||||
#define MOOSEPIC_W 64
|
||||
#define MOOSEPIC_H 88
|
||||
@@ -128,6 +129,7 @@ main(int argc, char **argv)
|
||||
{
|
||||
SDL_Window *window;
|
||||
SDL_RWops *handle;
|
||||
char *filename = NULL;
|
||||
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
@@ -138,7 +140,13 @@ main(int argc, char **argv)
|
||||
}
|
||||
|
||||
/* load the moose images */
|
||||
handle = SDL_RWFromFile("moose.dat", "rb");
|
||||
filename = GetResourceFilename(NULL, "moose.dat");
|
||||
if (filename == NULL) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory\n");
|
||||
return -1;
|
||||
}
|
||||
handle = SDL_RWFromFile(filename, "rb");
|
||||
SDL_free(filename);
|
||||
if (handle == NULL) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't find the file moose.dat !\n");
|
||||
quit(2);
|
||||
|
||||
Reference in New Issue
Block a user