This file contains 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
// I'm rendering a subdivided quad of resolution x resolution vertices | |
let vertex = Vertex(position: position, normal: float3(0,0,0), texture: float2(0,0)) | |
vertices.append(vertex) | |
// vertices are stored in a vertices array, same for indices | |
// for every vertex but the last row and column we want to create two triangles | |
if x != resolution-1 && y != resolution-1 { | |
self.indices.append(contentsOf: [ | |
UInt16(i), UInt16(i + resolution), UInt16(i + resolution + 1), // triangle 1 | |
UInt16(i), UInt16(i + resolution + 1), UInt16(i + 1) // triangle 2 |