diff options
Diffstat (limited to 'test/src')
-rw-r--r-- | test/src/main.rb | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/test/src/main.rb b/test/src/main.rb index 499a49a..bc28ffc 100644 --- a/test/src/main.rb +++ b/test/src/main.rb @@ -25,8 +25,13 @@ end def init() texture = CandyGear::Texture.from_image("textures/color_texture.qoi"); mesh = CandyGear::Mesh.new("meshes/cube.cgmesh"); - font = CandyGear::Font.new("/usr/share/fonts/TTF/Vera.ttf", 16); - text = CandyGear::Texture.from_text(font, "HelloWorld") + # FIXME: Text rendering crashes with this font: + # font = CandyGear::Font.new("/usr/share/fonts/TTF/sazanami-mincho.ttf", 16); + # FIXME: This font, under this path, may not be present in all Linuxes: + font = CandyGear::Font.new("/usr/share/fonts/TTF/HanaMinA.ttf", 30); + japanese_text = CandyGear::Texture.from_text(font, "こんにちは世界!"); + english_text = CandyGear::Texture.from_text( + font, "The quick brown fox jumps"); $color = CandyGear::Vector3D.new(0.8, 0.2, 0.2); $model = CandyGear::Model.new(mesh, texture); @@ -34,10 +39,15 @@ def init() texture, CandyGear::Vector4D.new(0, 0, 1.0, 1.0)); $rectangle = CandyGear::Vector4D.new(103.0, 1.0, 100.0, 100.0); $sprite_position = CandyGear::Vector4D.new(1.0, 1.0, 100.0, 100.0); - $text_sprite = CandyGear::Sprite.new( - text, CandyGear::Vector4D.new(0, 0, 1.0, 1.0)); - $text_position = CandyGear::Vector4D.new( - 204.0, 1.0, text.width, text.height); + $japanese_text_sprite = CandyGear::Sprite.new( + japanese_text, CandyGear::Vector4D.new(0, 0, 1.0, 1.0)); + $japanese_text_position = CandyGear::Vector4D.new( + 204.0, 1.0, japanese_text.width, japanese_text.height); + $english_text_sprite = CandyGear::Sprite.new( + english_text, CandyGear::Vector4D.new(0, 0, 1.0, 1.0)); + $english_text_position = CandyGear::Vector4D.new( + 204.0, japanese_text.height + 2.0, + english_text.width, english_text.height); $instances = [ CandyGear::Vector3D.new(5.0, 0.0, 0.0), @@ -54,9 +64,9 @@ def init() color = CandyGear::Vector3D.new(0.12, 0.12, 0.18); $view1 = CandyGear::View2D.new( - CandyGear::Vector4D.new(0, 0, 1280, 360), 640, 180); + CandyGear::Vector4D.new(0, 0, 1280, 240), 640, 120); $view2 = CandyGear::View3D.new( - CandyGear::Vector4D.new(0, 360, 1280, 360), 1280, 360); + CandyGear::Vector4D.new(0, 240, 1280, 480), 1280, 480); CandyGear.views = [$view1, $view2]; $view2.camera_position = $camera_position; @@ -95,7 +105,8 @@ def quit() = CandyGear.quit(); def tick() $sprite.draw($view1, $sprite_position); - $text_sprite.draw($view1, $text_position); + $japanese_text_sprite.draw($view1, $japanese_text_position); + $english_text_sprite.draw($view1, $english_text_position); $instances_rotation.rotate(0.0, BOX_ROTATION_SPEED); $rectangle.draw_rectangle($view1, $color); $instances.each do |i| |