Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1045639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:00:57+00:00 2026-05-16T16:00:57+00:00

I am porting an Android app I made to iPhone and running into problems

  • 0

I am porting an Android app I made to iPhone and running into problems with the syntax (I think)

I’m basing the project off of the example from
http://iphonedevelopment.blogspot.com/2009/04/opengl-es-from-ground-up-part-2-look-at.html

I would like to pull out the geometry from the rendering process to keep the code modular but I can’t seem to get it to work. I’ve created a class called Icosahedron (comments are my understanding of what’s going on)
Icosahedron.h

#import <Foundation/Foundation.h>
#import "OpenGLCommon.h"



@interface Icosahedron : NSObject {
 Vertex3D *vertices[12]; //allocate a group of 12 Vertex3D pointers
 Vertex3D *normals[12]; // ditto
 GLubyte *faces[60]; // ditto but with 60 face values
}

// Declare methods
-(Vertex3D *) vertices; 
-(void) setVertices:(Vector3D *)setVerts; 

-(Vertex3D *) normals;
-(void) setNormals:(Vector3D *)setNorms;

-(GLubyte *) faces;
-(void) setFaces:(GLubyte *)setFaces;

@end

Icosahedron.m

#import "Icosahedron.h"


@implementation Icosahedron

// Returns the pointer to the vertices instance variable
-(Vector3D *) vertices{
 return *vertices;
}

-(void) setVertices:(Vector3D *)setVerts
{
 //vertices=setVerts[0];
}

-(Vector3D *) normals{
 return *normals;
}

-(void) setNormals:(Vector3D *)setNorms
{
 //normals=setNorms;
}

-(GLubyte *) faces{
 return *faces;
}

-(void) setFaces:(GLubyte *)setFaces
{
 //faces=setFaces;
}
/**/
-(id)init
{
 // super method
 self=[super init];

    // create 12 Vector3D objects and populate them...
 Vector3D tempVert[12]={
        {0, -0.525731, 0.850651},             // vertices[0]
        {0.850651, 0, 0.525731},              // vertices[1]
        {0.850651, 0, -0.525731},             // vertices[2]
        {-0.850651, 0, -0.525731},            // vertices[3]
        {-0.850651, 0, 0.525731},             // vertices[4]
        {-0.525731, 0.850651, 0},             // vertices[5]
        {0.525731, 0.850651, 0},              // vertices[6]
        {0.525731, -0.850651, 0},             // vertices[7]
        {-0.525731, -0.850651, 0},            // vertices[8]
        {0, -0.525731, -0.850651},            // vertices[9]
        {0, 0.525731, -0.850651},             // vertices[10]
        {0, 0.525731, 0.850651}               // vertices[11]
    };
    // same...
 Vector3D tempNorm[12]={
        {0.000000, -0.417775, 0.675974},
        {0.675973, 0.000000, 0.417775},
        {0.675973, -0.000000, -0.417775},
        {-0.675973, 0.000000, -0.417775},
        {-0.675973, -0.000000, 0.417775},
        {-0.417775, 0.675974, 0.000000},
        {0.417775, 0.675973, -0.000000},
        {0.417775, -0.675974, 0.000000},
        {-0.417775, -0.675974, 0.000000},
        {0.000000, -0.417775, -0.675973},
        {0.000000, 0.417775, -0.675974},
        {0.000000, 0.417775, 0.675973},
    };


 // face values
 GLubyte tempFaces[60]={
        1, 2, 6,
        1, 7, 2,
        3, 4, 5,
        4, 3, 8,
        6, 5, 11,
        5, 6, 10,
        9, 10, 2,
        10, 9, 3,
        7, 8, 9,
        8, 7, 0,
        11, 0, 1,
        0, 11, 4,
        6, 2, 10,
        1, 6, 11,
        3, 5, 10,
        5, 4, 11,
        2, 7, 9,
        7, 1, 0,
        3, 9, 8,
        4, 8, 0,
    };

   // set the instance pointers to the temp values
 *vertices=tempVert;
 *normals=tempNorm;
 *faces=tempFaces;

at this point the values are NOT properly populated, only the first value is correct.

 return self;

}

@end

All I want to do is to be able to call something like

...
ico=[[Icosahedron alloc] init];
glVertexPointer(3, GL_FLOAT, 0, [ico vertices]);
...

in the rendering section but it the farthest I’ve been able to get is setting the first value of the Vertex3Ds inside the Icosahedron class and I get ‘out of scope’ in the debugger for any of the Icosahedron’s values in the rendering class.

I suspect that this is just me learning Objective-C’s quirks but I’ve tried many different approaches for a few days and nothing seems to get me anywhere.

Please help me Overflow-Wan, you’re my only hope.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T16:00:58+00:00Added an answer on May 16, 2026 at 4:00 pm

    You’re getting your pointers and arrays mixed up. You’d want something like this:

    Vertex3D vertices[12];
    
    - (void) setVertices: (Vertex3D *)newVertices;
    {
        memcpy( vertices, newVertices, 12 * sizeof( Vertex3D ) );
    }
    
    - (Vertex3D *) vertices;
    {
        return vertices;
    }
    

    To copy arrays in C you have to use memcpy (or a hand-written loop), you cannot do this with the assignment operator.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm porting a web-app from iPhone to Android. Unexpectedly, buttons work as usual, except
I'm porting an OpenGL app from the iPhone to Android, and I need to
I am porting an app from Android Java to iPhone. In Android I used
I am porting an app from iPhone to Android and I was wondering what
I'm doing porting app from Iphone to Android related to RGB colors. Is there
I am currently porting an application from iOS into Android and I have ran
An Android/Iphone app will be accessing application data from the server. [Django-Python] How can
I'm porting an app from iOS to Android. In the iOS app, there is
I'm porting an Android app I made to iOS. Android has a Yield() function
I made a little example for posting messages to facebook feed via Android app.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.