-
Notifications
You must be signed in to change notification settings - Fork 0
/
sdl_image.c
75 lines (55 loc) · 1.48 KB
/
sdl_image.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gprolog.h>
#include <SDL.h>
#include <SDL_image.h>
#include "sdllib_common.h"
#define RETURN_IMG_FAIL(F) \
fprintf(stderr, "%s failed -> %s\n", #F, IMG_GetError()); \
return PL_FALSE;
#define SHOW_IMG_FAIL(F) fprintf(stderr, "%s failed -> %s\n", #F, IMG_GetError());
//--------------------------------------------------------------------
//
// Image functions
//
// "SDL_image"
//
//--------------------------------------------------------------------
PlBool gp_IMG_Linked_Version(PlLong *major, PlLong *minor, PlLong *patch)
{
SDL_version compile_version;
const SDL_version *link_version = IMG_Linked_Version();
SDL_IMAGE_VERSION(&compile_version);
*major = (PlLong)compile_version.major;
*minor = (PlLong)compile_version.minor;
*patch = (PlLong)compile_version.patch;
return PL_TRUE;
}
PlBool gp_IMG_Init(PlLong flags, PlLong *loaded)
{
int initted = IMG_Init(flags);
#ifdef __DEBUG__
fprintf(stdout, "IMG_Init has done: %02x\n", initted);
#endif
if ((initted & flags) != flags) {
RETURN_IMG_FAIL(IMG_Init);
}
*loaded = (PlLong)initted;
return PL_TRUE;
}
PlBool gp_IMG_Quit()
{
IMG_Quit();
return PL_TRUE;
}
PlBool gp_IMG_Load(char* filename, PlLong *handle)
{
SDL_Surface *image = IMG_Load(filename);
fprintf(stdout, "%p\n", image);
if (image) {
*handle = (PlLong)image;
return PL_TRUE;
}
RETURN_IMG_FAIL(IMG_Load);
}