-
-
Save ReneSac/56fa1fa99d1551d3ca96 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import opengl, glfw/glfw | |
| type | |
| TCoord = enum | |
| x, y, z | |
| TVertex = object | |
| pos: array[TCoord, GLfloat] | |
| normal: array[TCoord, GLfloat] | |
| var | |
| vertices: array[NumVertices, TVertex] | |
| converter toGlVec(a: Array[3, int]) : array[TCoord, GLfloat] = | |
| return [a[x.ord].GlFloat, a[y.ord].GlFloat, a[z.ord].GlFloat] | |
| # Call: | |
| newVertexGroup([0, 0, 1] , [-1, -1, 1] , [1, -1, 1] , [1, 1, 1] , [-1, 1, 1] ) | |
| #Works: | |
| proc newVertexGroup(normal: Array[3, int], pos: varargs[Array[3, int]]) = | |
| var curVertex {.global.} = 0 | |
| for p in pos: | |
| vertices[curVertex] = TVertex(pos: p, normal: normal) | |
| curVertex.inc | |
| #Fails: | |
| proc newVertexGroup(normal: array[TCoord, GLfloat], pos: varargs[array[TCoord, GLfloat]]) = | |
| var curVertex {.global.} = 0 | |
| for p in pos: | |
| vertices[curVertex] = TVertex(pos: p, normal: normal) | |
| curVertex.inc | |
| # Error: type mismatch: got (Array constructor[0..2, int], Array constructor[0..2, int], Array constructor[0..2, int], Array constructor[0..2, int], Array constructor[0..2, int]) | |
| #but expected one of: | |
| #N.newVertexGroup(normal: array[TCoord, GLfloat], pos: varargs[array[TCoord, GLfloat]]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment