Using GL_QUAD_STRIPS to make a cube.

Hey guys. I’ve finally crawled out of my hole in the ground and have learned that using glBegin/glEnd and 24 vertices is just about the slowest way to draw a simple cube. Since then, I’ve read up on vertexarrays, gldrawelements, strips, etc. Now… I would like to use gldrawelements and a quadstrip to draw a full cube.

I have successfully figured out how to draw the right, front, left and back sides. Now I’m kind of confused. Is it possible to fit the top and bottom in the same strip? Like I said… I’m new to strips… so I’m not sure if I’m ordering it the correct way… of if it is just impossible. I understand that I may have to use a strip to draw 4 of the sides, and then use normal quads to cap off the top and bottom. Is this the case?

Please let me know if it is impossible to use one strip to achieve a full cube, or if I need to use an entirely different method that will be just as fast or faster than a quad strip.

Thanks in advance!

Anyone? =) Really need to know this stuff before moving on with my engine… it’s pretty low level and determines how I decide to do a bunch of stuff… thanks!

Oh yeah… I am “Llama” … finally got off my butt and registered =P

[This message has been edited by Cebu (edited 03-29-2001).]

Another hint: is to use tristrips instead of quadstrips - they are faster as they still only require 4 verts to do a quad but it is already broken down in to triangles which the gfx card would have to do if you used quads. You will have to add 2 extra quads, but preferably tristrips for the top and bottom.

[This message has been edited by Tim Stirling (edited 03-29-2001).]

Alright… I’ll try out triangle strips. So there’s no way to use a single strip for the whole cube? Hmm just from the top of my head seems like it would be possible to do 5 sides via triangles… is this correct?

Err I’m smoking crack… nevermind about the 5 sides thing… I guess it’s the same deal as quad strips as far as that goes. I want to post some partial code though… and make sure I’m doing this the best way. Again… I’m just trying to make a complete cube.

glDrawElements(GL_TRIANGLE_STRIP, 10, GL_UNSIGNED_BYTE, vertexIndexForSides);

glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_BYTE, vertexIndexForTop);

glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_BYTE, vertexIndexForBottom);

Basically… is this the minimum (of actual drawing code) I can do to make a cube. I’m open to any suggestions that’ll consolidate any work or make stuff faster. Thanks again for any suggestions

even better use 2 fans.
just pick 2 opposite vertices for the fans center.

|  | |

Oh nice… two fans… that’s a good idea. I’ll give that a twirl. Thanks for the suggestion Zed

Or why not go for one strip for the whole cube: top, left, front, right, back, bottom

Won’t that one work aswell?

Before going any further - did you want to use lighting? If so, you’re better off with GL_QUADS or GL_TRIANGLES; stripping/fanning uses the same computed vertex colour for each usage of a vertex by a triangle, and for a cube that’s going to look really bad.

Originally posted by Bob:
[b]Or why not go for one strip for the whole cube: top, left, front, right, back, bottom

Won’t that one work aswell?[/b]

The topic question was asking if this is possible and it isn’t.

2 triangle fans- thats clever!

MikeC, at some point I do plan on using lighting… I’m not sure what you mean by same vertex color etc though. I guess I’ll just have to go ahead and throw in a light and see what happens with the strip to see what you mean.

Oh yeah - for the current objects (walls) I’ve decided to just go with one strip to do all the sides and leave off the tops and bottoms, since they will not be viewable.

Tim - thanks for clearing stuff up a bit…
Bob - if you know a way to use a single strip for all sides of a cube, I think we’d all like to see that source code… cause I sure as hell don’t know how :stuck_out_tongue:

Thanks to everyone for their help so far… any other input would be greatly appreciated… I’m learning a lot.