Sign in to follow this  
u235

[.net] sizeof(CustomVertex.TransformTextured) question

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this