MCPcopy Create free account
hub / github.com/baldurk/renderdoc / RenderTextInternal

Method RenderTextInternal

renderdoc/driver/gl/gl_rendertext.cpp:305–580  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

303}
304
305void WrappedOpenGL::RenderTextInternal(float x, float y, const rdcstr &text)
306{
307 if(text.empty())
308 return;
309
310 RDCASSERT(text.size() < FONT_MAX_CHARS);
311
312 ContextData &ctxdata = GetCtxData();
313
314 if(!ctxdata.built || !ctxdata.ready || (ctxdata.Modern() && ctxdata.Program == 0))
315 return;
316
317 // if it's reasonably modern context, assume we can use buffers and UBOs
318 if(ctxdata.Modern())
319 {
320 GL.glBindBuffer(eGL_ARRAY_BUFFER, ctxdata.ArrayBuffer);
321
322 size_t len = text.size();
323
324 if((int)len > FONT_MAX_CHARS)
325 {
326 static bool printedWarning = false;
327
328 // this could be called once a frame, don't want to spam the log
329 if(!printedWarning)
330 {
331 printedWarning = true;
332 RDCWARN("log string '%s' is too long", text.c_str(), (int)len);
333 }
334
335 len = FONT_MAX_CHARS;
336 }
337
338 static const Vec2f basePos[] = {
339 Vec2f(0.0, 0.0), Vec2f(1.0, 0.0), Vec2f(0.0, 1.0),
340 Vec2f(1.0, 0.0), Vec2f(0.0, 1.0), Vec2f(1.0, 1.0),
341 };
342
343 const Vec2f FontScreenAspect(ctxdata.CharAspect / RDCMAX(1.0f, float(ctxdata.initParams.width)),
344 1.0f / RDCMAX(1.0f, float(ctxdata.initParams.height)));
345
346 float *vertexData = new float[5 * len * 6];
347
348 for(size_t i = 0; i < len; i++)
349 {
350 for(int ch = 0; ch < 6; ch++)
351 {
352 Vec2f uv = basePos[ch];
353
354 Vec2f pos = uv;
355 pos.x += float(i) + x;
356 pos.y += y;
357
358 pos.x *= 2.0f * ctxdata.CharSize * FontScreenAspect.x;
359 pos.y *= 2.0f * ctxdata.CharSize * FontScreenAspect.y;
360
361 pos.x -= 1.0f;
362 pos.y -= 1.0f;

Callers

nothing calls this directly

Calls 15

RDCMAXFunction · 0.85
stbtt_GetBakedQuadFunction · 0.85
RDCMINFunction · 0.85
ModernMethod · 0.80
Vec2fClass · 0.50
Vec4fClass · 0.50
emptyMethod · 0.45
sizeMethod · 0.45
glBindBufferMethod · 0.45
c_strMethod · 0.45
glBufferSubDataMethod · 0.45
glEnableiMethod · 0.45

Tested by

no test coverage detected