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 ;}
43 handle = SDL_CreateRenderer(元Window, -1, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE);
44 surface = SDL_GetWindowSurface(元Window);
77 if (handle !=
nullptr)
return false;
80 surface = SDL_CreateRGBSurface(0, 幅, 高さ, 32, 0, 0, 0, 0);
82 handle = SDL_CreateSoftwareRenderer(surface);
91 if ( isWindow){
return false; }
92 if (handle == 0){
return false; }
93 if (surface !=
nullptr)
95 SDL_FreeSurface(surface);
98 SDL_DestroyRenderer(handle);
110 if (!surface){
return false; }
111 return !SDL_SetColorKey(surface, SDL_TRUE, SDL_MapRGB(surface->format, 透過色.
GetRed(), 透過色.
GetBlue(), 透過色.
GetGreen()));
118 if (!surface){
return false; }
119 return !SDL_SetColorKey(surface,
false, 0);
127 if (!surface){
return false; }
130 image = SDL_CreateTextureFromSurface(コピー先.GetHandle(), surface);
132 SDL_Rect srcrect = { 0, 0, (int)領域.
GetW(), (int)領域.
GetH() };
133 SDL_Rect dsrect = { (int)領域.
GetX(), (int)領域.
GetY(), (int)領域.
GetW(), (int)領域.
GetH() };
134 SDL_RenderCopy(コピー先.GetHandle(), image, &srcrect, &dsrect);
135 SDL_DestroyTexture(image);
145 if (!surface){
return false; }
147 SDL_Texture* image = SDL_CreateTextureFromSurface(コピー先.GetHandle(), surface);
149 SDL_Rect srcrect = { (int)元範囲.
GetX(), (int)元範囲.
GetY(), (int)元範囲.
GetW(), (int)元範囲.
GetH() };
150 SDL_Rect dsrect = { (int)コピー先範囲.
GetX(), (int)コピー先範囲.
GetY(), (int)コピー先範囲.
GetW(), (int)コピー先範囲.
GetH() };
152 SDL_BlitScaled(surface, &srcrect, コピー先.surface, &dsrect);
153 SDL_RenderCopy(コピー先.GetHandle(), image, &srcrect, &dsrect);
154 SDL_DestroyTexture(image);
162 if (handle ==
nullptr){
return false; }
164 SDL_SetRenderDrawColor
172 SDL_RenderClear(handle);
192 if (handle ==
nullptr){
return false; }
194 if (描画領域.GetW() == 0)
196 return !SDL_RenderSetClipRect(handle, 0);
209 return !SDL_RenderSetClipRect(handle, &rect);
230 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:52
bool DrawExtend(const Rect &元範囲, const Rect &コピー先範囲, Renderer &コピー先=Renderer::mainRenderer)
対象RenderHandleにコピー.
Definition: Renderer.h:143
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:51
SDL_Rect TransRect(const SDL_Rect &変換前矩形) const
領域を画面上のどこに相当するか変換.
Definition: Camera.h:103
Renderer(int 幅, int 高さ)
コンストラクタ.
Definition: Renderer.h:62
BlendMode blendMode
描画モード
Definition: Renderer.h:50
bool Create(int 幅, int 高さ)
Windowと独立した、Rendererを生成.
Definition: Renderer.h:75
bool Draw(const Rect &領域, Renderer &コピー先=Renderer::mainRenderer)
対象RenderHandleにコピー.
Definition: Renderer.h:125
bool Destroy()
Rendererを削除.
Definition: Renderer.h:89
bool SetClip(const Rect &描画領域={0, 0, 0, 0})
描画領域を設定する、範囲外には描画されない.
Definition: Renderer.h:190
void SetColor(int 赤, int 緑, int 青, int α値=255)
色の各要素を設定.
Definition: Color.h:24
SDL_Renderer * GetHandle()
描画ハンドルを取得.
Definition: Renderer.h:68
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:160
Image * GetTarget()
現在の描画先を取得する.
Definition: Renderer.h:183
bool SetTarget(Image *描画対象=nullptr)
描画先を変更.
Definition: SDXafx.h:74
bool ResetTransColor()
透過色を解除.
Definition: Renderer.h:116
ウィンドウを表すクラス.
Definition: SubWindow.h:13
static Camera * Get()
現在アクティブなカメラを取得.
Definition: Camera.h:58
int GetRed() const
赤の要素を取得.
Definition: Color.h:30
void SetDrawMode(const Color &輝度+α値=Color::White, BlendMode ブレンドモード=BlendMode::NoBlend)
描画輝度と描画モードをまとめて設定
Definition: Renderer.h:236
void SetBlendMode(BlendMode ブレンドモード, int α値)
描画モードを設定.
Definition: Renderer.h:226
int GetAlpha() const
透明度を取得.
Definition: Color.h:48
static Renderer & mainRenderer
メインウィンドウのレンダラー
Definition: Renderer.h:48
void SetBackColor(const Color &背景色)
Screen::Clear後の色を設定.
Definition: Renderer.h:213
void SetBright(const Color &輝度)
描画輝度を設定.
Definition: Renderer.h:220
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:108