__
This commit is contained in:
parent
83946b1e66
commit
ca52e6dae6
@ -59,11 +59,13 @@ namespace RenderD7
|
|||||||
void SetupBenchmark(int framerate);
|
void SetupBenchmark(int framerate);
|
||||||
bool IsBenchmarkRunning() { return this->benchmark; }
|
bool IsBenchmarkRunning() { return this->benchmark; }
|
||||||
|
|
||||||
void DrawText(int x, int y, float t_size, u32 color, std::string text);
|
void DrawDebugText(int x, int y, float t_size, u32 color, std::string text);
|
||||||
|
void DrawText(int x, int y, int t_size, u32 color, std::string text);
|
||||||
private:
|
private:
|
||||||
//funcs
|
//funcs
|
||||||
bool Decode(Decoder deccc);
|
bool Decode(Decoder deccc);
|
||||||
void DrawChar(u32 posX, u32 posY, u32 color, char character);
|
void DrawDebugChar(u32 posX, u32 posY, u32 color, char character);
|
||||||
|
void DrawChar(u32 posX, u32 posY, int t_size, u32 color, char character);
|
||||||
//parameter
|
//parameter
|
||||||
int frame = 0;
|
int frame = 0;
|
||||||
RenderD7::Image renderframe;
|
RenderD7::Image renderframe;
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include <regex>
|
#include <regex>
|
||||||
|
|
||||||
#define UNPACK_RGBA(col) (uint8_t) (col >> 24), (col >> 16), (col >> 8), (col)
|
#define UNPACK_RGBA(col) (uint8_t) (col >> 24), (col >> 16), (col >> 8), (col)
|
||||||
|
#define UNPACK_BGRA(col) (uint8_t) (col >> 8), (col >> 16), (col >> 24), (col)
|
||||||
|
|
||||||
namespace RenderD7
|
namespace RenderD7
|
||||||
{
|
{
|
||||||
|
1591
include/renderd7/Fonts/ConsolasFont.hpp
Normal file
1591
include/renderd7/Fonts/ConsolasFont.hpp
Normal file
File diff suppressed because it is too large
Load Diff
@ -330,7 +330,7 @@ void RenderD7::BitmapPrinter::SetupBenchmark(int framerate)
|
|||||||
|
|
||||||
#include <renderd7/debugfont.h>
|
#include <renderd7/debugfont.h>
|
||||||
|
|
||||||
void RenderD7::BitmapPrinter::DrawChar(u32 posX, u32 posY, u32 color, char character)
|
void RenderD7::BitmapPrinter::DrawDebugChar(u32 posX, u32 posY, u32 color, char character)
|
||||||
{
|
{
|
||||||
for(u32 y = 0; y < 8; y++)
|
for(u32 y = 0; y < 8; y++)
|
||||||
{
|
{
|
||||||
@ -339,7 +339,21 @@ void RenderD7::BitmapPrinter::DrawChar(u32 posX, u32 posY, u32 color, char chara
|
|||||||
for(u32 x = 0; x < 8; x++)
|
for(u32 x = 0; x < 8; x++)
|
||||||
if(((charPos >> (7 - x)) & 1) == 1)
|
if(((charPos >> (7 - x)) & 1) == 1)
|
||||||
{
|
{
|
||||||
DrawPixel((int)posX + x + 1, (int)posY + y + 1, 255, 255, 255, 255);
|
DrawPixel((int)posX + x + 1, (int)posY + y + 1, UNPACK_BGRA(color));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderD7::BitmapPrinter::DrawChar(u32 posX, u32 posY, int t_size, u32 color, char character)
|
||||||
|
{
|
||||||
|
for(u32 y = 0; y < (uint32_t)(8*t_size); y++)
|
||||||
|
{
|
||||||
|
char charPos = debugfont[character * 8 + y/t_size];
|
||||||
|
|
||||||
|
for(u32 x = 0; x < (uint32_t)(8*t_size); x++)
|
||||||
|
if(((charPos >> (7 - x)) & 1) == 1)
|
||||||
|
{
|
||||||
|
DrawPixel((int)posX + x + 1, (int)posY + y + 1, UNPACK_BGRA(color));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -347,7 +361,7 @@ void RenderD7::BitmapPrinter::DrawChar(u32 posX, u32 posY, u32 color, char chara
|
|||||||
#define SPACING_Y 10
|
#define SPACING_Y 10
|
||||||
#define SPACING_X 8
|
#define SPACING_X 8
|
||||||
|
|
||||||
void RenderD7::BitmapPrinter::DrawText(int x, int y, float t_size, u32 color, std::string text)
|
void RenderD7::BitmapPrinter::DrawDebugText(int x, int y, float t_size, u32 color, std::string text)
|
||||||
{
|
{
|
||||||
for(u32 i = 0, line_i = 0; i < strlen(text.c_str()); i++)
|
for(u32 i = 0, line_i = 0; i < strlen(text.c_str()); i++)
|
||||||
switch(text[i])
|
switch(text[i])
|
||||||
@ -370,7 +384,43 @@ void RenderD7::BitmapPrinter::DrawText(int x, int y, float t_size, u32 color, st
|
|||||||
if(text[i] == ' ') break; //Spaces at the start look weird
|
if(text[i] == ' ') break; //Spaces at the start look weird
|
||||||
}
|
}
|
||||||
|
|
||||||
this->DrawChar((u32)x + line_i * SPACING_X, (u32)y, color, text[i]);
|
this->DrawDebugChar((u32)x + line_i * SPACING_X, (u32)y, color, text[i]);
|
||||||
|
|
||||||
|
line_i++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderD7::BitmapPrinter::DrawText(int x, int y, int t_size, u32 color, std::string text)
|
||||||
|
{
|
||||||
|
if (t_size < 1)
|
||||||
|
{
|
||||||
|
t_size = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(u32 i = 0, line_i = 0; i < strlen(text.c_str()); i++)
|
||||||
|
switch(text[i])
|
||||||
|
{
|
||||||
|
case '\n':
|
||||||
|
y += SPACING_Y*t_size;
|
||||||
|
line_i = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '\t':
|
||||||
|
line_i += 2*t_size;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
//Make sure we never get out of the screen
|
||||||
|
if(line_i >= (((u32)this->bitmap.bmp_info_header.width) - (u32)x) / SPACING_X*t_size)
|
||||||
|
{
|
||||||
|
y += SPACING_Y*t_size;
|
||||||
|
line_i = 1; //Little offset so we know the same text continues
|
||||||
|
if(text[i] == ' ') break; //Spaces at the start look weird
|
||||||
|
}
|
||||||
|
|
||||||
|
this->DrawChar((u32)x + line_i * SPACING_X, (u32)y, t_size, color, text[i]);
|
||||||
|
|
||||||
line_i++;
|
line_i++;
|
||||||
break;
|
break;
|
||||||
|
@ -228,6 +228,9 @@ void RenderD7::Error::DisplayError(std::string toptext, std::string errortext, i
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include <renderd7/BitmapPrinter.hpp>
|
||||||
|
|
||||||
void RenderD7::Error::DisplayFatalError(std::string toptext, std::string errortext)
|
void RenderD7::Error::DisplayFatalError(std::string toptext, std::string errortext)
|
||||||
{
|
{
|
||||||
shouldbe_disabled = true;
|
shouldbe_disabled = true;
|
||||||
@ -237,10 +240,18 @@ void RenderD7::Error::DisplayFatalError(std::string toptext, std::string errorte
|
|||||||
C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
|
C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
|
||||||
C2D_TargetClear(Top, DSEVENBLACK);
|
C2D_TargetClear(Top, DSEVENBLACK);
|
||||||
C2D_TargetClear(Bottom, DSEVENBLACK);
|
C2D_TargetClear(Bottom, DSEVENBLACK);
|
||||||
|
RenderD7::BitmapPrinter errorss(400, 240);
|
||||||
|
errorss.DrawRectFilled(0, 0, 400, 240, 0, 0, 0, 255);
|
||||||
|
errorss.DrawText(4, 4, 2, RenderD7::Color::Hex("#ff0000"), toptext);
|
||||||
|
errorss.DrawText(4, 26, 1, RenderD7::Color::Hex("#000000"), errortext);
|
||||||
|
errorss.DrawText(4, 230, 1, RenderD7::Color::Hex("#000000"), "Press Start to Exit!");
|
||||||
|
RenderD7::Image img;
|
||||||
|
img.LoadFromBitmap(errorss.GetBitmap());
|
||||||
RenderD7::OnScreen(Top);
|
RenderD7::OnScreen(Top);
|
||||||
RenderD7::DrawTextCentered(0, 0, 0.7f, DSEVENWHITE, toptext, 400);
|
img.Draw(0, 0);
|
||||||
|
/*RenderD7::DrawTextCentered(0, 0, 0.7f, DSEVENWHITE, toptext, 400);
|
||||||
RenderD7::DrawTextCentered(0, 100, 0.6f, DSEVENWHITE, errortext, 400);
|
RenderD7::DrawTextCentered(0, 100, 0.6f, DSEVENWHITE, errortext, 400);
|
||||||
RenderD7::DrawTextCentered(0, 200, 0.6f, DSEVENWHITE, "Press Start to Exit!", 400);
|
RenderD7::DrawTextCentered(0, 200, 0.6f, DSEVENWHITE, "Press Start to Exit!", 400);*/
|
||||||
C3D_FrameEnd(0);
|
C3D_FrameEnd(0);
|
||||||
while (error___)
|
while (error___)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user