annotate semiconginev2/old/panel.nim @ 1225:27cd1c21290e compiletime-tests

did: refactor resources
author sam <sam@basx.dev>
date Wed, 17 Jul 2024 22:20:59 +0700
parents 56781cc0fc7c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
431
e13b75bff00c intermediate commit :P
Sam <sam@basx.dev>
parents: 430
diff changeset
1 import std/strformat
433
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
2 import std/tables
431
e13b75bff00c intermediate commit :P
Sam <sam@basx.dev>
parents: 430
diff changeset
3
430
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
4 import ./core
431
e13b75bff00c intermediate commit :P
Sam <sam@basx.dev>
parents: 430
diff changeset
5 import ./mesh
433
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
6 import ./material
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
7 import ./vulkan/shader
434
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
8 import ./events
430
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
9
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
10 const
433
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
11 # font shader
431
e13b75bff00c intermediate commit :P
Sam <sam@basx.dev>
parents: 430
diff changeset
12 SHADER_ATTRIB_PREFIX = "semicon_panel_"
e13b75bff00c intermediate commit :P
Sam <sam@basx.dev>
parents: 430
diff changeset
13 MAX_PANEL_MATERIALS = 10
433
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
14 POSITION_ATTRIB = SHADER_ATTRIB_PREFIX & "position"
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
15 UV_ATTRIB = SHADER_ATTRIB_PREFIX & "uv"
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
16 PANEL_MATERIAL_TYPE* = MaterialType(
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
17 name: "default-panel-material-type",
999
b5be4ea07c3c fix: errors that have now been discovered thanks to last commit :)
sam <sam@basx.dev>
parents: 998
diff changeset
18 vertexAttributes: {POSITION_ATTRIB: Vec3F32, UV_ATTRIB: Vec2F32}.toTable,
b5be4ea07c3c fix: errors that have now been discovered thanks to last commit :)
sam <sam@basx.dev>
parents: 998
diff changeset
19 instanceAttributes: {TRANSFORM_ATTRIB: Mat4F32, MATERIALINDEX_ATTRIBUTE: UInt16}.toTable,
433
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
20 attributes: {"panelTexture": TextureType, "color": Vec4F32}.toTable,
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
21 )
1139
114f395b9144 did: finish refactoring and updated all tests accordingly
sam <sam@basx.dev>
parents: 1138
diff changeset
22 PANEL_SHADER* = CreateShaderConfiguration(
998
7e89c8fe57a8 did: add name for material types and fix shader-materialtype-compatability check
sam <sam@basx.dev>
parents: 444
diff changeset
23 name = "panel shader",
433
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
24 inputs = [
1137
a4aa9f374d44 did: more renaming
sam <sam@basx.dev>
parents: 1136
diff changeset
25 Attr[Mat4](TRANSFORM_ATTRIB, memoryPerformanceHint = PreferFastWrite, perInstance = true),
a4aa9f374d44 did: more renaming
sam <sam@basx.dev>
parents: 1136
diff changeset
26 Attr[Vec3f](POSITION_ATTRIB, memoryPerformanceHint = PreferFastWrite),
a4aa9f374d44 did: more renaming
sam <sam@basx.dev>
parents: 1136
diff changeset
27 Attr[Vec2f](UV_ATTRIB, memoryPerformanceHint = PreferFastWrite),
a4aa9f374d44 did: more renaming
sam <sam@basx.dev>
parents: 1136
diff changeset
28 Attr[uint16](MATERIALINDEX_ATTRIBUTE, memoryPerformanceHint = PreferFastRead, perInstance = true),
433
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
29 ],
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
30 intermediates = [
1137
a4aa9f374d44 did: more renaming
sam <sam@basx.dev>
parents: 1136
diff changeset
31 Attr[Vec2f]("uvFrag"),
a4aa9f374d44 did: more renaming
sam <sam@basx.dev>
parents: 1136
diff changeset
32 Attr[uint16]("materialIndexOut", noInterpolation = true)
433
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
33 ],
1137
a4aa9f374d44 did: more renaming
sam <sam@basx.dev>
parents: 1136
diff changeset
34 outputs = [Attr[Vec4f]("color")],
a4aa9f374d44 did: more renaming
sam <sam@basx.dev>
parents: 1136
diff changeset
35 uniforms = [Attr[Vec4f]("color", arrayCount = MAX_PANEL_MATERIALS), Attr[float32](ASPECT_RATIO_ATTRIBUTE)],
a4aa9f374d44 did: more renaming
sam <sam@basx.dev>
parents: 1136
diff changeset
36 samplers = [Attr[Texture]("panelTexture", arrayCount = MAX_PANEL_MATERIALS)],
433
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
37 vertexCode = &"""
444
f9d25bc331b3 did: same for panels
Sam <sam@basx.dev>
parents: 436
diff changeset
38 gl_Position = vec4({POSITION_ATTRIB}.x, {POSITION_ATTRIB}.y * Uniforms.{ASPECT_RATIO_ATTRIBUTE}, {POSITION_ATTRIB}.z, 1.0) * {TRANSFORM_ATTRIB};
433
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
39 uvFrag = {UV_ATTRIB};
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
40 materialIndexOut = {MATERIALINDEX_ATTRIBUTE};
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
41 """,
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
42 fragmentCode = &"""color = Uniforms.color[materialIndexOut] * texture(panelTexture[materialIndexOut], uvFrag);"""
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
43 )
430
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
44
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
45 var instanceCounter = 0
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
46
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
47 type
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
48 Panel* = object
431
e13b75bff00c intermediate commit :P
Sam <sam@basx.dev>
parents: 430
diff changeset
49 texture: Texture
430
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
50 horizontalAlignment: HorizontalAlignment = Center
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
51 verticalAlignment: VerticalAlignment = Center
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
52 dirty: bool
444
f9d25bc331b3 did: same for panels
Sam <sam@basx.dev>
parents: 436
diff changeset
53 mesh*: Mesh
434
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
54 # input handling
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
55 onMouseDown*: proc(panel: var Panel, buttons: set[MouseButton])
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
56 onMouseUp*: proc(panel: var Panel, buttons: set[MouseButton])
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
57 onMouseEnter*: proc(panel: var Panel)
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
58 onMouseMove*: proc(panel: var Panel)
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
59 onMouseLeave*: proc(panel: var Panel)
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
60 hasMouse*: bool
430
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
61
433
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
62 proc `$`*(panel: Panel): string =
444
f9d25bc331b3 did: same for panels
Sam <sam@basx.dev>
parents: 436
diff changeset
63 &"Panel {panel.mesh}"
433
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
64
1138
02e1d2658ff5 did: more renaming
sam <sam@basx.dev>
parents: 1137
diff changeset
65 proc Refresh*(panel: var Panel) =
433
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
66 if not panel.dirty:
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
67 return
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
68
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
69 var
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
70 offsetX = case panel.horizontalAlignment
444
f9d25bc331b3 did: same for panels
Sam <sam@basx.dev>
parents: 436
diff changeset
71 of Left: 0.5
433
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
72 of Center: 0
444
f9d25bc331b3 did: same for panels
Sam <sam@basx.dev>
parents: 436
diff changeset
73 of Right: -0.5
433
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
74 offsetY = case panel.verticalAlignment
444
f9d25bc331b3 did: same for panels
Sam <sam@basx.dev>
parents: 436
diff changeset
75 of Top: 0.5
433
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
76 of Center: 0
444
f9d25bc331b3 did: same for panels
Sam <sam@basx.dev>
parents: 436
diff changeset
77 of Bottom: -0.5
433
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
78
1136
71315636ba82 did: refactor naming in tons of places
sam <sam@basx.dev>
parents: 999
diff changeset
79 panel.mesh[POSITION_ATTRIB, 0] = NewVec3f(-0.5 + offsetX, -0.5 + offsetY)
71315636ba82 did: refactor naming in tons of places
sam <sam@basx.dev>
parents: 999
diff changeset
80 panel.mesh[POSITION_ATTRIB, 1] = NewVec3f(+0.5 + offsetX, -0.5 + offsetY)
71315636ba82 did: refactor naming in tons of places
sam <sam@basx.dev>
parents: 999
diff changeset
81 panel.mesh[POSITION_ATTRIB, 2] = NewVec3f(+0.5 + offsetX, +0.5 + offsetY)
71315636ba82 did: refactor naming in tons of places
sam <sam@basx.dev>
parents: 999
diff changeset
82 panel.mesh[POSITION_ATTRIB, 3] = NewVec3f(-0.5 + offsetX, +0.5 + offsetY)
433
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
83
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
84 panel.dirty = false
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
85
1138
02e1d2658ff5 did: more renaming
sam <sam@basx.dev>
parents: 1137
diff changeset
86 proc InitPanel*(
444
f9d25bc331b3 did: same for panels
Sam <sam@basx.dev>
parents: 436
diff changeset
87 transform = Unit4,
1136
71315636ba82 did: refactor naming in tons of places
sam <sam@basx.dev>
parents: 999
diff changeset
88 color = NewVec4f(1, 1, 1, 1),
434
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
89 texture = EMPTY_TEXTURE,
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
90 horizontalAlignment = HorizontalAlignment.Center,
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
91 verticalAlignment = VerticalAlignment.Center,
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
92 onMouseDown: proc(panel: var Panel, buttons: set[MouseButton]) = nil,
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
93 onMouseUp: proc(panel: var Panel, buttons: set[MouseButton]) = nil,
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
94 onMouseEnter: proc(panel: var Panel) = nil,
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
95 onMouseMove: proc(panel: var Panel) = nil,
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
96 onMouseLeave: proc(panel: var Panel) = nil,
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
97 ): Panel =
431
e13b75bff00c intermediate commit :P
Sam <sam@basx.dev>
parents: 430
diff changeset
98
434
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
99 result = Panel(
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
100 texture: texture,
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
101 horizontalAlignment: horizontalAlignment,
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
102 verticalAlignment: verticalAlignment,
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
103 onMouseDown: onMouseDown,
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
104 onMouseUp: onMouseUp,
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
105 onMouseEnter: onMouseEnter,
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
106 onMouseMove: onMouseMove,
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
107 onMouseLeave: onMouseLeave,
444
f9d25bc331b3 did: same for panels
Sam <sam@basx.dev>
parents: 436
diff changeset
108 dirty: true,
434
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
109 )
431
e13b75bff00c intermediate commit :P
Sam <sam@basx.dev>
parents: 430
diff changeset
110
1139
114f395b9144 did: finish refactoring and updated all tests accordingly
sam <sam@basx.dev>
parents: 1138
diff changeset
111 result.mesh = NewMesh(
444
f9d25bc331b3 did: same for panels
Sam <sam@basx.dev>
parents: 436
diff changeset
112 name = &"panel-{instanceCounter}",
433
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
113 positions = newSeq[Vec3f](4),
431
e13b75bff00c intermediate commit :P
Sam <sam@basx.dev>
parents: 430
diff changeset
114 indices = @[
e13b75bff00c intermediate commit :P
Sam <sam@basx.dev>
parents: 430
diff changeset
115 [uint16(0), uint16(1), uint16(2)],
e13b75bff00c intermediate commit :P
Sam <sam@basx.dev>
parents: 430
diff changeset
116 [uint16(2), uint16(3), uint16(0)],
433
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
117 ],
1136
71315636ba82 did: refactor naming in tons of places
sam <sam@basx.dev>
parents: 999
diff changeset
118 uvs = @[NewVec2f(0, 1), NewVec2f(1, 1), NewVec2f(1, 0), NewVec2f(0, 0)],
444
f9d25bc331b3 did: same for panels
Sam <sam@basx.dev>
parents: 436
diff changeset
119 transform = transform
433
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
120 )
1139
114f395b9144 did: finish refactoring and updated all tests accordingly
sam <sam@basx.dev>
parents: 1138
diff changeset
121 result.mesh[].RenameAttribute("position", POSITION_ATTRIB)
114f395b9144 did: finish refactoring and updated all tests accordingly
sam <sam@basx.dev>
parents: 1138
diff changeset
122 result.mesh[].RenameAttribute("uv", UV_ATTRIB)
114f395b9144 did: finish refactoring and updated all tests accordingly
sam <sam@basx.dev>
parents: 1138
diff changeset
123 result.mesh.material = InitMaterialData(
433
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
124 theType = PANEL_MATERIAL_TYPE,
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
125 name = "Panel material",
1137
a4aa9f374d44 did: more renaming
sam <sam@basx.dev>
parents: 1136
diff changeset
126 attributes = {"panelTexture": InitDataList(@[texture]), "color": InitDataList(@[color])},
433
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
127 )
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
128 inc instanceCounter
1139
114f395b9144 did: finish refactoring and updated all tests accordingly
sam <sam@basx.dev>
parents: 1138
diff changeset
129 result.Refresh()
431
e13b75bff00c intermediate commit :P
Sam <sam@basx.dev>
parents: 430
diff changeset
130
1138
02e1d2658ff5 did: more renaming
sam <sam@basx.dev>
parents: 1137
diff changeset
131 proc Color*(panel: Panel): Vec4f =
433
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
132 panel.mesh.material["color", 0, Vec4f]
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
133 proc `color=`*(panel: var Panel, value: Vec4f) =
1139
114f395b9144 did: finish refactoring and updated all tests accordingly
sam <sam@basx.dev>
parents: 1138
diff changeset
134 if value != panel.mesh.material["color", 0, Vec4f]:
433
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
135 panel.mesh.material["color", 0] = value
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
136
1138
02e1d2658ff5 did: more renaming
sam <sam@basx.dev>
parents: 1137
diff changeset
137 proc HorizontalAlignment*(panel: Panel): HorizontalAlignment =
430
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
138 panel.horizontalAlignment
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
139 proc `horizontalAlignment=`*(panel: var Panel, value: HorizontalAlignment) =
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
140 if value != panel.horizontalAlignment:
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
141 panel.horizontalAlignment = value
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
142 panel.dirty = true
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
143
1138
02e1d2658ff5 did: more renaming
sam <sam@basx.dev>
parents: 1137
diff changeset
144 proc VerticalAlignment*(panel: Panel): VerticalAlignment =
430
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
145 panel.verticalAlignment
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
146 proc `verticalAlignment=`*(panel: var Panel, value: VerticalAlignment) =
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
147 if value != panel.verticalAlignment:
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
148 panel.verticalAlignment = value
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
149 panel.dirty = true
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
150
1138
02e1d2658ff5 did: more renaming
sam <sam@basx.dev>
parents: 1137
diff changeset
151 proc Contains*(panel: Panel, p: Vec2f, aspectRatio: float32): bool =
434
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
152 let
1136
71315636ba82 did: refactor naming in tons of places
sam <sam@basx.dev>
parents: 999
diff changeset
153 cursor = panel.mesh.transform.Inversed * p.ToVec3
444
f9d25bc331b3 did: same for panels
Sam <sam@basx.dev>
parents: 436
diff changeset
154 p1 = panel.mesh[POSITION_ATTRIB, 0, Vec3f]
f9d25bc331b3 did: same for panels
Sam <sam@basx.dev>
parents: 436
diff changeset
155 p2 = panel.mesh[POSITION_ATTRIB, 2, Vec3f]
434
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
156 left = min(p1.x, p2.x)
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
157 right = max(p1.x, p2.x)
444
f9d25bc331b3 did: same for panels
Sam <sam@basx.dev>
parents: 436
diff changeset
158 top = min(p1.y * aspectRatio, p2.y * aspectRatio)
f9d25bc331b3 did: same for panels
Sam <sam@basx.dev>
parents: 436
diff changeset
159 bottom = max(p1.y * aspectRatio, p2.y * aspectRatio)
434
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
160 return left <= cursor.x and cursor.x <= right and top <= cursor.y and cursor.y <= bottom