webgl: Don't change wrapping mode in WebGL1

This commit is contained in:
Mike Welsh 2020-05-02 08:18:45 -07:00
parent 936b314569
commit caf421144a
2 changed files with 38 additions and 17 deletions

32
Cargo.lock generated
View File

@ -1826,22 +1826,6 @@ dependencies = [
"ruffle_core 0.1.0",
]
[[package]]
name = "ruffle_render_wgpu"
version = "0.1.0"
dependencies = [
"bytemuck 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
"image 0.23.4 (registry+https://github.com/rust-lang/crates.io-index)",
"jpeg-decoder 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"lyon 0.15.8 (registry+https://github.com/rust-lang/crates.io-index)",
"raw-window-handle 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"ruffle_core 0.1.0",
"wgpu 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"wgpu-native 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "ruffle_render_webgl"
version = "0.1.0"
@ -1858,6 +1842,22 @@ dependencies = [
"web-sys 0.3.34 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "ruffle_render_wgpu"
version = "0.1.0"
dependencies = [
"bytemuck 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
"image 0.23.4 (registry+https://github.com/rust-lang/crates.io-index)",
"jpeg-decoder 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"lyon 0.15.8 (registry+https://github.com/rust-lang/crates.io-index)",
"raw-window-handle 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"ruffle_core 0.1.0",
"wgpu 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"wgpu-native 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "ruffle_scanner"
version = "0.1.0"

View File

@ -670,6 +670,16 @@ impl RenderBackend for WebGlRenderBackend {
)
.warn_on_error();
// You must set the texture parameters for non-power-of-2 textures to function in WebGL.
self.gl
.tex_parameteri(Gl::TEXTURE_2D, Gl::TEXTURE_WRAP_S, Gl::CLAMP_TO_EDGE as i32);
self.gl
.tex_parameteri(Gl::TEXTURE_2D, Gl::TEXTURE_WRAP_T, Gl::CLAMP_TO_EDGE as i32);
self.gl
.tex_parameteri(Gl::TEXTURE_2D, Gl::TEXTURE_MIN_FILTER, Gl::LINEAR as i32);
self.gl
.tex_parameteri(Gl::TEXTURE_2D, Gl::TEXTURE_MAG_FILTER, Gl::LINEAR as i32);
let handle = BitmapHandle(self.textures.len());
self.textures.push((
id,
@ -713,6 +723,16 @@ impl RenderBackend for WebGlRenderBackend {
)
.warn_on_error();
// You must set the texture parameters for non-power-of-2 textures to function in WebGL.
self.gl
.tex_parameteri(Gl::TEXTURE_2D, Gl::TEXTURE_WRAP_S, Gl::CLAMP_TO_EDGE as i32);
self.gl
.tex_parameteri(Gl::TEXTURE_2D, Gl::TEXTURE_WRAP_T, Gl::CLAMP_TO_EDGE as i32);
self.gl
.tex_parameteri(Gl::TEXTURE_2D, Gl::TEXTURE_MIN_FILTER, Gl::LINEAR as i32);
self.gl
.tex_parameteri(Gl::TEXTURE_2D, Gl::TEXTURE_MAG_FILTER, Gl::LINEAR as i32);
let handle = BitmapHandle(self.textures.len());
self.textures.push((
id,
@ -1053,7 +1073,8 @@ impl RenderBackend for WebGlRenderBackend {
.tex_parameteri(Gl::TEXTURE_2D, Gl::TEXTURE_MAG_FILTER, filter);
self.gl
.tex_parameteri(Gl::TEXTURE_2D, Gl::TEXTURE_MIN_FILTER, filter);
let wrap = if bitmap.is_repeating {
// On WebGL1, you are unable to change the wrapping parameter causes non-power-of-2 textures.
let wrap = if self.gl2.is_some() && bitmap.is_repeating {
Gl::MIRRORED_REPEAT as i32
} else {
Gl::CLAMP_TO_EDGE as i32