Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best technique to handle vertices in OpenGL? C++

I am implementing a map renderer for Quake. I am currently running through the arrays of vertices and sending them one at a time. I was told that by using vertex arrays, I can greatly speed up the rendering process by sending vertices in a batch. Now, I have just looked at display lists and finally VBO's or vertex buffer objects. VBO's mention a great advantage in relation to client/server communication. IF I am just going to be developing a client and not a server, are VBO's still applicable to what I am doing?

What are games using currently in the OpenGL spectrum for quick vertex processing?

like image 915
Pladnius Brooks Avatar asked Jun 27 '11 18:06

Pladnius Brooks


2 Answers

When they say "client/server" communication, they are not talking about a internet network.

  • Client = The CPU
  • Server = The GFX hardware

These are two separate pieces of hardware. While they are (usually) attached to the same motherboard, they still need to communicate with each other. A graphics card doesn't usually have access to the main memory on your motherboard, so vertices (and textures, indices etc.) need to actually be sent to the graphics device.

Short story: Use Vertex Buffer Objects. For static data (like a Quake map) there is nothing better. The vertices are sent to the graphics device (server) once and stay there. When you draw things vertex by vertex (using something like glBegin(GL_TRIANGLES)) the vertices are sent across every frame, which, as you can imagine, is pretty inefficient.

like image 75
Peter Alexander Avatar answered Nov 14 '22 17:11

Peter Alexander


VBOs are the modern answer.

Do not misunderstand the terms "client" and "server" in the OpenGL-sense. This is not the difference between Apache (HTTP server) and Chrome (HTTP client, among other things). In OpenGL terms, the client is you/your code. The server is the graphics driver/hardware.

VBOs allow you to store vertex information on the graphics hardware, which can let you avoid sending each vertex to the card every time you use it. This is a huge advantage.

You ask about vertex processing, but to answer your question we'd have to clarify what you meant. If you mean getting vertices to the graphics card, the answer is VBOs. If we're talking about manipulating vertex data this can efficiently be achieved through Shaders.

like image 3
luke Avatar answered Nov 14 '22 15:11

luke