저는 XNA와 함께 작동하는 라이브러리를 작성하고 있습니다. 저는 프리미티브를위한 기본 클래스를 가지고 있습니다.이 클래스로부터 Planes, Cubes 및 기타 원시 타입을 작성할 계획입니다. 이상적으로 사용 된 정점 유형에 관계없이 내 기본 클래스에서 렌더링을 수행하고 싶습니다.일반 기본 클래스에서 DrawUserIndexedPrimitives <> 사용
관련 코드 : 이제
public abstract class Primitive<VT> where VT : IVertexType
{
private void Draw(GraphicsDevice graphics)
{
graphics.DrawUserIndexedPrimitives<VT>(primitiveType_,
vertices_,
0,
vertices_.Length,
indices_,
0,
primitiveCount_);
}
}
, 적절한 정점 타입의 사용이에서 파생 이외의 클래스 : 문제는
public abstract class Plane<VT> : Primitive<VT> where VT : IVertextTpye { ... }
public class PlaneColored : Primitive<VertexPositionColor> { .... }
public class PlaneTextured : Primitive<VertexPositionTexture> { .... }
, 내가 DrawUserIndexPrimitives <에 컴파일 오류를 > 전화 :
Error 1 The type 'VT' must be a non-nullable value type in order to use it as parameter 'T' in the generic type or method 'Microsoft.Xna.Framework.Graphics.GraphicsDevice.DrawUserIndexedPrimitives<T>(Microsoft.Xna.Framework.Graphics.PrimitiveType, T[], int, int, short[], int, int)' C:\dev\Projects\2010\XNAParts\XNAParts\Parts\Primitive.cs 88
그리고 구성을 struct
그렇지 않으면 DrawUserIndexPrimitives의 제네릭 매개 변수가 작동하지 않습니다 (구조체가 아니므로).
이 문제가 발생합니까?
미리 감사드립니다.
좋은 질문이지만 제목에 null 제약 조건이있는 실제 문제가 설명되어 있지 않습니다. –