Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


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


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
7 replies to this topic

#1 Conny14156   Members   -  Reputation: 270

Like
0Likes
Like

Posted 29 January 2013 - 10:19 AM

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  



Sponsor:

#2 rip-off   Moderators   -  Reputation: 8689

Like
1Likes
Like

Posted 29 January 2013 - 10:27 AM

What error message are you getting?



#3 Conny14156   Members   -  Reputation: 270

Like
0Likes
Like

Posted 29 January 2013 - 11:35 AM

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 ]



#4 Zaoshi Kaba   Crossbones+   -  Reputation: 4566

Like
1Likes
Like

Posted 29 January 2013 - 11:47 AM

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



#5 Daniel_RT   Members   -  Reputation: 478

Like
1Likes
Like

Posted 29 January 2013 - 01:47 PM

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?



#6 Conny14156   Members   -  Reputation: 270

Like
0Likes
Like

Posted 29 January 2013 - 04:13 PM

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 



#7 mhagain   Crossbones+   -  Reputation: 8275

Like
1Likes
Like

Posted 29 January 2013 - 05:16 PM

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


It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#8 Conny14156   Members   -  Reputation: 270

Like
0Likes
Like

Posted 29 January 2013 - 05:42 PM

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





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS