[c++ opengl] poligon class

Started by
12 comments, last by giugio 15 years, 8 months ago
I assume you're asking whether rendering tri-strips with VBOs is fine?!

Yes, you can do so, but must be aware that using strips
(a) enforces the need to _have_ strips, e.g. to implement strip generation algorithms for non-strip models,
(b) may yield in the need of more than one invocations of glDrawElements, namely if more than a single strip is used,
(c) and/or (partly alternatively to (b)) introduce degenerated triangles.

The advantage of strips is their lesser amount of vertex indices which are to be generated and pushed into the VBO. On the other hand, if not using strips but lists (i.e. each triangle is defined by its own 3 vertex indices) you can optimize the order of indices so that the resulting timing outperforms strips. You have to implement an algorithm for that optimization, of course, but on the other hand you would also need to implement an algorithm for building strips.


But, if your question addresses whether building strips is itself a convenient process when dealing with VBOs ... I don't know, because I never implemented such an algorithm. As can be seen from my answers, I personally go the way of lists.


If you mean something else, please re-formulate your question.
Advertisement
very thanks haegarr.
Quote:
if not using strips but lists (i.e. each triangle is defined by its own 3 vertex indices)

i'm not understand why strips and lists can't cooperate, why i can't use a lists of strips?
this is your answer that i'm not understand
[qute]
you can optimize the order of indices so that the resulting timing outperforms strips



Is useless?
Perhaps we have a misunderstanding of the term "triangle list" here...

Triangle strips and triangle lists can co-exist, of course. But you can push either a strip or a list to the API. If you have more than 1 strip or else both a strip and a list, you need to invoke glDrawElements more than once. The declaration
glDrawElements( GLenum mode, GLsizei count, GLenum type, const GLvoid *indices )
requires a mode as the 1st parameter. It can be (besides others) GL_TRIANGLE_STRIP or else GL_TRIANGLES (for a list). And if it is GL_TRIANGLE_STRIP then the count parameter denotes the length of 1 strip.

To make it clear: A triangle list means that a sequence of indices
{ i0, i1, i2, i0, i3, i4, i5, ... }
is interpreted as
triangle 1: vertices with indices i0, i1, i2
triangle 2: vertices with indices i0, i3, i4
...
so each triplet of vertex indices addresses the vertices of a single triangle.

To understand why this can be better than triangle strips, you must have knowledge of the cache that follows the "transformation & lighting" hardware, or for short "post-T&L cache". As its name suggest, it caches vertices that are already processed. That cache isn't very big; it has thereabout 20 to 30 entries (perhaps bigger ones exist nowadays). Now, if you can apply a sort algorithm that ensures that any vertex of the mesh is not used any more after it is once forced out of the cache, you have an optimal use case. But if you use strips, you have another force that influences your indexing scheme, and perhaps the need to introduce additional vertices (for degeneration) that seizes cache places, and all that may lead to sub-optimality.

I don't say "strips are evil". I say that triangle lists can be better. Whether or not depends on the mesh and its vertex indexing.
Thanks.
I'm try to compile an example from the "beginning opengl game programming" , chapther 10 in which use the list,but the frame rating in my pc(from the 2000)is equal or low slower than not use it than with strips.
I repeat,is a 2000 pc, can be?.
by

[Edited by - giugio on August 15, 2008 12:07:50 PM]

This topic is closed to new replies.

Advertisement