Relative Content

Tag Archive for swiftmetalvertices

How describe tightly packed vertices data in Apple Metal?

I’m transferring my program from opengl to metal. In the original I use tightly packed vertex data, which there are no problems with describing in opengle, but in metal it doesn’t work.
Tightly packed data in my opinion is: [x,y,z, ... x,y,z, nx,ny,nz, ... nx,ny,nz, r,g,b, ... r,g,b], normal packed data is [x,y,z,nx,ny,nz,r,g,b ... x,y,z,nx,ny,nz,r,g,b], where x,y,z – coordinates, nx,ny,nz – normals and r,g,b – colors.
In opengl I set stride to zero (or step in bytes between vertices within the same data type) and offset for the beginning of each data. But here I get an error.
Code