Convenience font rendering function for black text
This commit is contained in:
parent
5d555fd5a0
commit
69d35b5d15
17
.idea/deploymentTargetDropDown.xml
Normal file
17
.idea/deploymentTargetDropDown.xml
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="deploymentTargetDropDown">
|
||||||
|
<runningDeviceTargetSelectedWithDropDown>
|
||||||
|
<Target>
|
||||||
|
<type value="RUNNING_DEVICE_TARGET" />
|
||||||
|
<deviceKey>
|
||||||
|
<Key>
|
||||||
|
<type value="SERIAL_NUMBER" />
|
||||||
|
<value value="R52N60RNQLZ" />
|
||||||
|
</Key>
|
||||||
|
</deviceKey>
|
||||||
|
</Target>
|
||||||
|
</runningDeviceTargetSelectedWithDropDown>
|
||||||
|
<timeTargetWasSelectedWithDropDown value="2022-10-24T10:55:25.742010800Z" />
|
||||||
|
</component>
|
||||||
|
</project>
|
|
@ -196,8 +196,6 @@ void NativeEngine::gameLoop()
|
||||||
float x = 50;
|
float x = 50;
|
||||||
float y = 50;
|
float y = 50;
|
||||||
|
|
||||||
float start_x = x;
|
|
||||||
float start_y = y;
|
|
||||||
y += m_font.baseline_adjust;
|
y += m_font.baseline_adjust;
|
||||||
const char* text = "Hallo Welt";
|
const char* text = "Hallo Welt";
|
||||||
for (const char* c = text; *c != '\0'; ++c) {
|
for (const char* c = text; *c != '\0'; ++c) {
|
||||||
|
@ -211,12 +209,10 @@ void NativeEngine::gameLoop()
|
||||||
Renderer::ptr->addFontRect(
|
Renderer::ptr->addFontRect(
|
||||||
x, y,
|
x, y,
|
||||||
w, h,
|
w, h,
|
||||||
1.f, 1.f, 1.f, 1.f,
|
|
||||||
24.f,
|
24.f,
|
||||||
StringRepository::global->internString("Milky Honey.ttf"),
|
StringRepository::global->internString("Milky Honey.ttf"),
|
||||||
quad.s0, quad.t0,
|
quad.s0, quad.t0,
|
||||||
quad.s1, quad.t1);
|
quad.s1, quad.t1);
|
||||||
ALOGI("%f %f %f %f", quad.x0, quad.y0, quad.x1, quad.y1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ENDE VOM BEISPIELCODE
|
// ENDE VOM BEISPIELCODE
|
||||||
|
|
|
@ -223,6 +223,20 @@ void Renderer::addRect(float x,
|
||||||
m_draw_textures.push_back(texture);
|
m_draw_textures.push_back(texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Renderer::addFontRect(float x,
|
||||||
|
float y,
|
||||||
|
float w,
|
||||||
|
float h,
|
||||||
|
float char_height,
|
||||||
|
StringHandle font,
|
||||||
|
float src_x0,
|
||||||
|
float src_y0,
|
||||||
|
float src_x1,
|
||||||
|
float src_y1)
|
||||||
|
{
|
||||||
|
addFontRect(x, y, w, h, 0.f, 0.f, 0.f, 1.f, char_height, font, src_x0, src_y0, src_x1, src_y1);
|
||||||
|
}
|
||||||
|
|
||||||
void Renderer::addFontRect(float x,
|
void Renderer::addFontRect(float x,
|
||||||
float y,
|
float y,
|
||||||
float w,
|
float w,
|
||||||
|
|
|
@ -114,6 +114,28 @@ public:
|
||||||
float src_w,
|
float src_w,
|
||||||
float src_h);
|
float src_h);
|
||||||
|
|
||||||
|
/// @brief Adds a font rectangle to the screen with black text
|
||||||
|
/// \param x X-coordinate of the top-left corner
|
||||||
|
/// \param y Y-coordinate of the top-left corner
|
||||||
|
/// \param w width in pixels
|
||||||
|
/// \param h height in pixels
|
||||||
|
/// \param char_height Height of characters in pixels
|
||||||
|
/// \param font String handle in the global string repository of the ttf file name
|
||||||
|
/// \param src_x0 bottom left corner of the source rectangle inside the texture [0, 1]
|
||||||
|
/// \param src_y0 bottom left corner of the source rectangle inside the texture [0, 1]
|
||||||
|
/// \param src_x1 top right of the source rectangle inside the texture [0, 1]
|
||||||
|
/// \param src_y1 top right of the source rectangle inside the texture [0, 1]
|
||||||
|
void addFontRect(float x,
|
||||||
|
float y,
|
||||||
|
float w,
|
||||||
|
float h,
|
||||||
|
float char_height,
|
||||||
|
StringHandle font,
|
||||||
|
float src_x0,
|
||||||
|
float src_y0,
|
||||||
|
float src_x1,
|
||||||
|
float src_y1);
|
||||||
|
|
||||||
/// @brief Adds a tinted font rectangle to the screen
|
/// @brief Adds a tinted font rectangle to the screen
|
||||||
/// \param x X-coordinate of the top-left corner
|
/// \param x X-coordinate of the top-left corner
|
||||||
/// \param y Y-coordinate of the top-left corner
|
/// \param y Y-coordinate of the top-left corner
|
||||||
|
@ -125,10 +147,10 @@ public:
|
||||||
/// \param a alpha [0,1]
|
/// \param a alpha [0,1]
|
||||||
/// \param char_height Height of characters in pixels
|
/// \param char_height Height of characters in pixels
|
||||||
/// \param font String handle in the global string repository of the ttf file name
|
/// \param font String handle in the global string repository of the ttf file name
|
||||||
/// \param src_x top left corner of the source rectangle inside the texture [0, 1]
|
/// \param src_x0 bottom left corner of the source rectangle inside the texture [0, 1]
|
||||||
/// \param src_y top left corner of the source rectangle inside the texture [0, 1]
|
/// \param src_y0 bottom left corner of the source rectangle inside the texture [0, 1]
|
||||||
/// \param src_w width of the source rectangle inside the texture [0, 1]
|
/// \param src_x1 top right of the source rectangle inside the texture [0, 1]
|
||||||
/// \param src_h height of the source rectangle inside the texture [0, 1]
|
/// \param src_y1 top right of the source rectangle inside the texture [0, 1]
|
||||||
void addFontRect(float x,
|
void addFontRect(float x,
|
||||||
float y,
|
float y,
|
||||||
float w,
|
float w,
|
||||||
|
@ -139,10 +161,10 @@ public:
|
||||||
float a,
|
float a,
|
||||||
float char_height,
|
float char_height,
|
||||||
StringHandle font,
|
StringHandle font,
|
||||||
float src_x,
|
float src_x0,
|
||||||
float src_y,
|
float src_y0,
|
||||||
float src_w,
|
float src_x1,
|
||||||
float src_h);
|
float src_y1);
|
||||||
|
|
||||||
/// @brief Renders the frame
|
/// @brief Renders the frame
|
||||||
///
|
///
|
||||||
|
|
Loading…
Reference in New Issue
Block a user