MyGUI: MyGUI_RenderFormat.h Source File

MyGUI 3.4.3

MyGUI_RenderFormat.h
Go to the documentation of this file.
1/*
2 * This source file is part of MyGUI. For the latest info, see http://mygui.info/
3 * Distributed under the MIT License
4 * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
5 */
6
7#ifndef MYGUI_RENDER_FORMAT_H_
8#define MYGUI_RENDER_FORMAT_H_
9
10#include "MyGUI_Macros.h"
11
12namespace MyGUI
13{
14
15 struct MYGUI_EXPORT VertexColourType
16 {
17 public:
18 enum Enum
19 {
20 ColourARGB, // D3D style compact colour
21 ColourABGR, // GL style compact colour
22 MAX
23 };
24
25 VertexColourType(Enum _value = MAX) :
26 mValue(_value)
27 {
28 }
29
30 friend bool operator==(VertexColourType const& a, VertexColourType const& b)
31 {
32 return a.mValue == b.mValue;
33 }
34
35 friend bool operator!=(VertexColourType const& a, VertexColourType const& b)
36 {
37 return a.mValue != b.mValue;
38 }
39
40 int getValue() const
41 {
42 return mValue;
43 }
44
45 private:
46 Enum mValue;
47 };
48
49 struct MYGUI_EXPORT PixelFormat
50 {
51 enum Enum
52 {
53 Unknow,
54 L8, // 1 byte pixel format, 1 byte luminance
55 L8A8, // 2 byte pixel format, 1 byte luminance, 1 byte alpha
56 R8G8B8, // 24-bit pixel format, 8 bits for red, green and blue.
57 R8G8B8A8 // 32-bit pixel format, 8 bits for red, green, blue and alpha.
58 };
59
60 PixelFormat(Enum _value = Unknow) :
61 mValue(_value)
62 {
63 }
64
65 friend bool operator==(PixelFormat const& a, PixelFormat const& b)
66 {
67 return a.mValue == b.mValue;
68 }
69
70 friend bool operator!=(PixelFormat const& a, PixelFormat const& b)
71 {
72 return a.mValue != b.mValue;
73 }
74
75 int getValue() const
76 {
77 return mValue;
78 }
79
80 int getBytesPerPixel() const
81 {
82 switch (mValue)
83 {
84 case L8: return 1;
85 case L8A8: return 2;
86 case R8G8B8: return 3;
87 case R8G8B8A8: return 4;
88 case Unknow: return 0;
89 }
90 return 0;
91 }
92
93 private:
94 Enum mValue;
95 };
96
97 struct MYGUI_EXPORT TextureUsage
98 {
99 enum Enum
100 {
101 Default = MYGUI_FLAG_NONE,
102 Static = MYGUI_FLAG(0),
103 Dynamic = MYGUI_FLAG(1),
104 Stream = MYGUI_FLAG(2),
105 Read = MYGUI_FLAG(3),
106 Write = MYGUI_FLAG(4),
107 RenderTarget = MYGUI_FLAG(5)
108 };
109
110 TextureUsage(Enum _value = Default) :
111 mValue(_value)
112 {
113 }
114
115 friend bool operator==(TextureUsage const& a, TextureUsage const& b)
116 {
117 return a.mValue == b.mValue;
118 }
119
120 friend bool operator!=(TextureUsage const& a, TextureUsage const& b)
121 {
122 return a.mValue != b.mValue;
123 }
124
125 TextureUsage& operator|=(TextureUsage const& _other)
126 {
127 mValue = (mValue | _other.mValue).mValue;
128 return *this;
129 }
130
131 friend TextureUsage operator|(Enum const& a, Enum const& b)
132 {
133 return {Enum((unsigned int)a | (unsigned int)b)};
134 }
135
136 friend TextureUsage operator|(TextureUsage const& a, TextureUsage const& b)
137 {
138 return a.mValue | b.mValue;
139 }
140
141 bool isValue(Enum _value) const
142 {
143 return 0 != (mValue & _value);
144 }
145
146 int getValue() const
147 {
148 return mValue;
149 }
150
151 private:
152 Enum mValue;
153 };
154
155} // namespace MyGUI
156
157
158#endif // MYGUI_RENDER_FORMAT_H_
MyGUI_Macros.h
MYGUI_EXPORT
#define MYGUI_EXPORT
Definition MyGUI_Platform.h:77
MyGUI
Definition MyGUI_ActionController.h:15
MyGUI::MYGUI_FLAG
constexpr unsigned int MYGUI_FLAG(uint8_t num)
Definition MyGUI_Macros.h:24
MyGUI::MYGUI_FLAG_NONE
constexpr unsigned int MYGUI_FLAG_NONE
Definition MyGUI_Macros.h:23
MyGUI::PixelFormat::PixelFormat
PixelFormat(Enum _value=Unknow)
Definition MyGUI_RenderFormat.h:60
MyGUI::PixelFormat::operator!=
friend bool operator!=(PixelFormat const &a, PixelFormat const &b)
Definition MyGUI_RenderFormat.h:70
MyGUI::PixelFormat::operator==
friend bool operator==(PixelFormat const &a, PixelFormat const &b)
Definition MyGUI_RenderFormat.h:65
MyGUI::PixelFormat::getBytesPerPixel
int getBytesPerPixel() const
Definition MyGUI_RenderFormat.h:80
MyGUI::PixelFormat::Enum
Enum
Definition MyGUI_RenderFormat.h:52
MyGUI::PixelFormat::Unknow
@ Unknow
Definition MyGUI_RenderFormat.h:53
MyGUI::PixelFormat::L8A8
@ L8A8
Definition MyGUI_RenderFormat.h:55
MyGUI::PixelFormat::R8G8B8A8
@ R8G8B8A8
Definition MyGUI_RenderFormat.h:57
MyGUI::PixelFormat::L8
@ L8
Definition MyGUI_RenderFormat.h:54
MyGUI::PixelFormat::R8G8B8
@ R8G8B8
Definition MyGUI_RenderFormat.h:56
MyGUI::PixelFormat::getValue
int getValue() const
Definition MyGUI_RenderFormat.h:75
MyGUI::TextureUsage::operator|
friend TextureUsage operator|(TextureUsage const &a, TextureUsage const &b)
Definition MyGUI_RenderFormat.h:136
MyGUI::TextureUsage::Enum
Enum
Definition MyGUI_RenderFormat.h:100
MyGUI::TextureUsage::RenderTarget
@ RenderTarget
Definition MyGUI_RenderFormat.h:107
MyGUI::TextureUsage::Default
@ Default
Definition MyGUI_RenderFormat.h:101
MyGUI::TextureUsage::Static
@ Static
Definition MyGUI_RenderFormat.h:102
MyGUI::TextureUsage::Write
@ Write
Definition MyGUI_RenderFormat.h:106
MyGUI::TextureUsage::Read
@ Read
Definition MyGUI_RenderFormat.h:105
MyGUI::TextureUsage::Dynamic
@ Dynamic
Definition MyGUI_RenderFormat.h:103
MyGUI::TextureUsage::Stream
@ Stream
Definition MyGUI_RenderFormat.h:104
MyGUI::TextureUsage::getValue
int getValue() const
Definition MyGUI_RenderFormat.h:146
MyGUI::TextureUsage::operator|
friend TextureUsage operator|(Enum const &a, Enum const &b)
Definition MyGUI_RenderFormat.h:131
MyGUI::TextureUsage::isValue
bool isValue(Enum _value) const
Definition MyGUI_RenderFormat.h:141
MyGUI::TextureUsage::operator==
friend bool operator==(TextureUsage const &a, TextureUsage const &b)
Definition MyGUI_RenderFormat.h:115
MyGUI::TextureUsage::operator!=
friend bool operator!=(TextureUsage const &a, TextureUsage const &b)
Definition MyGUI_RenderFormat.h:120
MyGUI::TextureUsage::operator|=
TextureUsage & operator|=(TextureUsage const &_other)
Definition MyGUI_RenderFormat.h:125
MyGUI::TextureUsage::TextureUsage
TextureUsage(Enum _value=Default)
Definition MyGUI_RenderFormat.h:110
MyGUI::VertexColourType::Enum
Enum
Definition MyGUI_RenderFormat.h:19
MyGUI::VertexColourType::MAX
@ MAX
Definition MyGUI_RenderFormat.h:22
MyGUI::VertexColourType::ColourABGR
@ ColourABGR
Definition MyGUI_RenderFormat.h:21
MyGUI::VertexColourType::ColourARGB
@ ColourARGB
Definition MyGUI_RenderFormat.h:20
MyGUI::VertexColourType::operator!=
friend bool operator!=(VertexColourType const &a, VertexColourType const &b)
Definition MyGUI_RenderFormat.h:35
MyGUI::VertexColourType::getValue
int getValue() const
Definition MyGUI_RenderFormat.h:40
MyGUI::VertexColourType::VertexColourType
VertexColourType(Enum _value=MAX)
Definition MyGUI_RenderFormat.h:25
MyGUI::VertexColourType::operator==
friend bool operator==(VertexColourType const &a, VertexColourType const &b)
Definition MyGUI_RenderFormat.h:30