Jump to content
  • Advertisement
Sign in to follow this  
MAPster7

OpenGL draw calls and primitives

This topic is 640 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello,

I'm quite new to graphics programming and there are a few things I do not understand (openGL) :

 

1) Does a game only use 1 draw call or does it use multiple draw calls ? As far as I understood ( in simple examples ), you do one draw call and then any movement is done by the vertex shader with translation matrixes. But in large games you have to load/unload parts of the world. There is my question: Are there several draw calls used to draw different primitives ?

 

2) I found the term "draw call batching". It seems to have sth to do with instancing... what is draw call batching ?

 

3) Let's assume I want to draw a (solid) circle in openGL. My understanding is that triangles are the primitives, that graphic cards are mainly designed for (correct ? ). So you do not really want to use points or lines as primitives. This immediately makes me think of a folding fan. Here is my question: If you only use openGL do you really build everything from triangles ?

 

Thanks in advance for your answers

greetings

MAPster

Share this post


Link to post
Share on other sites
Advertisement
Games typically use a few hundred up to tens of thousands of draw calls. A few thousand would be common.

Batching is loosely any technique that lets you reduce the number of draw calls required. This traditionally includes places two different models contiguously into the same vertex buffer, so they can be drawn in one go.

Yes GPUs are built around triangles. Points and lines are supported, but not that useful in most scenes.
Triangles can come in lists, fans or strips. Strips used to be common as they're often a more compact (but more restrictive) representation, but GPUs have gotten better at dealing with lists, so I would say they're far more common now.

Any larger polygons (quads, pentagrams, hexagrams, etc) are split into triangles by GL before they're given to the GPU. GL's polygon mode is not recommended - split your polys into triangles yourself.

Share this post


Link to post
Share on other sites
  1. Separate draw calls are used to control drawing order (e.g. foreground objects drawn after, and therefore on top of, background objects) and for different states (e.g. text with an orthographic projection and a special distance field shader separated from 3D objects with a perspective projection and a lighting shader, or different groups of objects with different sets of textures).
    Reducing the number of calls is largely a matter of convenience: do you want to complicate code to collect compatible things to draw from unrelated places? Are you able and willing to use depth buffers or related techniques to draw primitives within the same draw call in the correct order? How far can you consolidate textures, shaders and vertex data of different objects?
    Loading and unloading data as the game progresses happens at a much slower timescale than draw calls. If you have, say, 30 potential draw calls for 30 groups of models, the subset that actually draws something varies from frame to frame, and your game engine can conservatively load assets before they are needed and recycle unnecessary textures etc. when memory is low.
  2. Batching is using one draw call to render as much data as possible, avoiding the overhead of unnecessary draw calls; instancing is using one object's worth of data, typically vertex buffers, multiple times for drawing multiple objects, reducing CPU-side work and transferred data compared to explicitly filling vertex buffers. They are both techniques to increase rendering efficiency, but aimed at different cost components.   
  3. Lines are rarely useful because they can be easily replaced by a long and thin rectangle (i.e. two triangles), normally more flexible and about equally cheap. Points might be cheaper than a small triangle or square textured with a "point sprite", but they are also much more limited.

Share this post


Link to post
Share on other sites
  1. Lines are rarely useful because they can be easily replaced by a long and thin rectangle (i.e. two triangles), normally more flexible and about equally cheap. Points might be cheaper than a small triangle or square textured with a "point sprite", but they are also much more limited.

 

 

Interesting. Is this really widely used as this ? (I'm talking about lines used as rectangles).

Share this post


Link to post
Share on other sites

  • Lines are rarely useful because they can be easily replaced by a long and thin rectangle (i.e. two triangles), normally more flexible and about equally cheap. Points might be cheaper than a small triangle or square textured with a "point sprite", but they are also much more limited.
 
Interesting. Is this really widely used as this ? (I'm talking about lines used as rectangles).
For exactly 1 pixel thick lines, then lines are used. For anything thicker or thinner or curved, rectangles are used.

Share this post


Link to post
Share on other sites

 

 

 

  • Lines are rarely useful because they can be easily replaced by a long and thin rectangle (i.e. two triangles), normally more flexible and about equally cheap. Points might be cheaper than a small triangle or square textured with a "point sprite", but they are also much more limited.
 
Interesting. Is this really widely used as this ? (I'm talking about lines used as rectangles).
For exactly 1 pixel thick lines, then lines are used. For anything thicker or thinner or curved, rectangles are used.

 

 

Thank you.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!