SDXFrameWork 0.09 SDXFrameWork

- Main Page
- Related Pages
- Classes

All Classes Namespaces Functions Variables Enumerations Enumerator Pages
Screen.h
1 #pragma once//☀SDL
2 #include <Multimedia/SDX.h>
3 #include <Multimedia/Color.h>
4 #include <Framework/Shape.h>
5
6 namespace SDX
7 {
8
10 enum class BlendMode
11 {
12 NoBlend = SDL_BLENDMODE_NONE,
13 Alpha = SDL_BLENDMODE_BLEND,
14 Add = SDL_BLENDMODE_ADD,
15 Mula = SDL_BLENDMODE_MOD
16 };
17
18 class Image;
19
23 class Renderer
24 {
25 private:
26 RendererHandle handle = 0;
27 public:
28 /*描画ハンドルを取得*/
29 RendererHandle GetHandle()
30 {
31 return handle;
32 }
33
34 ~Renderer()
35 {
36 Destroy();
37 }
38
39 /*Rendererを生成*/
40 void Create(WindowHandle 元Window)
41 {
42 handle = SDL_CreateRenderer(元Window, -1, SDL_RENDERER_PRESENTVSYNC);
43 }
44
45 /*Rendererを削除*/
46 bool Destroy()
47 {
48 if (handle == 0) return false;
49 SDL_DestroyRenderer(handle);
50 return true;
51 }
52 };
53
56 class Screen
57 {
58 private:
59 Screen(){};
60 ~Screen(){};
61 RendererHandle handle = 0;//現在の描画先
62
63 public:
64 BlendMode nowBlendMode = BlendMode::NoBlend;
65 int blendParam = 0;
66 Color clearColor = Color(0, 0, 0);//消去時の色
67 Color rgba = Color(255, 255, 255, 0);//描画輝度と透明度
68
70 static Screen& Single()
71 {
72 static Screen single;
73 return single;
74 }
75
77 static RendererHandle GetHandle()
78 {
79 return Single().handle;
80 }
81
83 static void SetRenderer(Renderer &描画先Renderer)
84 {
85 Single().handle = 描画先Renderer.GetHandle();
86 }
87
89 static bool SetArea(const Rect &描画領域)
90 {
91 return false;
92 }
93
95 static bool SetBackColor( Color 背景色 )
96 {
97 Single().clearColor.SetColor(背景色.GetRed(), 背景色.GetGreen(), 背景色.GetBlue());
98
99 return true;
100 }
101
103 static bool Flip()
104 {
105 SDL_RenderPresent(GetHandle());
106 return true;
107 }
108
110 static bool Copy()
111 {
112 SDL_RenderPresent(GetHandle());
113 return true;
114 }
115
117 static bool Clear()
118 {
119 SDL_SetRenderDrawColor
120 (
121 Screen::GetHandle(),
122 Single().clearColor.GetRed(),
123 Single().clearColor.GetGreen(),
124 Single().clearColor.GetBlue(),
125 0
126 );
127 SDL_RenderClear(GetHandle());
128 return true;
129 }
130
132 static bool SetBlendMode(BlendMode ブレンドモード,int 設定値)
133 {
134 Single().nowBlendMode = ブレンドモード;
135 if(設定値 > 255) Single().blendParam = 255;
136 else if(設定値 < 0) Single().blendParam = 0;
137 else Single().blendParam = 設定値;
138
139 return true;
140 }
141
143 static bool SaveBmp(const Rect &領域 , const char *ファイル名 )
144 {
145 return false;
146 }
147
149 static bool SetBright( Color 輝度 )
150 {
151 Single().rgba.SetColor(輝度.GetRed(), 輝度.GetGreen(), 輝度.GetBlue());
152 return true;
153 }
154
156 static bool SetTransColor(Color 輝度)
157 {
158 return false;
159 }
160
161 };
162 }
SDX::Screen::SetBlendMode
static bool SetBlendMode(BlendMode ブレンドモード, int 設定値)
ブレンド描画のモードを設定.
Definition: Screen.h:132
SDX::Screen
描画先を表すクラス.
Definition: Screen.h:56
SDX::Color::GetGreen
int GetGreen() const
緑の要素を取得.
Definition: Color.h:31
SDX::Rect
矩形を表す図形クラス.
Definition: Shape.h:536
SDX::Screen::SaveBmp
static bool SaveBmp(const Rect &領域, const char *ファイル名)
描画対象になっている画面の一部をBMP形式で保存[未実装].
Definition: Screen.h:143
SDX::Screen::GetHandle
static RendererHandle GetHandle()
スクリーンハンドルを取得.
Definition: Screen.h:77
SDX::Screen::Flip
static bool Flip()
描画内容を反映.
Definition: Screen.h:103
SDX::FileMode::Add
書込時、末尾に追加
SDX::Color::GetBlue
int GetBlue() const
青の要素を取得.
Definition: Color.h:37
SDX::Screen::Single
static Screen & Single()
シングルトンなインスタンスを取得.
Definition: Screen.h:70
SDX::Screen::SetBright
static bool SetBright(Color 輝度)
描画輝度を設定.
Definition: Screen.h:149
SDX::Screen::SetArea
static bool SetArea(const Rect &描画領域)
描画範囲を設定する、設定範囲外には描画されない[未実装].
Definition: Screen.h:89
SDX::Screen::Clear
static bool Clear()
画面を消去する.
Definition: Screen.h:117
SDX::Renderer
描画先を表すクラス.
Definition: Screen.h:23
SDX::Color
色を表すクラス.
Definition: Color.h:7
SDX::Screen::SetTransColor
static bool SetTransColor(Color 輝度)
透過色を設定[未実装].
Definition: Screen.h:156
SDX::Screen::SetRenderer
static void SetRenderer(Renderer &描画先Renderer)
スクリーンハンドルを設定.
Definition: Screen.h:83
SDX::Color::GetRed
int GetRed() const
赤の要素を取得.
Definition: Color.h:25
SDX::Screen::SetBackColor
static bool SetBackColor(Color 背景色)
Screen::Clear後の色を設定.
Definition: Screen.h:95
SDX::BlendMode
BlendMode
ブレンドモード.
Definition: Screen.h:10
SDX::Screen::Copy
static bool Copy()
裏画面の内容を、表画面にコピー.
Definition: Screen.h:110