Advertisement

3d world using rectangles instead....

Started by July 15, 2003 06:03 PM
6 comments, last by Scraniel 21 years, 7 months ago
Hi, in lesson 10 it was possible to create a 3d world by mapping textures onto triangles. Is it possible create the same 3d world with squares instead and use four vertices? I have no clue how to do it, but if you change it, wont you have to change everywhere it says TRIANGLES to QUADS and similar to other code? Thanks!! ~Dan~
Also, is it possible to read in triangles and quads while creating the same world. The reason I ask is because if you are creating a floor with a brick texture, it is safe to use triangles, because the pattern is repetitive. BUT, if you have a unique rectangular texture like a rug on top of the floor, you need to read it in as a quad and then display the rectangular texture over your newly formed rectangle on top of the floor. See what I mean? Is it possible to read in both types in the same program.

~Dan~
Advertisement
Yes, it is possible to do both in the same program, just draw all your triangles and then all of your quads (or vice versa, you can even switch back and forth). Example:

glBegin(GL_TRIANGLES);  //Draw all the triangles  ...glEnd();glBegin(GL_QUADS);      //Draw all the quads  ...glEnd();glBegin(GL_TRIANGLES);  //More triangles if you want  ...glEnd(); 


Good luck
Take care using quads. They may look nice but most video cards won''t like them.
When tons of primitives are being drawn, you can expect triangles to be much faster even with the extra vertices. This benchmarking was done a year ago but I think it still holds true.

Previously "Krohm"

Quads usually have to be converted to triangles before being rendered anyway. Its just a waste of time.
Why use quads at all then? =/ Let alone polygons...
Will J
Advertisement
I don''t really know what they were thinking when they made the quad primitive. While I''m not certain on why they use polygons, I suppose its because they are easier for a computer to handle and rasterize than other visualization methods. Sure we can have voxels to display 3d, but they are too painfully slow to use on a wide scale basis (And on anything besides a lab computer!). Perhaps someone knows the true reason behind using triangles?
With triangles you know that all the points on it lie on the same plane nomatter where its vertices are which allows for fast and correct drawing.
-----------------Always look on the bright side of Life!

This topic is closed to new replies.

Advertisement