DrawPolygon2D は DrawGraph などと同じように SetDrawBright と SetDrawBlendMode の設定が反映されます
DrawPolygon2D の実行前に SetDrawBright と SetDrawBlendMode を使用するサンプルコードは以下のようになります
#include "DxLib.h"
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
{
int texhandle ;
VERTEX2D Vert[ 6 ] ;
// ウィンドウモードで起動
ChangeWindowMode( TRUE ) ;
// 背景は紫色にする
SetBackgroundColor( 128, 0, 128 ) ;
// DXライブラリの初期化
if( DxLib_Init() < 0 ) return -1;
// テクスチャを読み込む
texhandle = LoadGraph( "Tex1.bmp" ) ;
// 2ポリゴン分の頂点のデータをセットアップ
Vert[ 0 ].pos = VGet( 0.0f, 0.0f, 0.0f ) ;
Vert[ 0 ].rhw = 1.0f ;
Vert[ 0 ].dif = GetColorU8( 255,255,255,255 ) ;
Vert[ 0 ].u = 0.0f ;
Vert[ 0 ].v = 0.0f ;
Vert[ 1 ].pos = VGet( 256.0f, 0.0f, 0.0f ) ;
Vert[ 1 ].rhw = 1.0f ;
Vert[ 1 ].dif = GetColorU8( 255,255,255,255 ) ;
Vert[ 1 ].u = 1.0f ;
Vert[ 1 ].v = 0.0f ;
Vert[ 2 ].pos = VGet( 0.0f, 256.0f, 0.0f ) ;
Vert[ 2 ].rhw = 1.0f ;
Vert[ 2 ].dif = GetColorU8( 255,255,255,255 ) ;
Vert[ 2 ].u = 0.0f ;
Vert[ 2 ].v = 1.0f ;
Vert[ 3 ].pos = VGet( 256.0f, 256.0f, 0.0f ) ;
Vert[ 3 ].rhw = 1.0f ;
Vert[ 3 ].dif = GetColorU8( 255,255,255,255 ) ;
Vert[ 3 ].u = 1.0f ;
Vert[ 3 ].v = 1.0f ;
Vert[ 4 ].pos = VGet( 0.0f, 256.0f, 0.0f ) ;
Vert[ 4 ].rhw = 1.0f ;
Vert[ 4 ].dif = GetColorU8( 255,255,255,255 ) ;
Vert[ 4 ].u = 0.0f ;
Vert[ 4 ].v = 1.0f ;
Vert[ 5 ].pos = VGet( 256.0f, 0.0f, 0.0f ) ;
Vert[ 5 ].rhw = 1.0f ;
Vert[ 5 ].dif = GetColorU8( 255,255,255,255 ) ;
Vert[ 5 ].u = 1.0f ;
Vert[ 5 ].v = 0.0f ;
// 描画先を裏画面に変更
SetDrawScreen( DX_SCREEN_BACK ) ;
// メインループ
int Bright = 255, BrightAdd = -8 ;
int Alpha = 255, AlphaAdd = -3 ;
while( ProcessMessage() == 0 )
{
// 画面をクリア
ClearDrawScreen() ;
// 輝度とアルファ値の推移処理
Bright += BrightAdd ;
if( Bright < 0 )
{
Bright = 0 ;
BrightAdd = -BrightAdd ;
}
else
if( Bright > 255 )
{
Bright = 255 ;
BrightAdd = -BrightAdd ;
}
Alpha += AlphaAdd ;
if( Alpha < 0 )
{
Alpha = 0 ;
AlphaAdd = -AlphaAdd ;
}
else
if( Alpha > 255 )
{
Alpha = 255 ;
AlphaAdd = -AlphaAdd ;
}
// 輝度とアルファ値の設定
SetDrawBright( Bright,255,255 ) ;
SetDrawBlendMode( DX_BLENDMODE_ALPHA, Alpha );
// 2Dの2ポリゴンの描画
DrawPolygon2D( Vert, 2, texhandle, TRUE ) ;
// 裏画面の内容を表画面に反映
ScreenFlip() ;
}
// DXライブラリの後始末
DxLib_End();
// ソフトの終了
return 0 ;
}