Rendering using VBOs and IBOs in OpenGLES glBufferData() function
===

I am using Vertex Buffer Objects and Index Buffer Objects to render the template geometry provided by xcode. I am able to render everything fine. Now I made my custom class which populates my vertex and index arrays but I am not able to render the same geometry. The problem is with the **glBufferData()** method. It takes 4 arguments and the third one points to the data(for vertex information or indices information) which is creating the problem. Here is my class declaration

    @interface MyGeometry : NSObject {

    @private
    
    float _startAngle;  
    float _endAngle;    
    float _radius;
    float _thickness;
    int _ns;
    int _nt;
    
    GLfloat *vertexArray; 
    GLushort *indexArray;    

    }
    -(GLfloat*) returnVertexArray;//returns vertex array
    -(GLushort*) returnIndexArray;//returns index array

I populate my vertex array and index array(indice array is not provided in the template,I provided myself {1,2,..36}) exactly as provided in the template. Also I NSLog the values to check everything is same but **my vertexarray and indexarray data pointers do not work**. Now in the controller class in the setupGL() method I do.

    #define BUFFER_OFFSET(i) ((char *)NULL + (i))
    gCubeVertexData[216] ={.....}
    indices[36] = {0,1,2....35}

    //initialize my class object and populate vertex and index arrays exactly as gCubeVertexData and indices
    myClassObject = [[MyGeometry alloc] initWithGeometryandPopulateVertexAndIndexArrays];

    
    glGenBuffers(1, &vertexBuffer);
    glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
    //here instead of gCubeVertexData as the third argument [myClassObject returnVertexArray] does not work.
    glBufferData(GL_ARRAY_BUFFER, 36*6*sizeof(GLfloat), gCubeVertexData , GL_STATIC_DRAW);
    
    glGenBuffers(1, &indexBuffer);
    //here instead of indices as the third argument [myClassObject returnIndexArray] does not work.
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer);
    glBufferData(GL_ELEMENT_ARRAY_BUFFER, 36*sizeof(GLushort),indices, GL_STATIC_DRAW);
    

    glEnableVertexAttribArray(GLKVertexAttribPosition);
    glVertexAttribPointer(GLKVertexAttribPosition, 3, GL_FLOAT, GL_FALSE, 6*sizeof(GLfloat), BUFFER_OFFSET(0));
    glEnableVertexAttribArray(GLKVertexAttribNormal);
    glVertexAttribPointer(GLKVertexAttribNormal, 3, GL_FLOAT, GL_FALSE, 6*sizeof(GLfloat), BUFFER_OFFSET(12));
    
    glBindVertexArrayOES(0);

    //for rendering using glDrawElements
    glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer);
    
    glDrawElements(GL_TRIANGLES, sizeof(indices)/sizeof(GLushort), GL_UNSIGNED_SHORT, (void*)0);


Here is the documentation of the function.
http://www.khronos.org/opengles/sdk/docs/man/xhtml/glBufferData.xml

Where am I going wrong ?

