private void LoadShaders() { var vShader = BuiltinShaderRepository.GetBuiltinShader(typeof(VertexPositionColorTexture), ShaderStages.Vertex); vertexShader = vShader.CreateDeviceShader(device); var fShader = BuiltinShaderRepository.GetBuiltinShader(typeof(VertexPositionColorTexture), ShaderStages.Fragment); fragmentShader = fShader.CreateDeviceShader(device); }
public VertexArray(GraphicsDevice device, int capacity, PrimitiveTopology geometryType = PrimitiveTopology.PointList) { this.device = device; factory = device.ResourceFactory; this.geometryType = geometryType; this.capacity = (uint)capacity; var vShader = BuiltinShaderRepository.GetBuiltinShader(typeof(T), ShaderStages.Vertex); var fShader = BuiltinShaderRepository.GetBuiltinShader(typeof(T), ShaderStages.Fragment); if (vShader == null || fShader == null) { throw new NotSupportedException("Not a supported vertex type"); } Shaders = new List <Shader> { vShader, fShader }; uint vertexSize = PrimitivesInfo.GetSize(typeof(T)); if (vertexSize == 0) { throw new NotSupportedException("Not a supported vertex type"); } var vld = PrimitivesInfo.GetVertexLayoutDescription(typeof(T)); if (!vld.HasValue) { throw new NotSupportedException("Not a supported vertex type"); } var resourceLayoutDescription = GetResourceLayoutDescription(typeof(T)); CreateResources(vertexSize, resourceLayoutDescription, vld.Value); }