[.net] sizeof(CustomVertex.TransformTextured) question

Started by
2 comments, last by u235 17 years ago
I'm writing a little 2D game, a re-make of a game I wrote way back when I first started programming, using MDX. When writing a routine to make a vertex buffer for my textured quads, I run into a little problem. I use CustomVertex.TranformTextured vertices but when I create the buffer, the second argument returns this error: 'Microsoft.DirectX.Direct3D.CustomVertex.TransformedTextured' does not have a predefined size, therefore sizeof can only be used in an unsafe context (consider using System.Runtime.InteropServices.Marshal.SizeOf) I've never run into this problem with any other vertex type so I wondering if anyone knew what is going on? I appreciate any light that can be shed on this. Thanks. -AJ
V/R,-AJThere are 10 kinds of people in the world: Those who understand binary and those who don't...
Advertisement
I'm not sure why .NET thinks CustomVertex.TransformedTextured doesn't have a fixed size, but I've run into this problem as well. If you want to use sizeof(), the easiest way to get around this is to check the 'allow unsafe code' on your project's property sheet (I believe it's on the build tab). As an alternative you can use the static StrideSize property, which should be available for all CustomVertex.WhatEver structs.

Hope this helps :)
Rim van Wersch [ MDXInfo ] [ XNAInfo ] [ YouTube ] - Do yourself a favor and bookmark this excellent free online D3D/shader book!
Microsoft.DirectX.Direct3D.CustomVertex.TransformedTextured.StrideSize

DO NOT USE UNSAFE CODE UNLESS YOU ABSOLUTELY NEED IT. And if you think you need it, you almost certainly don't.

[wink][wink][wink][wink][wink]
Thanks for the replies guys. Worked like a charm.

-AJ
V/R,-AJThere are 10 kinds of people in the world: Those who understand binary and those who don't...

This topic is closed to new replies.

Advertisement