MCPcopy Create free account
hub / github.com/defold/defold / debug_text

Method debug_text

engine/dlib/src/basis/encoder/basisu_enc.cpp:2055–2105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2053 }
2054
2055 void image::debug_text(uint32_t x_ofs, uint32_t y_ofs, uint32_t scale_x, uint32_t scale_y, const color_rgba& fg, const color_rgba* pBG, bool alpha_only, const char* pFmt, ...)
2056 {
2057 char buf[2048];
2058
2059 va_list args;
2060 va_start(args, pFmt);
2061#ifdef _WIN32
2062 vsprintf_s(buf, sizeof(buf), pFmt, args);
2063#else
2064 vsnprintf(buf, sizeof(buf), pFmt, args);
2065#endif
2066 va_end(args);
2067
2068 const char* p = buf;
2069
2070 const uint32_t orig_x_ofs = x_ofs;
2071
2072 while (*p)
2073 {
2074 uint8_t c = *p++;
2075 if ((c < 32) || (c > 127))
2076 c = '.';
2077
2078 const uint8_t* pGlpyh = &g_debug_font8x8_basic[c - 32][0];
2079
2080 for (uint32_t y = 0; y < 8; y++)
2081 {
2082 uint32_t row_bits = pGlpyh[y];
2083 for (uint32_t x = 0; x < 8; x++)
2084 {
2085 const uint32_t q = row_bits & (1 << x);
2086
2087 const color_rgba* pColor = q ? &fg : pBG;
2088 if (!pColor)
2089 continue;
2090
2091 if (alpha_only)
2092 fill_box_alpha(x_ofs + x * scale_x, y_ofs + y * scale_y, scale_x, scale_y, *pColor);
2093 else
2094 fill_box(x_ofs + x * scale_x, y_ofs + y * scale_y, scale_x, scale_y, *pColor);
2095 }
2096 }
2097
2098 x_ofs += 8 * scale_x;
2099 if ((x_ofs + 8 * scale_x) > m_width)
2100 {
2101 x_ofs = orig_x_ofs;
2102 y_ofs += 8 * scale_y;
2103 }
2104 }
2105 }
2106
2107} // namespace basisu

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected