# HG changeset patch # User Sam # Date 1707483775 -25200 # Node ID e13b75bff00c4db36acb441740a3a6e8fdd88b5e # Parent c5999345f42c6cbe921d40f3dd87c139299bda0b intermediate commit :P diff -r c5999345f42c -r e13b75bff00c semicongine.nim --- a/semicongine.nim Mon Feb 05 23:11:22 2024 +0700 +++ b/semicongine.nim Fri Feb 09 20:02:55 2024 +0700 @@ -13,6 +13,7 @@ import semicongine/material import semicongine/mesh import semicongine/noise +import semicongine/panel import semicongine/renderer import semicongine/resources import semicongine/settings @@ -29,6 +30,7 @@ export material export mesh export noise +export panel export renderer export resources export settings diff -r c5999345f42c -r e13b75bff00c semicongine/panel.nim --- a/semicongine/panel.nim Mon Feb 05 23:11:22 2024 +0700 +++ b/semicongine/panel.nim Fri Feb 09 20:02:55 2024 +0700 @@ -1,8 +1,11 @@ +import std/strformat + import ./core +import ./mesh const - SHADER_ATTRIB_PREFIX = "semicon_text_" - MAX_TEXT_MATERIALS = 10 + SHADER_ATTRIB_PREFIX = "semicon_panel_" + MAX_PANEL_MATERIALS = 10 var instanceCounter = 0 @@ -12,13 +15,27 @@ size: Vec2f color*: Vec4f + texture: Texture horizontalAlignment: HorizontalAlignment = Center verticalAlignment: VerticalAlignment = Center aspect_ratio: float32 - texture: Vec4f dirty: bool mesh: Mesh +proc initPanel*(position = newVec2f(), size = newVec2f(), color = newVec4f(1, 1, 1, 1), texture = EMPTY_TEXTURE, horizontalAlignment = HorizontalAlignment.Center, verticalAlignment = VerticalAlignment.Center): Panel = + + result = Panel(position: position, size: size, color: color, texture: texture, horizontalAlignment: horizontalAlignment, verticalAlignment: verticalAlignment, aspect_ratio: 1) + + inc instanceCounter + var + positions = newSeq[Vec3f](4) + indices = @[ + [uint16(0), uint16(1), uint16(2)], + [uint16(2), uint16(3), uint16(0)], + ] + uvs = newSeq[Vec2f](4) + result.mesh = newMesh(positions = positions, indices = indices, uvs = uvs, name = &"panel-{instanceCounter}") + proc position*(panel: Panel): Vec2f = panel.position proc `position=`*(panel: var Panel, value: Vec2f) = diff -r c5999345f42c -r e13b75bff00c tests/test_panel.nim --- a/tests/test_panel.nim Mon Feb 05 23:11:22 2024 +0700 +++ b/tests/test_panel.nim Fri Feb 09 20:02:55 2024 +0700 @@ -10,7 +10,7 @@ # build scene var scene = Scene(name: "main") - var panel = initPanel(position: newVec2f(0, 0), size: newVec2f(0.1, 0.1)) + var panel = Panel(position: newVec2f(0, 0), size: newVec2f(0.1, 0.1)) scene.add panel engine.loadScene(scene)