-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathxtexture.h
73 lines (56 loc) · 1.76 KB
/
xtexture.h
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
/**
* This file belongs to the 'xlab' game engine.
* Copyright 2009 xfacter
* Copyright 2016 wickles
* This work is licensed under the LGPLv3
* subject to all terms as reproduced in the included LICENSE file.
*/
#pragma once
#include "xconfig.h"
#ifdef __cplusplus
extern "C" {
#endif
#define X_TEX_TOP_IN_VRAM (1<<0) /* top level in vram */
#define X_TEX_MIPS_IN_VRAM (1<<1) /* all mipmaps in vram */
#define X_TEX_ALL_IN_VRAM (X_TEX_TOP_IN_VRAM|X_TEX_MIPS_IN_VRAM) /* all levels in vram */
#define X_TEX_GRAY_TO_ALPHA (1<<2)
typedef struct x_mipmap {
u16 width;
u16 height;
u16 buf_width;
u16 buf_height;
u16 pow2_height;
void* data;
} x_mipmap;
typedef struct xTexture {
int cpsm;
int psm;
int clut_entries;
u8 swizzled;
u16 width;
u16 height;
u16 buf_width;
u16 buf_height;
u16 pow2_height;
float u_scale;
float v_scale;
void* clut;
void* data;
int num_mips;
x_mipmap* mipmaps;
} xTexture;
xTexture* xTexLoadTex(char* filename, int levels, int flags);
xTexture* xTexLoadTGA(char* filename, int levels, int flags);
xTexture* xTexLoadPNG(char* filename, int levels, int flags);
xTexture* xTexLoadBMP(char* filename, int levels, int flags);
void xTexFree(xTexture* t);
int xTexUploadVRAM(xTexture* t, int level);
int xTexDownloadVRAM(xTexture* t, int level);
void xTexSetImage(xTexture* t);
/* draws texture from top left - must set blend modes and vert colors manually */
void xTexDraw(xTexture* t, int x, int y, int w, int h, int tx, int ty, int tw, int th);
/* draws texture from center with width w and height h, at a rotation of angle */
void xTexDrawAngle(xTexture* t, float x, float y, float w, float h, int tx, int ty, int tw, int th, float angle);
#ifdef __cplusplus
}
#endif