Simple Directmedia Layer
at main 38 lines 633 B view raw
1#include <metal_stdlib> 2using namespace metal; 3 4struct VSOutput 5{ 6 float4 color [[user(locn0)]]; 7 float4 position [[position]]; 8}; 9 10#ifdef VERTEX 11 12struct UBO 13{ 14 float4x4 modelViewProj; 15}; 16 17struct VSInput 18{ 19 float3 position [[attribute(0)]]; 20 float3 color [[attribute(1)]]; 21}; 22 23vertex VSOutput vs_main(VSInput input [[stage_in]], constant UBO& ubo [[buffer(0)]]) 24{ 25 VSOutput output; 26 output.color = float4(input.color, 1.0); 27 output.position = ubo.modelViewProj * float4(input.position, 1.0); 28 return output; 29} 30 31#else 32 33fragment float4 fs_main(VSOutput input [[stage_in]]) 34{ 35 return input.color; 36} 37 38#endif