diff options
Diffstat (limited to 'engine/src/renderer/opengl.rs')
-rw-r--r-- | engine/src/renderer/opengl.rs | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/engine/src/renderer/opengl.rs b/engine/src/renderer/opengl.rs index 3be892e..ea66de0 100644 --- a/engine/src/renderer/opengl.rs +++ b/engine/src/renderer/opengl.rs @@ -48,9 +48,11 @@ use crate::opengl::shader::{ }; use crate::opengl::texture::{ set_active_texture_unit, + Filtering as GlTextureFiltering, PixelDataFormat as GlTexturePixelDataFormat, Texture as GlTexture, TextureUnit, + Wrapping as GlTextureWrapping, }; use crate::opengl::vertex_array::{ DataType as VertexArrayDataType, @@ -68,7 +70,11 @@ use crate::opengl::{ use crate::projection::{ClipVolume, Projection}; use crate::renderer::opengl::vertex::{AttributeComponentType, Vertex}; use crate::renderer::RENDER_PHASE; -use crate::texture::Properties as TextureProperties; +use crate::texture::{ + Filtering as TextureFiltering, + Properties as TextureProperties, + Wrapping as TextureWrapping, +}; use crate::transform::{Scale, WorldPosition}; use crate::util::{defer, Defer, RefOrValue}; use crate::vector::{Vec2, Vec3}; @@ -357,7 +363,15 @@ fn create_gl_texture(image: &Image, texture_properties: &TextureProperties) -> G }, ); - gl_texture.apply_properties(texture_properties); + gl_texture.set_wrap(texture_wrapping_to_gl(texture_properties.wrap)); + + gl_texture.set_magnifying_filter(texture_filtering_to_gl( + texture_properties.magnifying_filter, + )); + + gl_texture.set_minifying_filter(texture_filtering_to_gl( + texture_properties.minifying_filter, + )); gl_texture } @@ -814,3 +828,23 @@ fn create_transformation_matrix(transformation: Transformation) -> Matrix<f32, 4 matrix } + +#[inline] +fn texture_wrapping_to_gl(texture_wrapping: TextureWrapping) -> GlTextureWrapping +{ + match texture_wrapping { + TextureWrapping::Repeat => GlTextureWrapping::Repeat, + TextureWrapping::MirroredRepeat => GlTextureWrapping::MirroredRepeat, + TextureWrapping::ClampToEdge => GlTextureWrapping::ClampToEdge, + TextureWrapping::ClampToBorder => GlTextureWrapping::ClampToBorder, + } +} + +#[inline] +fn texture_filtering_to_gl(texture_filtering: TextureFiltering) -> GlTextureFiltering +{ + match texture_filtering { + TextureFiltering::Linear => GlTextureFiltering::Linear, + TextureFiltering::Nearest => GlTextureFiltering::Nearest, + } +} |