Best technique to handle vertices in OpenGL? C++
Asked Answered
N

2

7

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?

Nich answered 27/6, 2011 at 18:20 Comment(0)
F
10

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.

Farland answered 27/6, 2011 at 18:29 Comment(1)
A graphics card does have access to the main memory, but it's through a shared bus so there's a much greater delay compared to direct dedicated access to the VRAM.Habanera
M
3

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.

Maimonides answered 27/6, 2011 at 18:30 Comment(2)
Thanks for the answer. I will look into shaders as well.Nich
Shaders are great fun, but they can be difficult for beginners.Maimonides

© 2022 - 2024 — McMap. All rights reserved.