Advertisement
Guest User

SDL_BlitSurface SDL2.0

a guest
Dec 24th, 2012
642
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.37 KB | None | 0 0
  1. //This works just fine
  2. SDL_Texture* BMF::getCharTexture(unsigned char character) const {
  3.     SDL_Surface* surf_char = this->chars.find(character)->second->getSurf();
  4.     SDL_Texture* text = SDL_CreateTextureFromSurface(Engine::Instance()->getRenderer(), surf_char);
  5.     return text;
  6. }
  7.  
  8. //This doesn't render anything
  9. SDL_Texture* BMF::getCharTexture(unsigned char character) const {
  10.     BMF_Char* bmf_char = this->chars.find(character)->second;
  11.     SDL_Surface* final_surf = NULL;
  12.     int width = bmf_char->getWidth(); //tested it's non zero
  13.     int height = bmf_char->getHeight(); //tested its' non zero
  14.     Uint32 rmask, gmask, bmask, amask;
  15. #if SDL_BYTEORDER == SDL_BIG_ENDIAN
  16.     rmask = 0xff000000;
  17.    gmask = 0x00ff0000;
  18.     bmask = 0x0000ff00;
  19.     amask = 0x000000ff;
  20. #else
  21.     rmask = 0x000000ff;
  22.     gmask = 0x0000ff00;
  23.     bmask = 0x00ff0000;
  24.     amask = 0xff000000;
  25. #endif
  26.     final_surf = SDL_CreateRGBSurface(0, width, height, 32, rmask, gmask, bmask, amask);//this will pass with no errors
  27.    
  28.     SDL_Rect dest;
  29.     dest.x = 0;
  30.     dest.y = 0;
  31.     dest.h = height;
  32.     dest.w = width;
  33.    
  34.     SDL_BlitSurface(bmf_char->getSurf(), NULL, final_surf, &dest);//same, pass
  35. with no errors
  36.    
  37.     SDL_Texture* text = SDL_CreateTextureFromSurface(Engine::Instance()->getRenderer(), final_surf);
  38.     return text; //not even single pixel in text
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement