Drawing a quad with ONE strip

Started by
10 comments, last by VanKurt 22 years, 3 months ago
Is it possible, to draw a quad (consisting of (forExample) 9 vertices), in ONE triangle strip ? The quad: 0 1 2 3 4 5 6 7 8 If I could do that, it would give my app a hardcore-speedUp. I''ve wasted thousands of pencils and sheets of paper to solve this prob, but I failed....... My best approach was this one: 0, 3, 1, 4, 2, 5, 8, 4, 7, 3, 6 But it''s buggy... ( Because of 2, 5, 8 ) :-((( Do you have an better idea ?
Advertisement
Sorry if I''m not being too helpful here, but why does the quad need 9 vertices? If it''s really a quad you only need the 4 corners. Vertices 1,3,5 and 8 must be in line with the edges of the quad and 4 isn''t needed either. In that case you could do it in a triangle strip.
You''d use a 9-point quad for things such as terrain.

And I think what you need is a triangle fan, not a strip.
Start with the center then draw the rest counter-clockwise.
Works great. =)

- Mike
"The important thing to remember when programming is: When you're 90% complete, there's still 50% more to go."
Yeah, I've had this problem, too. I'm not sure if it can actually be done with one GL_TRIANGLE_STRIP or GL_TRIANGLE_FAN call. I have eight vertices, which make a 3D cube or cuboid, with 2 triangles for each of 6 faces, when constructed. I have to render them using GL_TRIANGLES, because I haven't been able to find a method for winding the vertices properly.

I have found that for objects such as walls, GL_TRIANGLE_STRIP, if I could find the winding order, is actually more inefficent than GL_TRIANGLES. I suppose triangle strips should only be used when drawing models, which have enough vertices to warrant a decent drop in function calls to glVertex*.

If anyone does know a winding order to draw 12 triangles, which create 6 sides, I'd be glad to know it, but I don't think it can be done...

Edited by - iNsAn1tY on January 14, 2002 5:31:49 PM
My opinion is a recombination and regurgitation of the opinions of those around me. I bring nothing new to the table, and as such, can be safely ignored.[ Useful things - Firefox | GLee | Boost | DevIL ]
Um, a quad always has 4 vertices. That''s why it''s called a quad.

www.elf-stone.com

____________________________________________________________www.elf-stone.com | Automated GL Extension Loading: GLee 5.00 for Win32 and Linux

With "quad" I mean that it has a square shape. And mkaltner said, I need it for a landscape (You''re smart ;-)).
But as some of you said, I can''t use a fan, because the real size is 33x33 vertices (This here is just a simplyfied example).

My biggest problem is that I need 32 calls to glDrawElements(), to draw my quad. If I could draw all triangles with ONE call, the frame rate would be twice as high !!!
(I tried that, but I don''t know how to bring the vertices in a proper order)

Could anyone tell me what other possibilities I have to draw such a quad ? Perhaps I could tell glDrawElements() to draw it as triangles (not as a strip). How would my vertex-array have to look like then ?

thx, VanKurt
FFS, don''t misuse terms then. When you come in the OpenGL forum talking about quads, you can expect people to think you''re talking about 4 sided polygons. If you''d got as far as reading the definition in the docs for glBegin()/glEnd() you would know that.

Also, learn to spell.

www.elf-stone.com

____________________________________________________________www.elf-stone.com | Automated GL Extension Loading: GLee 5.00 for Win32 and Linux

One quick note... while your use of "quad" in the sense of a 4-sided figure is valid, the term "quad" in a computer graphics context usually means two triangles stuck together. Minor point, but as mentioned, it helps to avoid confusion.

What you are looking to do can be done with the help of degenerate triangles. A degenerate triangle is one with no area; it can be created by duplicating a vertex index. Most 3d hardware can recognize these and either efficiently drop them or render them (which, since they are degenerate, does not affect output).

So, one way to tristrip your square mesh would be:

0 3 1 4 2 5 5 8 7 4 3 6

or even

0 3 1 4 2 5 5 3 3 6 4 7 5 8

Don''t immediately throw out the last because it''s longer... (nor immediately accept it because I told you not to throw it out). There are many factors involved in getting full performance. Vertex cache is one, and potentially neither of the above are the best way to do it (for longer strips, that is). Some platforms, also, could do this without degen tris (PS2, for example) by using draw kick bits... not that the PS2 can''t handle a degen, but it may be better to do it other ways and save a little DMA.

Anyway, try the degens and see if it works for you. Then figure out your hardware to get the best efficiency.


---- --- -- -
Blue programmer needs food badly. Blue programmer is about to die!
Well, from the large number of different things you are wanting to do, why not just toss out all the triangle strips, fans, quads, loop de loops, and cubes and just use indexed vertecies. It has about the same performance gain I think and allows you to do anything you want.
XanGame ProgrammerVolition Inc.
Well, glDrawElements() is used with indexed vertices so I assume that is already what he is doing..

''Very funny, Scotty. Now beam down my clothes.'' -

[TheBlackJester]

"With my feet upon the ground I lose myself between the sounds and open wide to suck it in, I feel it move across my skin. I'm reaching up and reaching out. I'm reaching for the random or what ever will bewilder me, what ever will bewilder me. And following our will and wind we may just go where no one's been. We'll ride the spiral to the end and may just go where no one's been." - Maynard James Keenan Name: [email=darkswordtbj@hotmail.com]TheBlackJester[/email]Team: Wildfire Games
Projects O A.D.The Last Alliance

This topic is closed to new replies.

Advertisement