Hello, im new here and i am having a problem thats driving me absolutely insane. Long story short, im programming a simple game engine and i am writing a function to procedually generate a grid by creating a vertex and an index buffer.
(im using D3D11).
Where c is an int. Now the problem is, that i dont want to add an indice at certain locations which is why i am checking the indice's value (a). In this line: if(a==(4+c*5)), if i replace c with a constant value, such as 5 (by removing the variable c and just putting 5 in its place), then the indice with a value of 29 is left out. Now if i were to use that c to leave all of the unneeded ones out, it wont work at all and none of them are left out. It seems as if i cannot use a changing variable in an if statement? Thats absolutely ridicilous. When i dont increment the c (c++), it leaves one indice out like it should, but as soon as i try to increment it it just doesnt leave any of the indices out. This is driving me crazy.
The expression (4+c*5) grows five times faster than a does and is larger to begin with, so a will never equal to that expression (assuming c is less than or equal to 3 at the start)
If you're looking for all indices with a value of (4+c*5) to leave out where c is a value ranging from 0 to indiceCount, then instead you may want to consider checking if a, when reduced by four and divided by 5, has no remainder.
Thanks to the both of you. The mistake was so simple yet when looking at a piece of code for a long time, one can easily miss such a trivial mistake. Thanks again! I got it fixed.