Jump to content
  • Advertisement
Sign in to follow this  
u235

[.net] sizeof(CustomVertex.TransformTextured) question

This topic is 4212 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
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 :)

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!