• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: static typing (Learning Cocoa Chapter 13)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: static typing (Learning Cocoa Chapter 13)
      • From: "Erik M. Buck" <email@hidden>
References: 
 >Re: static typing (Learning Cocoa Chapter 13) (From: Gérard Iglesias <email@hidden>)

  • Prev by Date: NSImageView and Copy and Paste?
  • Next by Date: NSImage lockFocus
  • Previous by thread: Re: static typing (Learning Cocoa Chapter 13)
  • Next by thread: Re: static typing (Learning Cocoa Chapter 13)
  • Index(es):
    • Date
    • Thread