summaryrefslogtreecommitdiff
path: root/engine/src
diff options
context:
space:
mode:
Diffstat (limited to 'engine/src')
-rw-r--r--engine/src/rendering/backend/opengl.rs41
1 files changed, 20 insertions, 21 deletions
diff --git a/engine/src/rendering/backend/opengl.rs b/engine/src/rendering/backend/opengl.rs
index 2394acf..821d039 100644
--- a/engine/src/rendering/backend/opengl.rs
+++ b/engine/src/rendering/backend/opengl.rs
@@ -48,8 +48,8 @@ use opengl_bindings::shader::{
};
use opengl_bindings::texture::{
ColorSpace as GlTextureColorSpace,
+ Error as GlTextureGenerateError,
Filtering as GlTextureFiltering,
- GenerateError as GlTextureGenerateError,
PixelDataFormat as GlTexturePixelDataFormat,
Texture as GlTexture,
Wrapping as GlTextureWrapping,
@@ -1175,43 +1175,42 @@ fn draw_mesh(
}
fn create_gl_texture(
- current_context: &MaybeCurrentContextWithFns,
+ curr_gl_context: &MaybeCurrentContextWithFns,
image: &Image,
texture_properties: &TextureProperties,
) -> Result<GlTexture, GlTextureGenerateError>
{
- let gl_texture = GlTexture::new(current_context);
-
- gl_texture.generate(
- current_context,
- &image.dimensions().into(),
- image.as_bytes(),
- match image.color_type() {
- ImageColorType::Rgb8 => GlTexturePixelDataFormat::Rgb8,
- ImageColorType::Rgba8 => GlTexturePixelDataFormat::Rgba8,
- _ => {
- unimplemented!();
- }
- },
- if image.color_space_is_srgb() {
+ let gl_texture = GlTexture::builder()
+ .image(
+ image.as_bytes(),
+ match image.color_type() {
+ ImageColorType::Rgb8 => GlTexturePixelDataFormat::Rgb8,
+ ImageColorType::Rgba8 => GlTexturePixelDataFormat::Rgba8,
+ _ => {
+ unimplemented!();
+ }
+ },
+ )
+ .size(image.dimensions().into())
+ .color_space(if image.color_space_is_srgb() {
GlTextureColorSpace::Srgb
} else {
GlTextureColorSpace::Linear
- },
- )?;
+ })
+ .create(curr_gl_context)?;
gl_texture.set_wrap(
- current_context,
+ curr_gl_context,
texture_wrapping_to_gl(texture_properties.wrap),
);
gl_texture.set_magnifying_filter(
- current_context,
+ curr_gl_context,
texture_filtering_to_gl(texture_properties.magnifying_filter),
);
gl_texture.set_minifying_filter(
- current_context,
+ curr_gl_context,
texture_filtering_to_gl(texture_properties.minifying_filter),
);