How to render

Started by
1 comment, last by ed091maf 24 years, 5 months ago
It depends on you're API. I assume you mean GL or Direct3D. Also, you don't say whether the poly is convex or concave. Convex polys are quite easy, especially in GL:

glBegin(GL_POLYGON);
glVertex(...); // first point
...
glVertex(...); // last point
glEnd();

In D3DIM, its not quite that simple because you have to split the poly up into triangles yourself - triangulation. This is straightforward for convex polys. Draw some convex ploygons and see how easy it is to turn them into triangle-strips for yourself! Then:

device->Begin(D3DPT_TRIANGLESTRIP,
D3DFVF_VERTEX, 0);
device->Vertex(...); // first point
...
device->Vertex(...); // last point
device->End(0);

Note that there are MUCH more efficient ways of doing this in both GL and D3D when you know what you're doing!

Concave polys are a MUCH more complicated!

Advertisement
I want to render n-point polygon. Is it neccessary to triangulate it before rendering, and then render all triangles, or is it better to render without triangulating, and then how to do that?
Ernis
Sorry, for not mentioning the API. Actually i am doing (just for interest) my own rasterizer, and i want to render a convex polygon. And i want to do it in a fast way, so i want to know that fast way.
Ernis

This topic is closed to new replies.

Advertisement