5 #include <Multimedia/SDX.h>
6 #include <Multimedia/Color.h>
7 #include <Multimedia/Renderer.h>
8 #include <Framework/Shape.h>
9 #include <Framework/Camera.h>
17 Alpha = SDL_BLENDMODE_BLEND,
18 Add = SDL_BLENDMODE_ADD,
19 Mula = SDL_BLENDMODE_MOD,
32 SDL_Renderer* handle =
nullptr;
33 SDL_Surface* surface =
nullptr;
34 Image* target =
nullptr;
38 bool Create(SDL_Window* 元Window)
40 if (handle !=
nullptr){
return false ;}
44 handle = SDL_CreateRenderer(元Window, -1, SDL_RENDERER_PRESENTVSYNC);
45 surface = SDL_GetWindowSurface(元Window);
78 if (handle !=
nullptr)
return false;
81 surface = SDL_CreateRGBSurface(0, 幅, 高さ, 32, 0, 0, 0, 0);
83 handle = SDL_CreateSoftwareRenderer(surface);
92 if ( isWindow){
return false; }
93 if (handle == 0){
return false; }
94 if (surface !=
nullptr)
96 SDL_FreeSurface(surface);
99 SDL_DestroyRenderer(handle);
111 if (!surface){
return false; }
112 return !SDL_SetColorKey(surface, SDL_TRUE, SDL_MapRGB(surface->format, 透過色.
GetRed(), 透過色.
GetBlue(), 透過色.
GetGreen()));
119 if (!surface){
return false; }
120 return !SDL_SetColorKey(surface,
false, 0);
128 if (!surface){
return false; }
131 image = SDL_CreateTextureFromSurface(コピー先.GetHandle(), surface);
133 SDL_Rect srcrect = { 0, 0, (int)領域.
GetW(), (int)領域.
GetH() };
134 SDL_Rect dsrect = { (int)領域.
GetX(), (int)領域.
GetY(), (int)領域.
GetW(), (int)領域.
GetH() };
135 SDL_RenderCopy(コピー先.GetHandle(), image, &srcrect, &dsrect);
136 SDL_DestroyTexture(image);
146 if (!surface){
return false; }
148 SDL_Texture* image = SDL_CreateTextureFromSurface(コピー先.GetHandle(), surface);
150 SDL_Rect srcrect = { (int)元範囲.
GetX(), (int)元範囲.
GetY(), (int)元範囲.
GetW(), (int)元範囲.
GetH() };
151 SDL_Rect dsrect = { (int)コピー先範囲.
GetX(), (int)コピー先範囲.
GetY(), (int)コピー先範囲.
GetW(), (int)コピー先範囲.
GetH() };
153 SDL_BlitScaled(surface, &srcrect, コピー先.surface, &dsrect);
154 SDL_RenderCopy(コピー先.GetHandle(), image, &srcrect, &dsrect);
155 SDL_DestroyTexture(image);
163 if (handle ==
nullptr){
return false; }
165 SDL_SetRenderDrawColor
173 SDL_RenderClear(handle);
193 if (handle ==
nullptr){
return false; }
195 if (描画領域.GetW() == 0)
197 return !SDL_RenderSetClipRect(handle, 0);
210 return !SDL_RenderSetClipRect(handle, &rect);
231 else if (α値 < 0){ α値 = 0; }
double GetX() const override
X座標を取得.
Definition: Rect.h:97
int GetGreen() const
緑の要素を取得.
Definition: Color.h:36
矩形を表す図形クラス.
Definition: Rect.h:22
Color rgba
描画輝度とα値
Definition: Renderer.h:53
bool DrawExtend(const Rect &元範囲, const Rect &コピー先範囲, Renderer &コピー先=Renderer::mainRenderer)
対象RenderHandleにコピー.
Definition: Renderer.h:144
double GetY() const override
Y座標を取得.
Definition: Rect.h:102
int GetBlue() const
青の要素を取得.
Definition: Color.h:42
リソースを読み込まずに描画を行う関数群.
Definition: Drawing.h:17
Color clearColor
消去時の色
Definition: Renderer.h:52
SDL_Rect TransRect(const SDL_Rect &変換前矩形) const
領域を画面上のどこに相当するか変換.
Definition: Camera.h:102
Renderer(int 幅, int 高さ)
コンストラクタ.
Definition: Renderer.h:63
BlendMode blendMode
描画モード
Definition: Renderer.h:51
bool Create(int 幅, int 高さ)
Windowと独立した、Rendererを生成.
Definition: Renderer.h:76
bool Draw(const Rect &領域, Renderer &コピー先=Renderer::mainRenderer)
対象RenderHandleにコピー.
Definition: Renderer.h:126
bool Destroy()
Rendererを削除.
Definition: Renderer.h:90
bool SetClip(const Rect &描画領域={0, 0, 0, 0})
描画領域を設定する、範囲外には描画されない.
Definition: Renderer.h:191
void SetColor(int 赤, int 緑, int 青, int α値=255)
色の各要素を設定.
Definition: Color.h:24
SDL_Renderer * GetHandle()
描画ハンドルを取得.
Definition: Renderer.h:69
static const Color White
白 [RGB]255,255,255
Definition: Color.h:81
画像データを表すクラス.
Definition: Image.h:17
描画先を表すクラス.
Definition: Renderer.h:27
色を表すクラス.
Definition: Color.h:11
bool Clear()
画面を消去する.
Definition: Renderer.h:161
Image * GetTarget()
現在の描画先を取得する.
Definition: Renderer.h:184
bool SetTarget(Image *描画対象=nullptr)
描画先を変更.
Definition: SDXafx.h:80
bool ResetTransColor()
透過色を解除.
Definition: Renderer.h:117
ウィンドウを表すクラス.
Definition: SubWindow.h:14
static Camera * Get()
現在アクティブなカメラを取得.
Definition: Camera.h:57
int GetRed() const
赤の要素を取得.
Definition: Color.h:30
void SetDrawMode(const Color &輝度+α値=Color::White, BlendMode ブレンドモード=BlendMode::NoBlend)
描画輝度と描画モードをまとめて設定
Definition: Renderer.h:237
void SetBlendMode(BlendMode ブレンドモード, int α値)
描画モードを設定.
Definition: Renderer.h:227
int GetAlpha() const
透明度を取得.
Definition: Color.h:48
static Renderer & mainRenderer
メインウィンドウのレンダラー
Definition: Renderer.h:49
void SetBackColor(const Color &背景色)
Screen::Clear後の色を設定.
Definition: Renderer.h:214
void SetBright(const Color &輝度)
描画輝度を設定.
Definition: Renderer.h:221
BlendMode
ブレンドモード.
Definition: Renderer.h:14
double GetW() const override
幅を取得.
Definition: Rect.h:107
double GetH() const override
高さを取得.
Definition: Rect.h:112
bool SetTransColor(const Color &透過色)
透過色を設定.
Definition: Renderer.h:109