Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Triangle drawing order in DirectX/OpenGL

Is the order of drawing triangles in a 3D APIs guaranteed to be the same as their order in the index buffer?

For example if I have two overlapping triangles in a single draw call, and depth testing is disabled, will the first or second triangle be visible in the end?

Or do I need to issue separate draw calls to be sure that the 2nd triangle appears on top of the 1st?

like image 344
kaalus Avatar asked Jul 10 '12 10:07

kaalus


People also ask

What can you draw with 1 triangle in Direct3D?

Direct3D 11 Up and Running Anton Gerdelan. Last Updated 29 November 2019 This tutorial aims to get you set up with a minimal Direct3D 11 program that displays 1 triangle. If you can draw 1 triangle then you can draw anything.

What is the default windings order for OpenGL?

While you're right that counterclockwise is the default winding order (as it's called) for OpenGL, it might be useful to mention that the winding order is actually configurable using glFrontFace. This is an old answer, but calling this the right hand rule is likely to cause a great deal of confusion.

What is a triangle strip in 3D modeling?

Most objects in 3D scenes are composed of triangle strips. This is because triangle strips can be used to specify complex objects in a way that makes efficient use of memory and processing time. The following illustration depicts a rendered triangle strip. The following code shows how to create vertices for this triangle strip.

How many types of shaders are there in OpenGL?

Currently with OpenGL there are 6 types of shaders, vertex (GL_VERTEX_SHADER), tessellation control (GL_TESS_CONTROL_SHADER), tessellation evaluation (GL_TESS_EVALUATION_SHADER), geometry (GL_GEOMETRY_SHADER), fragment (GL_FRAGMENT_SHADER), compute (GL_COMPUTE_SHADER) shaders.


1 Answers

In OpenGL the order is indeed preserveed, so that painters algorithm can be used, for example when rendering semitransparent geometry.

Direct3D I don't know for sure, but I'd say the same applies there.

like image 146
datenwolf Avatar answered Oct 13 '22 14:10

datenwolf