irix6
08-26-2003, 06:51 AM
Hi,
I have tried to see if there is any difference between using vertex array and traditional glBegin() glEnd().
Here is my code for two different methods:
void drawOld()
{
unsigned int *index = _indexArray;
int xp = 0, xoffset;
int sizeX2 = _sizeX*2;
int sizeY1 = _sizeY-1;
for(int y=0; y<sizeY1; y++)
{
glBegin(GL_TRIANGLE_STRIP);
for(int x=0; x<sizeX2; x++)
{
xoffset = _indexArray[xp]*3;
glNormal3fv(&_normalArray[xoffset]);
glColor3fv(&_colorArray[xoffset]);
glVertex3fv(&_vertexArray[xoffset]);
xp++;
}
glEnd();
}
}
and
void draw()
{
unsigned int *index = _indexArray;
int sizeX2 = _sizeX*2;
int sizeY1 = _sizeY-1;
glVertexPointer(3, GL_FLOAT, 0, _vertexArray);
glEnableClientState(GL_VERTEX_ARRAY);
glColorPointer(3, GL_FLOAT, 0, _colorArray);
glEnableClientState(GL_COLOR_ARRAY);
glNormalPointer(GL_FLOAT, 0, _normalArray);
glEnableClientState(GL_NORMAL_ARRAY);
for(int y=0; y<sizeY1; y++)
{
glDrawElements(GL_TRIANGLE_STRIP, sizeX2, GL_UNSIGNED_INT, index);
index += sizeX2;
}
}
I couldn't see any difference in the performance. They both got almost the same frame rate.
I can only access SGI machines, I have test them on O2 and Octane and the new UltimateVision system.
Thanks all for your input.
[This message has been edited by irix6 (edited 08-26-2003).]
I have tried to see if there is any difference between using vertex array and traditional glBegin() glEnd().
Here is my code for two different methods:
void drawOld()
{
unsigned int *index = _indexArray;
int xp = 0, xoffset;
int sizeX2 = _sizeX*2;
int sizeY1 = _sizeY-1;
for(int y=0; y<sizeY1; y++)
{
glBegin(GL_TRIANGLE_STRIP);
for(int x=0; x<sizeX2; x++)
{
xoffset = _indexArray[xp]*3;
glNormal3fv(&_normalArray[xoffset]);
glColor3fv(&_colorArray[xoffset]);
glVertex3fv(&_vertexArray[xoffset]);
xp++;
}
glEnd();
}
}
and
void draw()
{
unsigned int *index = _indexArray;
int sizeX2 = _sizeX*2;
int sizeY1 = _sizeY-1;
glVertexPointer(3, GL_FLOAT, 0, _vertexArray);
glEnableClientState(GL_VERTEX_ARRAY);
glColorPointer(3, GL_FLOAT, 0, _colorArray);
glEnableClientState(GL_COLOR_ARRAY);
glNormalPointer(GL_FLOAT, 0, _normalArray);
glEnableClientState(GL_NORMAL_ARRAY);
for(int y=0; y<sizeY1; y++)
{
glDrawElements(GL_TRIANGLE_STRIP, sizeX2, GL_UNSIGNED_INT, index);
index += sizeX2;
}
}
I couldn't see any difference in the performance. They both got almost the same frame rate.
I can only access SGI machines, I have test them on O2 and Octane and the new UltimateVision system.
Thanks all for your input.
[This message has been edited by irix6 (edited 08-26-2003).]