Sign in to follow this  

[.net] sizeof(CustomVertex.TransformTextured) question

This topic is 3938 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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 :)

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
Thanks for the replies guys. Worked like a charm.

-AJ

Share this post


Link to post
Share on other sites
Sign in to follow this