summaryrefslogtreecommitdiff
path: root/test/src
diff options
context:
space:
mode:
authorFrederico Linhares <fred@linhares.blue>2023-04-20 16:17:49 -0300
committerFrederico Linhares <fred@linhares.blue>2023-04-20 16:17:49 -0300
commit66cb556fb6f87d195aacf8a25ffafb86d524da19 (patch)
tree358b69272bd46190092e4297f85642033b493d0a /test/src
parent63748c1035d3fb39ad7b6ab1f6ad1f829ed85758 (diff)
feat Create text rendering system
Diffstat (limited to 'test/src')
-rw-r--r--test/src/main.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/test/src/main.rb b/test/src/main.rb
index 33d0b1d..499a49a 100644
--- a/test/src/main.rb
+++ b/test/src/main.rb
@@ -1,4 +1,4 @@
-# Copyright 2022 Frederico de Oliveira Linhares
+# Copyright 2022-2023 Frederico de Oliveira Linhares
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -25,6 +25,8 @@ 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")
$color = CandyGear::Vector3D.new(0.8, 0.2, 0.2);
$model = CandyGear::Model.new(mesh, texture);
@@ -32,6 +34,10 @@ 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);
$instances = [
CandyGear::Vector3D.new(5.0, 0.0, 0.0),
@@ -89,6 +95,7 @@ def quit() = CandyGear.quit();
def tick()
$sprite.draw($view1, $sprite_position);
+ $text_sprite.draw($view1, $text_position);
$instances_rotation.rotate(0.0, BOX_ROTATION_SPEED);
$rectangle.draw_rectangle($view1, $color);
$instances.each do |i|