# Something about the performance using OpenglES 1.x

**URL:** <https://forums.imgtec.com/t/something-about-the-performance-using-opengles-1-x/884>\
**Category:** PowerVR Insider\
**Created:** [October 29, 2010, 8:27am UTC](https://forums.imgtec.com/t/something-about-the-performance-using-opengles-1-x/884 "2010-10-29T08:27:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jason-2](https://avatars.discourse-cdn.com/v4/letter/j/bb73d2/32.png) [@jason-2](https://forums.imgtec.com/u/jason-2)\
**Post date:** [October 29, 2010, 8:27am UTC](https://forums.imgtec.com/t/something-about-the-performance-using-opengles-1-x/884/1 "2010-10-29T08:27:34Z")

</div>

Hi,everyone.I am a learner&nbsp; as to Opengl ES.Now I am doing some test about the performace on a PND with POWERVR MBX ,using Wince OS.I am quite puzzled about the&nbsp; result.

codes like this:
  

1ã€rend 1000 triangles using **glDrawElements** and glColor4f
  

  

void Render()  
{  
&nbsp;&nbsp;&nbsp;&nbsp; long time = 0;  
&nbsp;&nbsp;&nbsp;&nbsp; int i;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp; GLshort vertexArray[500] = {-25,-25,0,&nbsp;&nbsp; 25,-25,0,&nbsp;&nbsp; 0,25,0 };  
&nbsp;&nbsp;&nbsp; GLubyte colorArray[12] = {255,0,0,0,&nbsp;&nbsp; 0,255,0,0,&nbsp;&nbsp;&nbsp; 0,0,255,0};
  

**&nbsp;&nbsp;&nbsp; GLubyte vertexIdx[3000];  
&nbsp; for (i = 0; i \< 1000; i ++)  
&nbsp; {**
  

**&nbsp;vertexIdx[i\*3 + 0] = 0;  
&nbsp;vertexIdx[i\*3 + 1] = 1;  
&nbsp;vertexIdx[i\*3 + 2] = 2;  
&nbsp; }**  
&nbsp; glClear(GL\_COLOR\_BUFFER\_BIT | GL\_DEPTH\_BUFFER\_BIT);&nbsp;   
&nbsp; glLoadIdentity();&nbsp; 
  

&nbsp; glTranslatex(0, 0, FixedFromInt(-10));  
time = GetTickCount();
  

&nbsp; //Enable the vertices array&nbsp;   
&nbsp; glEnableClientState(GL\_VERTEX\_ARRAY);  
&nbsp; glVertexPointer(3, GL\_SHORT, 0, vertexArray);  
&nbsp; //3 = XYZ coordinates, GL\_SHORT = data type, 0 = 0 stride bytes  
**&nbsp;&nbsp; glColor4f(255,0,0,1);**  
&nbsp; **glDrawElements(GL\_TRIANGLES, 3000, GL\_UNSIGNED\_BYTE, vertexIdx);**
  

&nbsp; glDisableClientState(GL\_VERTEX\_ARRAY);  
&nbsp;  
&nbsp; eglSwapBuffers(glesDisplay, glesSurface);  
&nbsp; 
  

&nbsp; time = GetTickCount() - time;  
&nbsp; PrintDebugInfo("time = %ldn",time);  
}

  

**the result is as follows:**
  

time = 282  
time = 393  
time = 392  
time = 392  
time = 392  
time = 392  
time = 393  
time = 392  
time = 393  
time = 392  
time = 392  
time = 393
  

&nbsp;
  

2ã€rend 1000 triangles using **glDrawArrays and** glColor4f
  

  

void Render()  
{  
&nbsp;&nbsp;&nbsp;&nbsp; long time = 0;  
&nbsp;&nbsp;&nbsp;&nbsp; int i;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp; GLshort vertexArray[9000] = {-25,-25,0,&nbsp;&nbsp; 25,-25,0,&nbsp;&nbsp; 0,25,0 };  
&nbsp;&nbsp;&nbsp; GLubyte colorArray[12] = {255,0,0,0,&nbsp;&nbsp; 0,255,0,0,&nbsp;&nbsp;&nbsp; 0,0,255,0};  
&nbsp; for (i = 0; i \< 1000; i ++)  
&nbsp; {  
&nbsp;vertexArray[9\*i + 0] = -25;  
&nbsp;vertexArray[9\*i + 1] = -25;  
&nbsp;vertexArray[9\*i + 2] = 0;
  

&nbsp;vertexArray[9\*i + 3] = 25;  
&nbsp;vertexArray[9\*i + 4] = -25;  
&nbsp;vertexArray[9\*i + 5] = 0;  
&nbsp;vertexArray[9\*i + 6] = 0;  
&nbsp;vertexArray[9\*i + 7] = 25;  
&nbsp;vertexArray[9\*i + 8] = 0;  
&nbsp; }  
&nbsp; glClear(GL\_COLOR\_BUFFER\_BIT | GL\_DEPTH\_BUFFER\_BIT);&nbsp;   
&nbsp; glLoadIdentity();&nbsp; 
  

&nbsp; glTranslatex(0, 0, FixedFromInt(-10));  
time = GetTickCount();
  

&nbsp; //Enable the vertices array&nbsp;   
&nbsp; glEnableClientState(GL\_VERTEX\_ARRAY);  
&nbsp; glVertexPointer(3, GL\_SHORT, 0, vertexArray);  
&nbsp; //3 = XYZ coordinates, GL\_SHORT = data type, 0 = 0 stride bytes  
**&nbsp; glColor4f(255,0,0,1);**  
&nbsp; **glDrawArrays(GL\_TRIANGLES, 0, 3000);**
  

&nbsp; glDisableClientState(GL\_VERTEX\_ARRAY);  
&nbsp;  
&nbsp; eglSwapBuffers(glesDisplay, glesSurface);  
&nbsp; 
  

&nbsp; time = GetTickCount() - time;  
&nbsp; PrintDebugInfo("time = %ldn",time);  
}
  

**the result is :**
  

time = 79  
time = 379  
time = 376  
time = 380  
time = 334  
time = 379  
time = 378  
time = 379  
time = 379  
time = 379  
time = 377
  

&nbsp;
  

3ã€‚rend 1000 triangles using **glDrawElements but without** glColor4f
  

  

void Render()  
{  
&nbsp;&nbsp;&nbsp;&nbsp; long time = 0;  
&nbsp;&nbsp;&nbsp;&nbsp; int i;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp; GLshort vertexArray[500] = {-25,-25,0,&nbsp;&nbsp; 25,-25,0,&nbsp;&nbsp; 0,25,0 };  
&nbsp;&nbsp;&nbsp; GLubyte colorArray[12] = {255,0,0,0,&nbsp;&nbsp; 0,255,0,0,&nbsp;&nbsp;&nbsp; 0,0,255,0};
  

**&nbsp;&nbsp;&nbsp; GLubyte vertexIdx[3000];  
&nbsp; for (i = 0; i \< 1000; i ++)  
&nbsp; {**
  

**&nbsp;vertexIdx[i\*3 + 0] = 0;  
&nbsp;vertexIdx[i\*3 + 1] = 1;  
&nbsp;vertexIdx[i\*3 + 2] = 2;  
&nbsp; }**  
&nbsp; glClear(GL\_COLOR\_BUFFER\_BIT | GL\_DEPTH\_BUFFER\_BIT);&nbsp;   
&nbsp; glLoadIdentity();&nbsp; 
  

&nbsp; glTranslatex(0, 0, FixedFromInt(-10));  
time = GetTickCount();
  

&nbsp; //Enable the vertices array&nbsp;   
&nbsp; glEnableClientState(GL\_VERTEX\_ARRAY);  
&nbsp; glVertexPointer(3, GL\_SHORT, 0, vertexArray);  
&nbsp; //3 = XYZ coordinates, GL\_SHORT = data type, 0 = 0 stride bytes  
**&nbsp;&nbsp;// glColor4f(255,0,0,1);**  
&nbsp; **glDrawElements(GL\_TRIANGLES, 3000, GL\_UNSIGNED\_BYTE, vertexIdx);**
  

&nbsp; glDisableClientState(GL\_VERTEX\_ARRAY);  
&nbsp;  
&nbsp; eglSwapBuffers(glesDisplay, glesSurface);  
&nbsp; 
  

&nbsp; time = GetTickCount() - time;  
&nbsp; PrintDebugInfo("time = %ldn",time);  
}
  

**the result is :**
  

  

time = 349  
time = 483  
time = 481  
time = 482  
time = 481  
time = 482  
time = 481  
time = 481  
time = 483  
time = 484
  

&nbsp;
  

so,I&nbsp;can't &nbsp;understand the results.
  

&nbsp;
  

First, comparing code 1 and code 2, I find that the performance of the code using glDrawArrays is a little better than glDrawElements&nbsp; .Whileï¼Œtheoretically speakingï¼Œit seems&nbsp;using&nbsp;&nbsp;glDrawElements&nbsp; is better.right?
  

&nbsp;
  

Second, comparing code 1 and code&nbsp;3, why the performance of the code calling glColor4f explicitly is much better than using the default color?
  

&nbsp;
  

Third,rending 1000 triangles takes about 400 microseconds.This result is&nbsp; quiet terrible,though I don't know how long it should take to rend.Is there any serious problem in my codes?
  

&nbsp;
  

&nbsp;
