Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > Mac OS X Development Forums > Objective-C, Python, Ruby Development

Reply
 
LinkBack Thread Tools Display Modes
Old 07-17-2009, 10:50 AM   #1 (permalink)
New Member
 
Join Date: Jul 2009
Posts: 6
Durnus is on a distinguished road
Question Pointers to C data types in Objective-C?

I'm using openGL ES in my iphone project, and want to use glVertexPointer, which requires an array of some number type that will be vertices. I need to declare this array dynamically because it can vary in size (I assume based on C/C++ experience) and came up with this:
Code:
...
GLfloat* lines;
lines = new GLfloat[ [touchArray count]*2 ]
//touchArray is just a NSMutableArray, nothing weird there.
...
But objective-C doesn't like it when I say "new" . GLfloat is just a typedef of float, so it isn't an object... and I'm completely lost when it comes to this. I previously wrapped a struct into an NSObject subclass just so I didn't have to ask this question, but I think it's time to get past this stumble.

How do I allocate memory to these simple data types? Or otherwise how do I make that pointer to a struct or pointer to an array?
Durnus is offline   Reply With Quote
Old 07-17-2009, 11:29 PM   #2 (permalink)
New Member
 
Join Date: Jul 2009
Posts: 6
Durnus is on a distinguished road
Default

Haha, fixed it. I was mixing my C and C++, new is a C++ allocator. I could have either changed the file extension to .mm to do C++ stuff, or use malloc() and free() as C code. Anyone else wondering about this (pretty basic) stuff can visit here for more about this.
Durnus is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 458
16 members and 442 guests
Domele, Duncan C, Feldspar, karatebasker, MacBook MH, Objective Zero, patapple, Paul Slocum, peterwilli, pipposanta, PixelInteractive, Punkjumper, rubyeim54, SLIC, taylor202, Today's Posts
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,694
Threads: 94,137
Posts: 402,950
Top Poster: BrianSlick (7,990)
Welcome to our newest member, peterwilli
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:02 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0