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

Started by
6 comments, last by Conny14156 11 years, 2 months ago

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

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

Advertisement

What error message are you getting?

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 ]

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

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?

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

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).

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

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
                                    );
    }

This topic is closed to new replies.

Advertisement