diff src/zamikongine/vertex.nim @ 33:94c38e4b5782

did: refactoring, move more from make to nimscript
author Sam <sam@basx.dev>
date Sun, 15 Jan 2023 23:23:54 +0700
parents 9edca5dc4e93
children 7f99b21a8777
line wrap: on
line diff
--- a/src/zamikongine/vertex.nim	Sat Jan 14 23:34:50 2023 +0700
+++ b/src/zamikongine/vertex.nim	Sun Jan 15 23:23:54 2023 +0700
@@ -14,9 +14,9 @@
     Unknown, Position Color
   GenericAttribute*[T:VertexAttributeType] = object
     data*: seq[T]
-  PositionAttribute*[T:VertexAttributeType] = object
+  PositionAttribute*[T:Vec] = object
     data*: seq[T]
-  ColorAttribute*[T:VertexAttributeType] = object
+  ColorAttribute*[T:Vec] = object
     data*: seq[T]
   VertexAttribute* = GenericAttribute|PositionAttribute|ColorAttribute
 
@@ -85,6 +85,11 @@
       else:
         assert result == uint32(value.data.len)
 
+func VertexAttributesCount*[T](): uint32 =
+  for name, value in T().fieldPairs:
+    when typeof(value) is VertexAttribute:
+      result += 1
+
 func generateGLSLVertexDeclarations*[T](): string =
   var stmtList: seq[string]
   var i = 0