Guest User

Untitled

a guest
Jan 2nd, 2020
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. void Renderer::DrawText(int x, int y, HFont fnt, const wchar_t *s)
  2. {
  3.     if(IsValid() && Font_IsValid(fnt)) {
  4.         SDL_Color color;
  5.         color.r = m_drawColor.r;
  6.         color.g = m_drawColor.g;
  7.         color.b = m_drawColor.b;
  8.         color.a = m_drawColor.a;
  9.  
  10.         SDL_Surface *sf = TTF_RenderUNICODE_Solid(m_FontMap[fnt], (Uint16 *)s, color);
  11.         SDL_Texture *tx = SDL_CreateTextureFromSurface(m_renderer, sf);
  12.  
  13.         int w, h;
  14.         SDL_QueryTexture(tx, nullptr, nullptr, &w, &h);
  15.         SDL_Rect dst = { x, y, w, h };
  16.  
  17.         SDL_RenderCopy(m_renderer, tx, nullptr, &dst);
  18.         SDL_DestroyTexture(tx);
  19.         SDL_FreeSurface(sf);
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment