Skip to main content
GameDev.net gamedev.net
🔒 Locked

C++ : arrays considerations

Started by penetrator Jun 27, 2005 at 3:53 PM 1 replies 750+ views
Original Post
penetrator
penetrator
I'm building a program that has to load several image files on different sizes and store values in an array. I was planning to have an array such as: float image_data[IMAGE_INDEX][IMAGE_X * IMAGE_Y]; Problem is that since any image will have a different size (i mean different numbers of x and y pixels), and IMAGE_X * IMAGE_Y must be a constant, i can only put an extremely high IMAGE_X * IMAGE_Y value and fill the array. In practice, if the image is 300x300 and IMAGE_X * IMAGE_Y is 1024x1024, i will have an array filled with values and with a long tail of 0's. To my knowledge there is no way to dinamically resize an array in C++ , so i'd like to know what possible "tricks" i might use. Thanks
DigitalDelusion
DigitalDelusion
Dynamic memory allocations maybe? Those flashy new/delete operators aren't just there because they look good ;) std::vector is another friendly and extremly flexible alternative.
HardDrop - hard link shell extension."Tread softly because you tread on my dreams" - Yeats
penetrator
penetrator
I found that something like this would do:


int cippa=1024;
int *buff = new int[cippa];
for (int i = 0; i < cippa; i++)
{
buff = 52;
}

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.