Skip to content

Commit 979d9df

Browse files
fix: non-power-of-two texture warnings
1 parent 6a6f10d commit 979d9df

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

lib/mittsu/renderers/opengl/textures/texture.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@ def set_parameters(texture_type, is_image_power_of_two)
6161
glTexParameteri(texture_type, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)
6262

6363
if wrap_s != ClampToEdgeWrapping || wrap_t != ClampToEdgeWrapping
64-
puts "WARNING: Mittsu::Texture: Texture is not power of two. Texture.wrap_s and Texture.wrap_t should be set to Mittsu::ClampToEdgeWrapping. (#{texture.source_file})"
64+
puts "WARNING: Mittsu::Texture: Texture is not power of two. Texture.wrap_s and Texture.wrap_t should be set to Mittsu::ClampToEdgeWrapping. (#{source_file})"
6565
end
6666

6767
glTexParameteri(texture_type, GL_TEXTURE_MAG_FILTER, filter_fallback(mag_filter))
6868
glTexParameteri(texture_type, GL_TEXTURE_MIN_FILTER, filter_fallback(min_filter))
6969

7070
if min_filter != NearestFilter && min_filter != LinearFilter
71-
puts "WARNING: Mittsu::Texture: Texture is not a power of two. Texture.min_filter should be set to Mittsu::NearestFilter or Mittsu::LinearFilter. (#{texture.source_file})"
71+
puts "WARNING: Mittsu::Texture: Texture is not a power of two. Texture.min_filter should be set to Mittsu::NearestFilter or Mittsu::LinearFilter. (#{source_file})"
7272
end
7373

7474
# TODO: anisotropic extension ???
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
require 'minitest_helper'
2+
3+
class TestNonPowerOfTwoTextureSanityCheck < Minitest::Test
4+
def test_that_it_works
5+
width = 800
6+
height = 600
7+
aspect = width.to_f / height.to_f
8+
9+
scene = Mittsu::Scene.new
10+
camera = Mittsu::PerspectiveCamera.new(75.0, aspect, 0.1, 1000.0)
11+
12+
renderer = Mittsu::OpenGLRenderer.new width: width, height: height, title: 'TestTextureSanityCheck'
13+
14+
geometry = Mittsu::BoxGeometry.new(1.0, 1.0, 1.0)
15+
texture = Mittsu::ImageUtils.load_texture(File.expand_path "../../support/samples/test_3x5.png", __FILE__)
16+
texture.wrap_s = Mittsu::RepeatWrapping
17+
texture.wrap_t = Mittsu::RepeatWrapping
18+
texture.min_filter = Mittsu::LinearMipMapLinearFilter
19+
material = Mittsu::MeshBasicMaterial.new(map: texture, normal_map: texture)
20+
cube = Mittsu::Mesh.new(geometry, material)
21+
scene.add(cube)
22+
23+
camera.position.z = 5.0
24+
25+
renderer.window.run do
26+
cube.rotation.x += 0.1
27+
cube.rotation.y += 0.1
28+
29+
renderer.render(scene, camera)
30+
end
31+
end
32+
end

test/support/samples/test_3x5.png

128 Bytes
Loading

0 commit comments

Comments
 (0)