いつもお世話になっております。
DrawModiStringToHandleで[あ]を481回並べた文字列は問題なく描画されましたが、482回並べて描画したところ表示されません。
DrawStringToHandleはちゃんと描画されるのを確認しました。
#include "DxLib.h"
#include <string>
using namespace std;
void Draw(int x, int y, int handle, string str, int width = 0)
{
if(width == 0) width = GetDrawStringWidthToHandle(str.c_str(), str.size(), handle);
DrawBox(x, y, x + width / 2, y + 30, GetColor(0, 255, 0), TRUE);
DrawModiStringToHandle(x, y, x + width, y, x + width, y + 30, x, y + 30, GetColor(255, 0, 0), handle, GetColor(255, 255, 255), FALSE, str.c_str());
}
int WINAPI WinMain(_In_ HINSTANCE, _In_opt_ HINSTANCE, _In_ LPSTR, _In_ int)
{
// logを生成しない
SetOutApplicationLogValidFlag(false);
// ウィンドウモード
ChangeWindowMode(true);
if (DxLib_Init() == -1) return -1;
string tmp1 = "", tmp2 = "", str = "あ";
int fontHandle = CreateFontToHandle(NULL, 30, 0, DX_FONTTYPE_ANTIALIASING_EDGE_8X8, -1, 2);
//int fontHandle = CreateFontToHandle(NULL, 30, 0, DX_FONTTYPE_NORMAL, -1, 2);
// 裏描画
SetDrawScreen(DX_SCREEN_BACK);
// ここを481回ループさせると表示されて、482回ループさせると表示が消える
for (int i = 0; i < 482; i++)
{
tmp1 += str;
tmp2 += str;
}
while (!ScreenFlip() && !ProcessMessage() && !ClearDrawScreen())
{
Draw(0, 0, fontHandle, tmp1);
Draw(0, 50, fontHandle, tmp2);
Draw(0, 100, fontHandle, tmp1, 600);
Draw(0, 150, fontHandle, tmp2, 600);
DrawStringToHandle(0, 200, tmp1.c_str(), GetColor(255, 0, 0), fontHandle, GetColor(255, 255, 255));
DrawStringToHandle(0, 250, tmp2.c_str(), GetColor(255, 0, 0), fontHandle, GetColor(255, 255, 255));
DrawFormatString(0, 300, GetColor(255, 0, 0), "%d", tmp1.compare(tmp2));
}
DxLib_End();
return 0;
}
原因がわからず、お手数ですがご確認いただけると幸いです。