Sign in to follow this  

Direct3D don't draw my vertices

This topic is 1173 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

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

 

Share this post


Link to post
Share on other sites

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 :( 

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

This topic is 1173 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.

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