Advertisement
Guest User

Untitled

a guest
May 21st, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. void CMyApp::TextureFromFileAttach(const char* filename, GLuint role) const
  2. {
  3. SDL_Surface* loaded_img = IMG_Load(filename);
  4.  
  5. int img_mode = 0;
  6.  
  7. if (loaded_img == 0)
  8. {
  9. std::cout << "[TextureFromFile] Hiba a kép betöltése közben: " << filename << std::endl;
  10. return;
  11. }
  12.  
  13. #if SDL_BYTEORDER == SDL_LIL_ENDIAN
  14. if (loaded_img->format->BytesPerPixel == 4)
  15. img_mode = GL_RGBA;
  16. else
  17. img_mode = GL_RGB;
  18. #else
  19. if (loaded_img->format->BytesPerPixel == 4)
  20. img_mode = GL_RGBA;
  21. else
  22. img_mode = GL_RGB;
  23. #endif
  24.  
  25. glTexImage2D(role, 0, GL_RGBA, loaded_img->w, loaded_img->h, 0, img_mode, GL_UNSIGNED_BYTE, loaded_img->pixels);
  26.  
  27. SDL_FreeSurface(loaded_img);
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement