//VERTEX
struct SpriteVertex
{
D3DXVECTOR3 vPos;
D3DXCOLOR Colour;
uINT u1, v1;
};
//VERTEX DECLARATION
D3DVERTEXELEMENT9 Sprite_Decl[] =
{
{0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
{0, 12, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0},
{0, 24, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0},
D3DDECL_END() // this macro is needed as the last item!
};
Look at what you did (aside from the color and alignment problems that should already be fixed).
Your structure has integers for the UV coordinates but you told Direct3D that you have 2 floats. UV coordinates are typically floating-point values often between 0.0f and 1.0f. Fix your structure and any logic you were using to put values into those.
Now look back at your screen shots.
Firstly, the index buffer is
not correct on the second draw. A triangle is 3 unique points. Your index buffer specifies only 2 unique points for every triangle, meaning every triangle is degenerate no matter what position values they had.
Secondly, look at the ranges of the indices.
You are using the same vertex buffer for both calls.
Fine.
Look at the index buffer. The vertex buffer elements 95-99 are valid. The vertex buffer elements 0-?? are not.
It is fairly clear you did not initialize the
whole vertex buffer. You handled some of the vertices but not the rest.
I've fixed the declaration like you said but I still can't see anything. But I am getting crazy values for my vertices
If you have ever used a debugger before you would easily recognize the pattern of bytes there. 0xDD and 0xCD are what the debugger fills over memory in certain cases.
If you see 0xCD, it means something was not initialized.
If you see 0xDD, it means the memory was freed/deleted.
The problem is obvious. You have deleted that memory.
the pre-VS had good values but the post VS-Doesn't
Are you talking about the values in that screenshot? If so, I can guarantee the PreVS values are
not good.
Still getting the same problem where I don't know why Draw indexed prim is being called twice
Again, have you ever used a debugger? Do you know what “breakpoints” are?
I am not going to spoon-feed you this. You need to learn a few very very fundamental and basic debugging skills in order to help yourself.
The most basic debugging skills would have solved the problem I mentioned first in this post as well. The screenshots made it obvious what the problem was, and a few breakpoints, some single-stepping, and 10 minutes of code-checking would have exposed the underlying issue.
I am not going to spoon-feed you this.
Google keywords: “Microsoft Visual Studio Debugger”, “Breakpoints”, “Single-Stepping”, and any combination of these.
L. Spiro