Quote:Original post by Julian90
**Points out my retarded typo**
Thanks, I completely missed that when i reread the post before hitting 'reply'. Good eye, but afraid you caught the wrong typo. Arrays of this type are aligned with the rows placed end-to-end.
Thanks for keeping me on my toes.
But in all honesty, while your method works great for traversing an image that is stored a certain way, most images are stored with the Y-value being the row index, and the X-value being the column index, so to retain cache coherency, you would use (x + (y * width)) instead of (y + (x * height)). I did goof up when i was specifying the original 2d version. Using the Y axis as the column will have the picture stored side-ways.
There isn't a 'right answer' here though. Really, it doesn't matter that much [so long as you twist the image right-way-up previous to making a texture out of it, and textures use x for column-index, and y for the row-index]. Just make sure when you're iterating over it, the inner loop is the added part, and the outer loop is the multiplied part [thus retaining the cache]. So it'll be (inner_loop_index + (outer_loop_index * pitch)) where pitch is the column count [also known as the size of the width]
Either way, thanks Julian90 for keeping me re-reading my posts for accuracy. Don't want to get sloppy.
Whatever axis is major doesn't matter, so long as it's consistent, and I wasn't consistent. Thanks for not letting my carelessness taint others.