Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. void animate::write(const char *msg,int x,int y,int r,int g,int b,int Size)
  2. {
  3. TTF_Font *font = TTF_OpenFont("Sans.ttf" , Size);
  4. SDL_Color color = {r,g,b};
  5. SDL_Rect rect;
  6. SDL_Surface *surf = TTF_RenderText_Solid(font,msg,color);
  7. SDL_Texture *tex = SDL_CreateTextureFromSurface(render,surf);
  8. rect.x=x;
  9. rect.y=y;
  10. rect.w=surf->w;
  11. rect.w=surf->h;
  12. SDL_FreeSurface(surf);
  13. SDL_RenderCopy(render,tex,NULL,&rect);
  14. SDL_DestroyTexture(tex);
  15. }
  16.  
  17. void animate::Render()
  18. {
  19. SDL_SetRenderDrawColor(render,150,170,190,255);
  20. rect.x=rect.y=0;
  21. rect.w=windowWidth;
  22. rect.h=windowHeight;
  23. SDL_RenderFillRect(render,&rect);
  24.  
  25. draw(face);
  26. write("hello",20,30,0,255,0,24); // Getting error on adding this
  27.  
  28. frameCount++;
  29. int timerFPS = SDL_GetTicks() + lastFrame;
  30. if(timerFPS < 1000/60)
  31. {
  32. SDL_Delay((1000/60) - timerFPS);
  33. }
  34.  
  35. SDL_RenderPresent(render);
  36. }
  37.  
  38. SDL_FreeSurface(surf);
  39. SDL_RenderCopy(render,tex,NULL,&rect);`
  40.  
  41. SDL_RenderCopy(render,tex,NULL,&rect);
  42. SDL_FreeSurface(surf);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement