the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#pragma once
2
3class Rect2i;
4class ByteBuffer;
5class BufferedImage;
6
7#ifdef __PS3__
8class ByteBuffer_IO;
9#endif
10
11class Texture
12{
13public:
14 static const int WM_WRAP = GL_REPEAT;
15 static const int WM_CLAMP = GL_CLAMP;
16 static const int WM_MIRROR = 0; //GL_MIRRORED_REPEAT;
17
18 static const int TFMT_RGBA = GL_RGBA;
19 static const int TFMT_BGRA = GL_BGRA;
20
21 static const int TFLT_NEAREST = GL_NEAREST;
22 static const int TFLT_LINEAR = GL_LINEAR;
23 static const int TFLT_LINEAR_MIP_NEAREST = 0; //GL_LINEAR_MIPMAP_NEAREST;
24 static const int TFLT_LINEAR_MIP_LINEAR = 0; //GL_LINEAR_MIPMAP_LINEAR;
25 static const int TFLT_NEAREST_MIP_NEAREST = 0; //GL_NEAREST_MIPMAP_NEAREST;
26 static const int TFLT_NEAREST_MIP_LINEAR = GL_NEAREST_MIPMAP_LINEAR;
27
28 static const int TM_STATIC = 0;
29 static const int TM_DYNAMIC = 1;
30 static const int TM_CONTAINER = 2;
31
32private:
33 int glId;
34 int managerId;
35
36 // Indicates certain aspects of this texture's behavior in terms of how tightly it is bound, conceptually. A static
37 // texture is loaded once, uploaded to the GPU, and discarded CPU-side. A dynamic texture is kept on both the CPU
38 // and GPU, as it will likely be dynamically updated on the CPU. A container texture exists only to keep the data
39 // on the CPU, usually for later combination into a larger texture via the Stitcher class.
40 int mode;
41
42 int width;
43 int height;
44 int depth;
45 int format;
46 int type;
47 int minFilter;
48 int magFilter;
49 int wrapMode;
50 bool mipmapped;
51 wstring name;
52
53 Rect2i *rect;
54
55 bool valid;
56 bool immediateUpdate;
57 bool updated;
58 int m_iMipLevels;
59#ifdef __PS3__
60 ByteBuffer_IO *data[10];
61#else
62 ByteBuffer *data[10]; // Arrays for mipmaps - NULL if not used
63#endif
64
65public:
66 bool m_bInitialised; // 4J Added
67
68 ~Texture();
69private:
70 Texture(const wstring &name, int mode, int width, int height, int depth, int wrapMode, int format, int minFilter, int magFilter, bool mipMap = true);
71
72 void _init(const wstring &name, int mode, int width, int height, int depth, int wrapMode, int format, int minFilter, int magFilter, bool mipMap);
73 void _init(const wstring &name, int mode, int width, int height, int depth, int wrapMode, int format, int minFilter, int magFilter, BufferedImage *image, bool mipMap);
74
75public:
76 Texture(const wstring &name, int mode, int width, int height, int wrapMode, int format, int minFilter, int magFilter, BufferedImage *image, bool mipMap = true);
77 Texture(const wstring &name, int mode, int width, int height, int depth, int wrapMode, int format, int minFilter, int magFilter, BufferedImage *image, bool mipMap = true);
78
79 const Rect2i *getRect();
80 void fill(const Rect2i *rect, int color);
81 void writeAsBMP(const wstring &name);
82 void writeAsPNG(const wstring &filename);
83 void blit(int x, int y, Texture *source);
84 void blit(int x, int y, Texture *source, bool rotated);
85 void transferFromBuffer(intArray buffer);
86 void transferFromImage(BufferedImage *image);
87 int getManagerId();
88 int getGlId();
89 int getWidth();
90 int getHeight();
91 wstring getName();
92 void setImmediateUpdate(bool immediateUpdate);
93 void bind(int mipMapIndex);
94 void updateOnGPU();
95 ByteBuffer *getData(unsigned int level = 0);
96
97 static int crispBlend(int c0, int c1);
98};