Something I do not understand. All the tutorials on OpenGL, DirectX, or other, always show you how to draw a shape and then change its vertices, move it around and so on. But all the games I know of, tutorials on creating, etc., always have sprites and sprites alone.

What is the reason for drawing triangles and squares for games? I never see it used, only pre-made graphics.

edit: based upon answers so far, is the purpose of drawing shapes to "bound" a sprite? So if I have a character, on a platformer like Mario, Mario has a shape around him and that shape's location is used to detect collisions, etc.?

edit: Maybe a small example?

  • \$\begingroup\$ Opengl doesn't know what sprites are, it only draws triangles as fast as possible on the screen. So to create a sprite we need to render 2 triangles and attach a texture to it. \$\endgroup\$
    – Anton D
    Commented Jan 3, 2015 at 16:56
  • \$\begingroup\$ Why the down Vote? \$\endgroup\$
    – johnny
    Commented Jan 3, 2015 at 20:45

2 Answers 2


Because 3D libraries like OpenGL and DirectX draw everything using triangles, including sprites.

You put a texture (image) on triangles, put two triangles side by side to make a square and that's how you draw a "sprite" with OpenGL or Direct3D.

enter image description here

The sprites are drawn using triangles, its not for collisions, its simply for drawing them.

  • \$\begingroup\$ Are you saying the draw around a given sprite, so it can be manipulated, like a bounding square or the like? \$\endgroup\$
    – johnny
    Commented Jan 3, 2015 at 17:00
  • 1
    \$\begingroup\$ @johnny You need to accept that the only way to draw things in OpenGL/Direct3D is to draw geometry. It may be textured with images to emulate what you call sprites. The edges in the image above is debug output to help you visualise the underlying geometry used. \$\endgroup\$ Commented Jan 3, 2015 at 17:37
  • \$\begingroup\$ The fact is GPUs are used for drawing triangles primarily. They do this extremely quickly. True, you might have a faster sprite renderer if GPUs were all about drawing sprites, but they're not( thanks to 3D games ). You're still going to be drawing sprites much quicker using polygons and the GPU than you would be drawing sprites directly using the CPU. \$\endgroup\$
    – Ben
    Commented Jan 3, 2015 at 17:41

You can achieve certain effects with shapes that would be more difficult with sprites. For example if you want a circle line or a pathway to be drawn in certain amount of time, or an image shattering to several pieces. These are that came to my mind at the moment, but obviously, you can think up anything.

  • \$\begingroup\$ This answer does not quite address the underlying misunderstanding of the OP, which is what 3D APIs actually deal in only primitives. There are no sprites in the core API. \$\endgroup\$ Commented Jan 3, 2015 at 17:39
  • \$\begingroup\$ The only reason this is easier in something like OpenGL is because texture mapping is built in and already done for you. It's still not any easier to implement these things on your own using polygons over sprites. \$\endgroup\$
    – Ben
    Commented Jan 3, 2015 at 17:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .