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

This topic is 1813 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 on other sites

What error message are you getting?

##### Share on other sites

Less than a error but more of a warning >.<

D3D11: WARNING: ID3D11DeviceContext::DrawIndexed: Index buffer has not enough space! [ EXECUTION WARNING #359: DEVICE_DRAW_INDEX_BUFFER_TOO_SMALL ]

##### Share on other sites

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

##### 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 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 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 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 on other sites

This topic is 1813 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.