Advertisement
Guest User

Untitled

a guest
Jul 24th, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. // Sampler creation
  2. glCreateSamplers(1, &sampler_handle_);
  3. SetSamplerParam(GL_TEXTURE_WRAP_S, GL_REPEAT);
  4. SetSamplerParam(GL_TEXTURE_WRAP_T, GL_REPEAT);
  5.  
  6. SetSamplerParam(GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
  7. SetSamplerParam(GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  8.  
  9. // Loading texture from drive to RAM
  10. image_data_ = SOIL_load_image(file_path_.c_str(), &width_, &height_, nullptr, SOIL_LOAD_RGB);
  11.  
  12. if (image_data_ == nullptr) {
  13. throw std::runtime_error(std::string("Error loading texture at path: ") + file_path_);
  14. }
  15.  
  16. // Creating texture oobject and loading
  17. glCreateTextures(GL_TEXTURE_2D, 1, &texture_handle_);
  18.  
  19. // Allocating storage.
  20. glTextureStorage2D(
  21. texture_handle_,
  22. 1, // Mipmaps
  23. GL_RGB,
  24. width_,
  25. height_
  26. );
  27.  
  28. glTextureSubImage2D(
  29. texture_handle_,
  30. 0, // Mipmaps
  31. 0, 0,
  32. width_, height_,
  33. GL_RGB,
  34. GL_FLOAT,
  35. image_data_
  36. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement