Sign in to follow this  
Conny14156

Pointer array sizeof question?[Problem Found](Embarrassing problem)

Recommended Posts

Hi, I am trying to send the sizeof a array into the D3D11_BUFFER_DESC.ByteWidth By doing it like this [

 

code=:0]//Some other code

DWORD* indcies_D;indcies_D = new DWORD[Model.Total.Face * 3];

D3D11_BUFFER_DESC indexBufferDesc;ZeroMemory( &indexBufferDesc, sizeof(indexBufferDesc) );

indexBufferDesc.Usage = D3D11_USAGE_DEFAULT;

indexBufferDesc.ByteWidth = sizeof(DWORD) * Model.Total.Face * 3; //<---- This would be complained by the compiler for some reason but not if its * 4

indexBufferDesc.BindFlags = D3D11_BIND_INDEX_BUFFER;

indexBufferDesc.CPUAccessFlags = 0;indexBufferDesc.MiscFlags = 0;

//some more code[/code]

 

am guessing my pointer takes up some extra memory? if so how would I get the size of a pointer o.o?

 

Problem:

was drawing 3 times as much, than what the buffer was created for  

Share this post


Link to post
Share on other sites

Hmm that's weird, only thing different from yours to mine is WORD and that is 2 bytes less than DWORD...

 

unsigned int numIndices = Model.Total.Face* 3
indexBufferDesc.ByteWidth = numIndices * sizeof(WORD);

 

Maybe the number of faces is wrong?

Share this post


Link to post
Share on other sites

This error means you're trying to draw more triangles than you actually defined in your index buffer.


Yeha I thougth so, i want to know why I get it cause the face*3 is suppose to be the total indices and I just double checked my total vertex I am suppose to draw and it is indeed the same

Hmm that's weird, only thing different from yours to mine is WORD and that is 2 bytes less than DWORD...

unsigned int numIndices = Model.Total.Face* 3indexBufferDesc.ByteWidth = numIndices * sizeof(WORD);


Maybe the number of faces is wrong?

The faces does not get change or suppose to change between the two code, they just a few line apart from each other >.<

 

Seems like using *4 does not work now >.<, Keep complainning about memory heap. I was probably lucky the last time I got it to work before I changed computer 

Share this post


Link to post
Share on other sites

This error is being caused by bad parameters to your DrawIndexed call, not by your index buffer creation, so have a look at those, in particular your IndexCount and StartIndexLocation parameters - add them together and you'll find that you're overflowing the size of your index buffer (which is Model.Total.Face * 3).

Share this post


Link to post
Share on other sites

[URL=http://imgur.com/4Zmc24Q][/URL]

Here a screen on the

IndexCount(Its suppose to hold how many index/indices its suppose to draw for that group)

StartIndex(and this one suppose to hold how far off its suppose to draw )

And I get the same amount by 

multiplying Face*3 which in this case is 

348, which is also the total of all the index count and the startindex seems to be all right.

 

Edit:

FORGET everything

>.< dammit this is VERY Embarrassing.

 

Thanks for pointing out the draw index, for some stupid reason I also had *3 when I was drawing my object so it was atleast 3 times as much, no wonder my buffer complained.

Really sorry for wasting all of your guys time and such a stupid misstake

 

    for(int i = 0; i < Model.Total.Group; i++)
    {
        Gfx->D3d11DevCon->DrawIndexed
                                    (
                                        Model.DrawingIndexIndices.IndexCount[i]*3,//<---- This was the problem >.<
                                        Model.DrawingIndexIndices.StartIndex[i],
                                        0
                                    );
    }

Share this post


Link to post
Share on other sites

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