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 06-12-2011, 05:30 AM   #1 (permalink)
Registered Member
 
Join Date: Jun 2011
Posts: 1
RobinvD is on a distinguished road
Default NSArray to dynamic C-array

Hi all,

I'm working on a simple Obj-C Graphics Library but I'm stuck with a very annoying issue.

I've got the following two structs:

typedef struct _GLVector4 {
float x;
float y;
float z;
float w;
} GLVector4;

and

typedef struct _GLRawVertex {
GLVector4 position;
GLVector4 color;
} GLRawVertex;

I want to initialize an array of GLRawVertex's so I define:

GLRawVertex *rawVertexData;

Now when I want to store data, I've got two options:

GLRawVertex otherVertices[] = {
{{0,0,0,1},{0,1,0,1}},
{{1,0,0,1},{1,0,0,1}},
{{0,1,0,1},{0,0,1,1}}};

or

rawVertexData = new GLRawVertex[3];
int i = 0;
for (GLVertex *currentVertex in vertices){
rawVertexData[i].position = currentVertex.position;
rawVertexData[i].color = currentVertex.color;
i++;
}

where in the last part GLVertex is a simple Obj-C class with GLVector4 properties for position and color. Position and color contain the same values as in the static array declaration. When I NSLog them this is confirmed.

For some strange reason OpenGL draws fine with the first part, but when I initialize the array dynamically nothing is drawn on the screen.

Does somebody know where the second part fails? How can I create dynamic arrays in C? My source-code file is a .mm and the XCode file-type is Objective-C++.

Thanks for your help!
RobinvD 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: 477
16 members and 461 guests
7twenty7, AlanFloyd, AppsBlogger, David-T, HemiMG, iAppDeveloper, imac74, Jaxen66, lovoyl, Music Man, mutantskin, Paul Slocum, SLIC, solardrift, unicornleo, usernametaken
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,683
Threads: 94,131
Posts: 402,932
Top Poster: BrianSlick (7,990)
Welcome to our newest member, unicornleo
Powered by vBadvanced CMPS v3.1.0

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