| 41 | } |
| 42 | |
| 43 | IGLFont::Ptr OpenGLModule::getFont(IGLFont::Style style, std::size_t size) |
| 44 | { |
| 45 | auto cacheKey = std::make_pair(style, static_cast<int>(size)); |
| 46 | auto cachedFont = _fontCache.find(cacheKey); |
| 47 | |
| 48 | // Try to look up and lock a shared_ptr in our cache |
| 49 | if (cachedFont != _fontCache.end()) |
| 50 | { |
| 51 | auto locked = cachedFont->second.lock(); |
| 52 | |
| 53 | if (locked) |
| 54 | { |
| 55 | return locked; |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | // No cache hit, create new instance |
| 60 | auto font = std::make_shared<gl::GLFont>(style, static_cast<unsigned int>(size)); |
| 61 | |
| 62 | _fontCache[cacheKey] = font; |
| 63 | |
| 64 | return font; |
| 65 | } |
| 66 | |
| 67 | void OpenGLModule::drawString(const std::string& string) const |
| 68 | { |
no test coverage detected