Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualNightCreature83

Posted 15 January 2013 - 03:53 AM

D3DXCOLOR looks like this: http://msdn.microsoft.com/en-us/library/windows/desktop/bb172730%28v=vs.85%29.aspx

struct D3DXCOLOR
{
    float r,g,b,a;
}

Which means it's 16 bytes big so you have D3DXVector3 = 12 bytes + D3DXCOLOR = 16 + uint = 4 bytes * 2 = 36 bytes, which happens to be the same thing sizeof(SpriteVertex) will return. Your vertex declaration however tells D3D that the color value is only a DWORD big which is 4 bytes.
If you define your SpriteVertex as:

struct SpriteVertex
{
   D3DXVector3 position;
   DWORD color;//This is the same as D3DCOLOR
   unsigned int u, v;
}

This will match your vertex declaration and will make your sprite buffer work again, there are helper functions in D3DX that allow you to transform a 4 float value into a dword(http://msdn.microsoft.com/en-us/library/windows/desktop/bb172518%28v=vs.85%29.aspx).


#2NightCreature83

Posted 15 January 2013 - 03:51 AM

D3DXCOLOR looks like this: http://msdn.microsoft.com/en-us/library/windows/desktop/bb172730%28v=vs.85%29.aspx
struct D3DXCOLOR{    float r,g,b,a;}
Which means it's 16 bytes big so you have D3DXVector3 = 12 bytes + D3DXCOLOR = 16 + uint = 4 bytes * 2 = 36 bytes, which happens to be the same thing sizeof(SpriteVertex) will return. Your vertex declaration however tells D3D that the color value is only a DWORD big which is 4 bytes.
If you define your SpriteVertex as:
struct SpriteVertex{   D3DXVector3 position;   unsigned int color; //DWORD is typedefed as unsigned int on windows   unsigned int u, v;}
This will match your vertex declaration and will make your sprite buffer work again, there are helper functions in D3DX that allow you to transform a 4 float value into a dword(http://msdn.microsoft.com/en-us/library/windows/desktop/bb172518%28v=vs.85%29.aspx).

#1NightCreature83

Posted 15 January 2013 - 03:46 AM

D3DXCOLOR looks like this: http://msdn.microsoft.com/en-us/library/windows/desktop/bb172730%28v=vs.85%29.aspx

struct D3DXCOLOR
{
    float r,g,b,a;
}

Which means it's 16 bytes big so you have D3DXVector3 = 12 bytes + D3DXCOLOR = 16 + uint = 4 bytes * 2 = 36 bytes, which happens to be the same thing sizeof(SpriteVertex) will return. Your vertex declaration however tells D3D that the color value is only a DWORD big which is 4 bytes.

If you define your SpriteVertex as:

struct SpriteVertex
{
   D3DXVector3 position;
   unsigned int color; //DWORD is typedefed as unsigned int on windows
   unsigned int u, v;
}

This will match your vertex declaration and will make your sprite buffer work again, there are helper functions in D3DX that allow you to transform a 4 float value into a dword.


PARTNERS