Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Sampler creation
- glCreateSamplers(1, &sampler_handle_);
- SetSamplerParam(GL_TEXTURE_WRAP_S, GL_REPEAT);
- SetSamplerParam(GL_TEXTURE_WRAP_T, GL_REPEAT);
- SetSamplerParam(GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
- SetSamplerParam(GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- // Loading texture from drive to RAM
- image_data_ = SOIL_load_image(file_path_.c_str(), &width_, &height_, nullptr, SOIL_LOAD_RGB);
- if (image_data_ == nullptr) {
- throw std::runtime_error(std::string("Error loading texture at path: ") + file_path_);
- }
- // Creating texture oobject and loading
- glCreateTextures(GL_TEXTURE_2D, 1, &texture_handle_);
- // Allocating storage.
- glTextureStorage2D(
- texture_handle_,
- 1, // Mipmaps
- GL_RGB,
- width_,
- height_
- );
- glTextureSubImage2D(
- texture_handle_,
- 0, // Mipmaps
- 0, 0,
- width_, height_,
- GL_RGB,
- GL_FLOAT,
- image_data_
- );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement