views:

89

answers:

0

Hello!

I am trying to use OpenGLES to draw a x by y matrix of squares about an arbitrary point.

I have an array sideVertice[] that holds a series of vertex structs defined as such

typedef struct {
    GLfloat x;
    GLfloat y;
    GLfloat z;
} Vertex3D;

and an element array defined as such

GLubyte elementArray[];

my draw loop is as such

        glLoadIdentity();
        glVertexPointer(3, GL_FLOAT, 0, cube.sideVertice);

        for (int i=0; i<((cube.cubeSize + 1)*(cube.cubeSize + 1)); i++) {
            for (int j=0; j<=3; j++) {
                elementArray[j] = j + i*4;
                glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_BYTE, elementArray);
            }
        }
        for (int i=0; i<=3; i++)
            elementArray[i] = i;

However, the visual output is corrupted and I cannot figure out what the problem is.

here is an output of the vertice held in the array:

2010-04-15 23:44:48.816 RubixGL[4203:20b] vertex[0][0] x:-26.000000 y:1.000000
2010-04-15 23:44:48.817 RubixGL[4203:20b] vertex[1][1] x:-26.000000 y:26.000000
2010-04-15 23:44:48.826 RubixGL[4203:20b] vertex[2][2] x:-1.000000 y:1.000000
2010-04-15 23:44:48.829 RubixGL[4203:20b] vertex[3][3] x:-1.000000 y:26.000000
2010-04-15 23:44:48.830 RubixGL[4203:20b] Next Face
2010-04-15 23:44:48.830 RubixGL[4203:20b] vertex[0][4] x:1.000000 y:1.000000
2010-04-15 23:44:48.832 RubixGL[4203:20b] vertex[1][5] x:1.000000 y:26.000000
2010-04-15 23:44:48.837 RubixGL[4203:20b] vertex[2][6] x:26.000000 y:1.000000
2010-04-15 23:44:48.838 RubixGL[4203:20b] vertex[3][7] x:26.000000 y:26.000000
2010-04-15 23:44:48.848 RubixGL[4203:20b] Next Face
2010-04-15 23:44:48.849 RubixGL[4203:20b] vertex[0][8] x:-26.000000 y:-26.000000
2010-04-15 23:44:48.850 RubixGL[4203:20b] vertex[1][9] x:-26.000000 y:-1.000000
2010-04-15 23:44:48.851 RubixGL[4203:20b] vertex[2][10] x:-1.000000 y:-26.000000
2010-04-15 23:44:48.852 RubixGL[4203:20b] vertex[3][11] x:-1.000000 y:-1.000000
2010-04-15 23:44:48.853 RubixGL[4203:20b] Next Face
2010-04-15 23:44:48.853 RubixGL[4203:20b] vertex[0][12] x:1.000000 y:-26.000000
2010-04-15 23:44:48.854 RubixGL[4203:20b] vertex[1][13] x:1.000000 y:-1.000000
2010-04-15 23:44:48.854 RubixGL[4203:20b] vertex[2][14] x:26.000000 y:-26.000000
2010-04-15 23:44:48.855 RubixGL[4203:20b] vertex[3][15] x:26.000000 y:-1.000000

any ideas?