Advertisement
Guest User

Untitled

a guest
May 6th, 2015
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. GLuint Render::loadTexture(const sf::String & name)
  2. {
  3. sf::Image image;
  4.  
  5. if (!image.loadFromFile(name))
  6. return EXIT_FAILURE;
  7.  
  8. image.flipVertically();
  9.  
  10. GLuint texture = 0;
  11. glGenTextures(1, &texture);
  12. glBindTexture(GL_TEXTURE_2D, texture);
  13. gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, image.getSize().x, image.getSize().y, GL_RGBA, GL_UNSIGNED_BYTE, image.getPixelsPtr());
  14. glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  15. glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
  16.  
  17. glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, 0x812F);
  18. glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, 0x812F);
  19. glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
  20. glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
  21.  
  22. return texture;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement