Re: static typing (Learning Cocoa Chapter 13)
Re: static typing (Learning Cocoa Chapter 13)
- Subject: Re: static typing (Learning Cocoa Chapter 13)
- From: Jeff Binder <email@hidden>
- Date: Sat, 22 Sep 2001 21:43:11 -0400
For example, to store 3D terrain, I use
float **heightMap;
I then initialize it like this:
heightMap = (float **)malloc(size * sizeof(float *));
for (index = 0; index < size; index++)
{
heightMap[index] = (float *)malloc(size * sizeof(float));
}
I can then access it just like a two dimensional array:
heightMap[x][y]
Which is easier and clearer that using a simple pointer, which would be
heightMap[x + (y * size)]
I use this for the terrain, and in the 3D data file parser, both of
which produce arrays ready to submit to OpenGL.
Jeff Binder
On Saturday, September 22, 2001, at 03:54 AM, Girard Iglesias wrote:
Le samedi 22 septembre 2001, ` 02:48 , Jeff Binder a icrit :
Actually, I use handles in my Cocoa program as a resizable,
multidimentional array for storing vertices. It's more convenient than
using pointer arithmetic.
Can you be more explicit?
Gerard
_______________________________________________
cocoa-dev mailing list
email@hidden
http://www.lists.apple.com/mailman/listinfo/cocoa-dev