Blamite Game Engine - blam!  00296.01.12.21.0102.blamite
The core library for the Blamite Game Engine.
text.cpp File Reference
#include "../drawing.h"
#include <d2d1effects_1.h>
#include <ScreenGrab.h>
#include <wincodec.h>
#include <wrl/client.h>
#include "components/rendering/directx11/utils/render_utils.h"
#include "components/resources/engine_globals/globals.h"
#include "components/rendering/directx11/render_stack/render_stack.h"
#include "components/diagnostics/logger/logger.h"
#include "components/diagnostics/errors/errors.h"
#include "components/rendering/rendering.h"
#include <Strings/components/utils/math/math.h>
#include <Strings/components/utils/string/string.h>
#include "components/core/utils/color/color.h"
#include <Strings/components/utils/saferelease/saferelease.h>

Functions

void log_bitmap_error (std::string message, Font *font, char current_char, BlamLogLevel severity)
 Logs a message to file, and adds information about the font and character that errored. More...
 
HRESULT recolor_bitmap (ID2D1Bitmap **bitmap, D2D1_COLOR_F color, Font *font, FontGlyph *current_glyph, char current_char, ID2D1RenderTarget *target)
 Recolors the specified glyph. More...
 
HRESULT draw_text_main (int origin_x, int origin_y, ID2D1RenderTarget *target, int text_length, const char *text_cstr, Font *font, D2D1_COLOR_F color, bool ignore_color_codes)
 Main function to draw text data. More...
 
HRESULT generate_bitmap (Font *font, std::string text, float x, float y, D2D1_COLOR_F color, bool use_shadow, int shadow_x, int shadow_y, D2D1_COLOR_F shadow_color, bool show_zone, D2D1_COLOR_F zone_color, float zone_thickness, ID2D1Bitmap **text_bitmap, D2D1_RECT_F *area)
 Generates a bitmap containing the full text object to display. More...
 

Function Documentation

◆ draw_text_main()

HRESULT draw_text_main ( int  origin_x,
int  origin_y,
ID2D1RenderTarget *  target,
int  text_length,
const char *  text_cstr,
Font font,
D2D1_COLOR_F  color,
bool  ignore_color_codes 
)

Main function to draw text data.

This will render all text glyphs to the provided render target.

Parameters
origin_x- The X origin coordinate of the text.
origin_y- The Y origin coordinate of the text.
target- The render target on which to draw the text.
text_length- The length of the text to be drawn.
text_cstr- The text to be drawn.
font- A pointer to the font being used.
color- The desired color of the text.
Returns
S_OK if the bitmap was tinted, otherwise returns an error code.

◆ generate_bitmap()

HRESULT generate_bitmap ( Font font,
std::string  text,
float  x,
float  y,
D2D1_COLOR_F  color,
bool  use_shadow,
int  shadow_x,
int  shadow_y,
D2D1_COLOR_F  shadow_color,
bool  show_zone,
D2D1_COLOR_F  zone_color,
float  zone_thickness,
ID2D1Bitmap **  text_bitmap,
D2D1_RECT_F *  area 
)

Generates a bitmap containing the full text object to display.

To prevent noticable "flicker" when text strings are modified, the entire string of text is drawn to a single bitmap. That bitmap is then presented at once, and thus the text and shadow are drawn simultaneously.

Parameters
font- A pointer to the font being used.
text- The text to be drawn.
x- The X origin coordinate of the text.
y- The Y origin coordinate of the text.
color- The desired color of the text.
use_shadow- Whether or not to draw a shadow behind the text.
shadow_x- The X offset of the shadow.
shadow_y- The Y offset of the shadow.
shadow_color- The color to use for the shadow.
show_zone- Whether or not to show a border around the text area.
zone_color- The color of the zone border. Unused if show_zone is set to false.
zone_thickness- The thickness of the zone border. Unused if show_zone is set to false.
text_bitmap- Pointer to a D2D bitmap in which to store the rendered text.
area- A pointer to use for the area of the text.
Returns
S_OK if the bitmap was tinted, otherwise returns an error code.

◆ log_bitmap_error()

void log_bitmap_error ( std::string  message,
Font font,
char  current_char,
BlamLogLevel  severity 
)

Logs a message to file, and adds information about the font and character that errored.

Parameters
message- The message to write to the log.
font- A pointer to the font being used.
current_char- The character being rendered.
severity- The severity of the message.

◆ recolor_bitmap()

HRESULT recolor_bitmap ( ID2D1Bitmap **  bitmap,
D2D1_COLOR_F  color,
Font font,
FontGlyph current_glyph,
char  current_char,
ID2D1RenderTarget *  target 
)

Recolors the specified glyph.

Parameters
bitmap- Pointer to the D2D bitmap to store the recolored glyph data in.
color- The new color of the bitmap.
font- Pointer to the current font.
current_glyph- Pointer to the current font glyph.
current_char- The current character.
target- The D2D render target that the bitmap will be rendered to.
Returns
S_OK if the bitmap was tinted, otherwise returns an error code.