NeHe OpenGL 3d-Triangles Vs. Quads? |
NeHe OpenGL 3d-Triangles Vs. Quads? |
MrOzBarry
|
I don't know the exact reason for triangles, but I believe it's because triangles are more versatile - I have a friend that does 3d modelling and that's all using triangles. I'm sure there's a better reason, but for most complex shapes, it's just easier. If you're just doing boxes with no textures, quads is fine. If you're doing a complex 3d shape, triangles are the way to go.
On Wed, Jun 30, 2010 at 9:02 PM, JeZ-l-Lee wrote:
|
|||||||||||||
|
NeHe OpenGL 3d-Triangles Vs. Quads? |
Casey Banner
Guest
|
Quads are usually converted to triangles before rendering, and quads
don't exist in OpenGL 3.x. -Casey On Wed, Jun 30, 2010 at 9:02 PM, JeZ-l-Lee wrote:
SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|
NeHe OpenGL 3d-Triangles Vs. Quads? |
JeZ-l-Lee
|
Hi,
Thanks for the response. I wish to make a simple 3d game with square tiles for floor, ceiling, and walls. The squares would have square textures. Would be OK to use quads for this? Jesse On 06/30/2010 09:06 PM, Alex Barry wrote:
|
|||||||||||||||
|
NeHe OpenGL 3d-Triangles Vs. Quads? |
MrOzBarry
|
As Casey pointed out, quads get converted into two triangles, so it's probably better practice to just use triangles.
On Wed, Jun 30, 2010 at 9:11 PM, Jesse Palser wrote:
|
|||||||||||||||||
|
NeHe OpenGL 3d-Triangles Vs. Quads? |
Torsten Giebl
|
Hello !
Put two triangles together and you have a quad. In 3D programming triangles are the most used things, because a single triangle is always flat, no matter how you set the three points. This is important for algorithms like, is the triangle viewable on the screen or only parts of it and so on. It would be a lot harder with things like real quads, that can be in a non flat form. So for a wall you just glue two triangles together and using the correct texture UV coords, you get what you want. CU _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|
NeHe OpenGL 3d-Triangles Vs. Quads? |
Donny Viszneki
Guest
|
Triangles are the basic building block of any polygon. All polygons
can be built from triangles. This is the reason graphics hardware and a lot of graphics software use triangles as their graphical primitives (with some notable exceptions like line segments and points.) On Wed, Jun 30, 2010 at 9:02 PM, JeZ-l-Lee wrote:
-- http://codebad.com/ _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|
NeHe OpenGL 3d-Triangles Vs. Quads? |
JeZ-l-Lee
|
Hi,
So I must use triangles...I accept that. But am still confused... My textures would be squares - for example 256x256. How do I draw one half into one triangle and the other half in another triangle? Please forgive my ignorance, I've never done 3d game programming before. Thanks! Jesse On 06/30/2010 09:25 PM, Torsten Giebl wrote:
_______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||||
|
NeHe OpenGL 3d-Triangles Vs. Quads? |
John Magnotti
Guest
|
that internally renders as triangles, but I remember when I rewrote my program to use triangles instead of quads and found no appreciable speed up. If you ever work on high-class stuff, you may run into a situation where the difference is noticeable. As a further point, though, it is pretty common to crunch things to display lists, vertex buffer objects or whatever if you need more speed. Turning triangles into quads naively also means extra vertices (previous techniques solve this problem).
pretend like the triangles are quads and list the texture points beside the appropriate vertices. Say you want a quad using the points [x1, y1], [x2, y1] to [x2, y2], [x1,y2]. Just render triangle one at [x1, y1], [x2, y1], [x1, y2] using tex coordinates: [0,0], [1, 0], [0, 1]. Then the second triangle is at [x2,y1], [x2, y2], [x1,y2] with tex coordinates [1,0], [1, 1], [0,1]. To reiterate, though, write it as quads to get something up and running, maybe it will be fast enough for your needs. If this is your first project, save the high-performance tuning for your second project :) I think someone mentioned the Redbook not too long, this is an excellent resource to accompany online tutorials: http://www.glprogramming.com/red/ John _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||||
|
NeHe OpenGL 3d-Triangles Vs. Quads? |
Torsten Giebl
|
Hello !
The UV texture coordinates you assign, basically cut out a triangle form of the texture. Look at Lesson 6 of the NeHe Demos, he explains on the site how the cut out is done. If you want to be successfull, it is important that you start from the first lesson and then go on from there. Back in 2001 bought a book about "OpenGL Programming" : http://www.amazon.com/OpenGL-Programming-Prima-Techs-Development/dp/0761533303/ref=sr_1_11?ie=UTF8&s=books&qid=1277949252&sr=8-11 As from this year, it tolds nothing about shaders, but it explains nearly everything from the beginning to generating 3D landscapes and how to build a simple engine, loading player models and so on. CU _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|
NeHe OpenGL 3d-Triangles Vs. Quads? |
Justin Coleman
Guest
|
This is the book I learned from, years back (1st or 2nd ed, I
recommend you get the 4th ed as it's much updated): http://www.opengl.org/sdk/docs/books/SuperBible/ On Wed, Jun 30, 2010 at 9:30 PM, Jesse Palser wrote:
SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||||||
|
NeHe OpenGL 3d-Triangles Vs. Quads? |
Jonny D
|
Using a triangle strip with 4 coplanar vertices is the same as drawing a quad. Something like this:
glBegin(GL_QUADS);glTexCoord2f(0, 0); glVertex3f(0, 0); glTexCoord2f(1, 0); glVertex3f(1, 0); glTexCoord2f(1, 1); glVertex3f(1, 1); glTexCoord2f(0, 1); glVertex3f(0, 1); glEnd(); glBegin(GL_TRIANGLE_STRIP);glTexCoord2f(0, 0); glVertex3f(0, 0); glTexCoord2f(1, 0); glVertex3f(1, 0); glTexCoord2f(1, 1); glVertex3f(1, 1); glTexCoord2f(0, 1); glVertex3f(0, 1); glEnd(); Jonny D On Wed, Jun 30, 2010 at 7:01 PM, Justin Coleman wrote:
|
|||||||||||||||||||
|