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
@@ -458,6 +458,7 @@ main(int argc, char *argv[])
|
||||
Uint32 then, now;
|
||||
int status;
|
||||
shader_data *data;
|
||||
char *path = NULL;
|
||||
|
||||
/* Initialize parameters */
|
||||
fsaa = 0;
|
||||
@@ -561,14 +562,25 @@ main(int argc, char *argv[])
|
||||
|
||||
/* Load SDF BMP image */
|
||||
#if 1
|
||||
tmp = SDL_LoadBMP(f);
|
||||
if (tmp == NULL) {
|
||||
SDL_Log("missing image file: %s", f);
|
||||
path = GetNearbyFilename(f);
|
||||
|
||||
if (path == NULL)
|
||||
path = SDL_strdup(f);
|
||||
|
||||
if (path == NULL) {
|
||||
SDL_Log("out of memory\n");
|
||||
exit(-1);
|
||||
} else {
|
||||
SDL_Log("Load image file: %s", f);
|
||||
}
|
||||
|
||||
tmp = SDL_LoadBMP(path);
|
||||
if (tmp == NULL) {
|
||||
SDL_Log("missing image file: %s", path);
|
||||
exit(-1);
|
||||
} else {
|
||||
SDL_Log("Load image file: %s", path);
|
||||
}
|
||||
|
||||
SDL_free(path);
|
||||
#else
|
||||
/* Generate SDF image using SDL_ttf */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user