# Thread: More than 60K triangles per second?

1. ## More than 60K triangles per second?

I am using the following code , which is slightly modified from the Code::Blocks opengl default project. The problem Im having is that I cant get more than 1000 triangles without falling below 60 fps. I'm not sure what the triangles per second rating is, as radeon doesn't specify for the 200, only 230 and up, but I'm sure 60K is very low. I think my VooDoo5 can do more than that. So I'm assuming I'm not optimizing the code right or something. please help

Code :
```glBegin(GL_TRIANGLES);

for(int z = 0;z<1000    ;z++){
//x = (rand() % 1000)/50 - 1.0f;
//y = (rand() % 100)/50 - 1.0f;

glColor3f(1.0f, 0.0f, 0.0f);   glVertex3f((float)(rand() % 1000)/500.0f - 1.0f,(float)(rand() % 1000)/500.0f - 1.0f,(float)(rand() % 1000)/500.0f - 1.0f);
glColor3f(0.0f, 1.0f, 0.0f);   glVertex3f((float)(rand() % 1000)/500.0f - 1.0f,(float)(rand() % 1000)/500.0f - 1.0f,(float)(rand() % 1000)/500.0f - 1.0f);
glColor3f(0.0f, 0.0f, 1.0f);   glVertex3f((float)(rand() % 1000)/500.0f - 1.0f,(float)(rand() % 1000)/500.0f - 1.0f,(float)(rand() % 1000)/500.0f - 1.0f);

}//*/

theta += 0.1f;
glEnd();```

2. Two things:

1) glBegin/glEnd code is slow; it will never be able to achieve full triangle throughput.

2) Triangle count isn't the only arbiter of performance. Depending on the size of those triangles you may well end up being fillrate-bound. If you wish to measure triangle count in isolation then you should draw them as small as possible (or not draw them at all).

3. If you want performance, you should be using glDrawArrays/glDrawElements/etc with the data in VBOs.

Using glBegin/glEnd means half a dozen function calls per triangle. The GPU is spending 1% of its time actually working and the the other 99% waiting for the CPU to send it more data.

4. Cwhizard, once you rework your drawing to use glDraw* and VBOs, there's lots more you can do if you still need more performance. The goal becomes minimizing the number of state changes and draw calls, and reducing the CPU time spent per draw. Lots of interesting techniques to learn here when you're ready.

5. Originally Posted by mhagain
Two things:

1) glBegin/glEnd code is slow; it will never be able to achieve full triangle throughput.

2) Triangle count isn't the only arbiter of performance. Depending on the size of those triangles you may well end up being fillrate-bound. If you wish to measure triangle count in isolation then you should draw them as small as possible (or not draw them at all).
Fillrate was an issue. making them smaller increased the TPS to 1.2M+. I tried to upload a screenshot, but all 3 methods, including posting a link, failed.

Code :
```            for(int z = 0;z<20000    ;z++){
float x = (float)(rand() % 1000)/600.0f - 0.9f;
float y = (float)(rand() % 1000)/600.0f - 0.9f;

glColor3f(1.0f, 0.0f, 0.0f);   glVertex3f(x,y,(x+y)/2.0f);
glColor3f(0.0f, 1.0f, 0.0f);   glVertex3f(x+0.1f,y,(x+y)/2.0f);
glColor3f(0.0f, 0.0f, 1.0f);   glVertex3f(x,y+0.1f,(x+y)/2.0f);

}//*/```

6. Originally Posted by Cwhizard
I tried to upload a screenshot, but all 3 methods, including posting a link, failed.
I've tried everything to post screenshots I could think of, including links to images uploaded to Imgur and Gyazo, with no luck.

The only thing that seems to work was uploading them to my web site. A link to those images displayed properly.

I'm interested in knowing of another way to post an image.

7. Just post the URL with a space or two in/after the http:// and we'll fix up the link for you.

8. Originally Posted by Dark Photon
Just post the URL with a space or two in/after the *snip* and we'll fix up the link for you.
It is literally denying even posting the url if http is removed. So I dont know It's still denying me. Here it is without the hypertext transport protocol thingy:

http://steamcommunity.com/sharedfile.../?id=932086498

9. I think perhaps myu account may not have permissions?

10. Ok. I fixed up your URL for you above. Next time just put some spaces in the URL (and make a comment about removing the spaces).

Sorry for the inconvenience. For spam prevention, new users can't post URLs until they have a certain small number of posts under-their-belt. It won't be long and you should be able to post URLs.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•