| 303 | } |
| 304 | |
| 305 | void 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; |
nothing calls this directly
no test coverage detected