Direct3D don't draw my vertices

Started by
8 comments, last by Stragen 9 years, 6 months ago

Hi everyone!

I've been following the DirectXSDK tutorial for a while and tried to build my own vertex structure.

First I made some change to the SimpleVertex structure from SDK tutorial 3

it looked like this and worked well

struct SimpleVertex
{
XMFLOAT3 Pos;
};
but after i add some constructors , the triangle disappeared X(
struct SimpleVertex
{
public:
SimpleVertex(){};
SimpleVertex(XMFLOAT3){};
~SimpleVertex(){};
XMFLOAT3 Pos;
};
I've change the stride and size several times but nothing seemed to work
Does anyone know what the problem is ?
Any suggestions would be appreciated

Advertisement

Is this pseudo code or your real struct?

If you add some virtual functions or destructors this will cause the struct to have a different size.

What does sizeof( SimpleVertex ) return?

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

Is this pseudo code or your real struct?

If you add some virtual functions or destructors this will cause the struct to have a different size.

What does sizeof( SimpleVertex ) return?

12

I have worked that out. I think it's the inline function that makes the address changed when I use it.

By the way , I use std::vector to store the vertices and that did't work again :(

What code are you using to create a variable from the simplevertex?

I would expect somewhere you're doing SimpleVertex someVertex; someVertex.pos = XMFLOAT3()....

What code are you using to create a variable from the simplevertex?

I would expect somewhere you're doing SimpleVertex someVertex; someVertex.pos = XMFLOAT3()....

just like sdk tutorial did.

Use the debugger to check the contents of the array your passing to D3D (e.g. put a breakpoint just after you assign stuff so you can look at the contents). I don't know what IDE your using, but you should be able to find an introductory tutorial for it.

Also that "SimpleVertex(XMFLOAT3)" as shown is wrong, your not actually assigning the value.

What SyncViews says... i dont think you're assigning anything within the constructor...

I would have expected that you would have had

SimpleVertex(XMFLOAT3 _var){pos = _var; }

and then creating a variable of type SimpleVertex using:

SimpleVertex newVertex(XMFLOAT3(x,y,z)) or what ever else you use.

or:

SimpleVertex newVertex;

newVertex.pos = _var;

saying exactly what the tutorial says doesn't help a great deal, i don't have the particular tutorial that you're referring to... and i've seen many.

Use the debugger to check the contents of the array your passing to D3D (e.g. put a breakpoint just after you assign stuff so you can look at the contents). I don't know what IDE your using, but you should be able to find an introductory tutorial for it.

Also that "SimpleVertex(XMFLOAT3)" as shown is wrong, your not actually assigning the value.

i just fill the struct without the constructor so i dont think that there will be any problem

Well still use the debugger to validate the memory contents your passing to D3D, and that it matches up with other values (total size, stride, vertex count, etc.). If adding a constructor broke it, then the array contents is pretty likely to be the source.

still, would be a whole lot easier if we can see the code that you've got down to see where you've declared and used the variable...

This topic is closed to new replies.

Advertisement