1 type Materials = 2 let sampler : VkSampler 3 val control : Material 4 val font_materials = Map<Font, Material>.new 5 val font_materials_rgba = Map<Font, Material>.new 6 7 let ensure_font (font : Font) = 8 if not font_materials.contains font then 9 let font_image = Image.from_memory "font" font.memory 10 let font_image_rgba = Image.from_memory "font_rgba" font.memory_rgba 11 let material = Material.create 12 Shader.font_vertex Shader.font_fragment 13 resources = (font_image, self.sampler) 14 |> to_descriptor "source" 15 |> list_of 16 17 is_translucent = true 18 19 let material_rgba = Material.create 20 Shader.font_rgba_vertex 21 Shader.font_rgba_fragment 22 resources = (font_image_rgba, self.sampler) 23 |> to_descriptor "source" 24 |> list_of 25 26 is_translucent = true 27 28 font_materials.add font material 29 font_materials_rgba.add font material_rgba 30 31 def text (font : Font) = 32 ensure_font font 33 font_materials[font] 34 35 def text_rgba (font : Font) = 36 ensure_font font 37 font_materials_rgba[font] 38 39 object Materials = 40 def create (sampler : VkSampler) = 41 let material = Material.create 42 Shader.color_vertex 43 Shader.color_fragment 44 List.new 45 is_translucent = false 46 47 Materials =sampler 48 control = material 49