Etterna 0.74.4
Loading...
Searching...
No Matches
RageTextureID.h
1/* RageTextureID - An identifier for a texture and associated loading
2 * parameters. */
3
4#ifndef RAGE_TEXTURE_ID_H
5#define RAGE_TEXTURE_ID_H
6
7/* A unique texture is identified by a RageTextureID. (Loading the
8 * same file with two different dither settings is considered two
9 * different textures, for example.) See RageTexture.cpp for explanations
10 * of these. */
12{
13 std::string filename;
14
15 bool base64{ false };
16
17 // Maximum size of the texture, per dimension.
18 int iMaxSize{ 0 };
19
20 // Generate mipmaps for this texture
21 bool bMipMaps{ false };
22
23 /* Maximum number of bits for alpha. In 16-bit modes, lowering
24 * this gives more bits for color values. (0, 1 or 4) */
25 int iAlphaBits{ 0 };
26
27 /* If this is greater than -1, then the image will be loaded as a luma/alpha
28 * map, eg. I4A4. At most 8 bits per pixel will be used This only actually
29 * happens when paletted textures are supported.
30 *
31 * If the sum of alpha and grayscale bits is <= 4, and the system supports
32 * 4-bit palettes, then the image will be loaded with 4bpp.
33 *
34 * This may be set to 0, resulting in an alpha map with all pixels white. */
35 int iGrayscaleBits{ 0 };
36
37 /* Preferred color depth of the image. (This is overridden for
38 * paletted images and transparencies.) -1 for default. */
39 int iColorDepth{ 0 };
40
41 // If true and color precision is being lost, dither. (slow)
42 bool bDither{ false };
43
44 // If true, resize the image to fill the internal texture. (slow)
45 bool bStretch{ false };
46
47 /* If true, enable HOT PINK color keying. (deprecated but needed for
48 * banners) */
49 bool bHotPinkColorKey{ false }; // #FF00FF
50
51 // These hints will be used in addition to any in the filename.
52 std::string AdditionalTextureHints;
53
54 /* Used by RageTextureManager. Order is important; see
55 * RageTextureManager.cpp. Note that this property is not considered for
56 * ordering/equality. Loading a texture with a different loading policy will
57 * reuse the same texture with a different policy. */
58 enum TexPolicy
59 {
60 TEX_VOLATILE,
61 TEX_DEFAULT
62 } Policy{ TEX_DEFAULT };
63
64 void Init();
65
66 RageTextureID() { Init(); }
67 RageTextureID(const std::string& fn)
68 {
69 Init();
70 SetFilename(fn);
71 }
72 void SetFilename(const std::string& fn);
73};
74
75inline auto
76operator==(RageTextureID const& lhs, RageTextureID const& rhs) -> bool
77{
78 return lhs.filename == rhs.filename && lhs.iMaxSize == rhs.iMaxSize && lhs.bMipMaps == rhs.bMipMaps &&
79 lhs.iAlphaBits == rhs.iAlphaBits && lhs.iGrayscaleBits == rhs.iGrayscaleBits && lhs.iColorDepth == rhs.iColorDepth &&
80 lhs.bDither == rhs.bDither && lhs.bStretch == rhs.bStretch && lhs.bHotPinkColorKey == rhs.bHotPinkColorKey &&
81 lhs.AdditionalTextureHints == rhs.AdditionalTextureHints &&
82 lhs.base64 == rhs.base64;
83 // && lhs.Policy == rhs.Policy; // don't do this
84}
85
86inline auto
87operator!=(RageTextureID const& lhs, RageTextureID const& rhs) -> bool
88{
89 return !operator==(lhs, rhs);
90}
91
92inline auto
93operator<(RageTextureID const& lhs, RageTextureID const& rhs) -> bool
94{
95#define COMP(a) \
96 if (lhs.a < rhs.a) \
97 return true; \
98 if (lhs.a > rhs.a) \
99 return false;
100 COMP(filename);
101 COMP(iMaxSize);
102 COMP(bMipMaps);
103 COMP(iAlphaBits);
104 COMP(iGrayscaleBits);
105 COMP(iColorDepth);
106 COMP(bDither);
107 COMP(base64);
108 COMP(bStretch);
109 COMP(bHotPinkColorKey);
110 COMP(AdditionalTextureHints);
111 // COMP(Policy); // don't do this
112#undef COMP
113 return false;
114}
115
116inline auto
117operator>(RageTextureID const& lhs, RageTextureID const& rhs) -> bool
118{
119 return operator<(rhs, lhs);
120}
121inline auto
122operator<=(RageTextureID const& lhs, RageTextureID const& rhs) -> bool
123{
124 return !operator<(rhs, lhs);
125}
126inline auto
127operator>=(RageTextureID const& lhs, RageTextureID const& rhs) -> bool
128{
129 return !operator<(lhs, rhs);
130}
131
132#endif
Definition RageTextureID.h:12