NeHe OpenGL 3d-Triangles Vs. Quads?

NeHe OpenGL 3d-Triangles Vs. Quads?

Hi,

I’m a little confused.

Was looking at the NeHe SDL1.2+OpenGL 3d tutorial lesson 23 sources.
It displays a 3d world with floor, ceiling, & walls + movement with [ARROW] keys & aim with mouse.
This lesson loads in a map file, but the information loaded to display 3d world is triangles?

Why use triangles? Was thinking quads would be a better choice but perhaps I am wrong?
(the 3d demo draws squares for floor, ceiling, and walls - so was thinking quads would be better)

Can someone explain why triangles are used in this demo and not quads?

Also, how was the map file created? Is there some program I can install on Ubuntu 10.04
that would allow me to make a similar map file? (can’t see typing out a larger map)

Thanks!------------------------
JeZ+Lee
JessePalser <AT> Gmail <DOT> com
16BitSoft®
Video Game Design Studio
www.16BitSoft.com

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?

Hi,

I’m a little confused.

Was looking at the NeHe SDL1.2+OpenGL 3d tutorial lesson 23 sources.
It displays a 3d world with floor, ceiling, & walls + movement with [ARROW]
keys & aim with mouse.
This lesson loads in a map file, but the information loaded to display 3d
world is triangles?

Why use triangles? Was thinking quads would be a better choice but perhaps
I am wrong?
(the 3d demo draws squares for floor, ceiling, and walls - so was thinking
quads would be better)

Can someone explain why triangles are used in this demo and not quads?

Also, how was the map file created? Is there some program I can install on
Ubuntu 10.04
that would allow me to make a similar map file? (can’t see typing out a
larger map)

Thanks!


JeZ+Lee
JessePalser Gmail com
16BitSoft®
Video Game Design Studio
www.16BitSoft.com


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Quads are usually converted to triangles before rendering, and quads
don’t exist in OpenGL 3.x.

-CaseyOn Wed, Jun 30, 2010 at 9:02 PM, JeZ-l-Lee wrote:

NeHe OpenGL 3d-Triangles Vs. Quads?

Hi,

I’m a little confused.

Was looking at the NeHe SDL1.2+OpenGL 3d tutorial lesson 23 sources.
It displays a 3d world with floor, ceiling, & walls + movement with [ARROW]
keys & aim with mouse.
This lesson loads in a map file, but the information loaded to display 3d
world is triangles?

Why use triangles? Was thinking quads would be a better choice but perhaps I
am wrong?
(the 3d demo draws squares for floor, ceiling, and walls - so was thinking
quads would be better)

Can someone explain why triangles are used in this demo and not quads?

Also, how was the map file created? Is there some program I can install on
Ubuntu 10.04
that would allow me to make a similar map file? (can’t see typing out a
larger map)

Thanks!


JeZ+Lee
JessePalser Gmail com
16BitSoft®
Video Game Design Studio
www.16BitSoft.com


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

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?

JesseOn 06/30/2010 09:06 PM, Alex Barry wrote:

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 <SLNTHERO at aol.com <mailto:SLNTHERO at aol.com>> wrote:

NeHe OpenGL 3d-Triangles Vs. Quads?

Hi,

I'm a little confused.

Was looking at the NeHe SDL1.2+OpenGL 3d tutorial lesson 23 sources.
It displays a 3d world with floor, ceiling, & walls + movement
with [ARROW] keys & aim with mouse.
This lesson loads in a map file, but the information loaded to
display 3d world is triangles?

Why use triangles? Was thinking quads would be a better choice but
perhaps I am wrong?
(the 3d demo draws squares for floor, ceiling, and walls - so was
thinking quads would be better)

Can someone explain why triangles are used in this demo and not quads?

Also, how was the map file created? Is there some program I can
install on Ubuntu 10.04
that would allow me to make a similar map file? (can't see typing
out a larger map)

Thanks!


------------------------------------------------------------------------

JeZ+Lee
JessePalser <AT> Gmail <DOT> com
16BitSoft(R)
Video Game Design Studio
www.16BitSoft.com <http://www.16BitSoft.com>

_______________________________________________
SDL mailing list
SDL at lists.libsdl.org <mailto:SDL at lists.libsdl.org>
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

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:

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:

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?

Hi,

I’m a little confused.

Was looking at the NeHe SDL1.2+OpenGL 3d tutorial lesson 23 sources.
It displays a 3d world with floor, ceiling, & walls + movement with
[ARROW] keys & aim with mouse.
This lesson loads in a map file, but the information loaded to display 3d
world is triangles?

Why use triangles? Was thinking quads would be a better choice but perhaps
I am wrong?
(the 3d demo draws squares for floor, ceiling, and walls - so was thinking
quads would be better)

Can someone explain why triangles are used in this demo and not quads?

Also, how was the map file created? Is there some program I can install on
Ubuntu 10.04
that would allow me to make a similar map file? (can’t see typing out a
larger map)

Thanks!


JeZ+Lee
JessePalser Gmail com
16BitSoft®
Video Game Design Studio
www.16BitSoft.com


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing listSDL at lists.libsdl.orghttp://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Hello !

I’m a little confused.

Was looking at the NeHe SDL1.2+OpenGL 3d tutorial lesson 23 sources.
It displays a 3d world with floor, ceiling, & walls + movement with [ARROW] keys & aim with mouse.
This lesson loads in a map file, but the information loaded to display 3d world is triangles?

Why use triangles? Was thinking quads would be a better choice but perhaps I am wrong?
(the 3d demo draws squares for floor, ceiling, and walls - so was thinking quads would be better)

Can someone explain why triangles are used in this demo and not quads?

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

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:

NeHe OpenGL 3d-Triangles Vs. Quads?

Hi,

I’m a little confused.

Was looking at the NeHe SDL1.2+OpenGL 3d tutorial lesson 23 sources.
It displays a 3d world with floor, ceiling, & walls + movement with [ARROW]
keys & aim with mouse.
This lesson loads in a map file, but the information loaded to display 3d
world is triangles?

Why use triangles? Was thinking quads would be a better choice but perhaps I
am wrong?
(the 3d demo draws squares for floor, ceiling, and walls - so was thinking
quads would be better)

Can someone explain why triangles are used in this demo and not quads?

Also, how was the map file created? Is there some program I can install on
Ubuntu 10.04
that would allow me to make a similar map file? (can’t see typing out a
larger map)

Thanks!


JeZ+Lee
JessePalser Gmail com
16BitSoft®
Video Game Design Studio
www.16BitSoft.com


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


http://codebad.com/

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!

JesseOn 06/30/2010 09:25 PM, Torsten Giebl wrote:

Hello !

I’m a little confused.

Was looking at the NeHe SDL1.2+OpenGL 3d tutorial lesson 23 sources.
It displays a 3d world with floor, ceiling,& walls + movement with [ARROW] keys& aim with mouse.
This lesson loads in a map file, but the information loaded to display 3d world is triangles?

Why use triangles? Was thinking quads would be a better choice but perhaps I am wrong?
(the 3d demo draws squares for floor, ceiling, and walls - so was thinking quads would be better)

Can someone explain why triangles are used in this demo and not quads?
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
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

So I must use triangles…I accept that.
But am still confused…
Just to chime in, I’ve had success with just using a DrawQuad function
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).

My textures would be squares - for example 256x256.
How do I draw one half into one triangle and the other half in another
triangle?
Although this sounds hard, OpenGL will do the hard part for you–just
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 :slight_smile:

I think someone mentioned the Redbook not too long, this is an
excellent resource to accompany online tutorials:
http://www.glprogramming.com/red/

John

Hello !

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.

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” :

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

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:

?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:

Hello !

I’m a little confused.

Was looking at the NeHe SDL1.2+OpenGL 3d tutorial lesson 23 sources.
It displays a 3d world with floor, ceiling,& ?walls + movement with
[ARROW] keys& ?aim with mouse.
This lesson loads in a map file, but the information loaded to display 3d
world is triangles?

Why use triangles? Was thinking quads would be a better choice but
perhaps I am wrong?
(the 3d demo draws squares for floor, ceiling, and walls - so was
thinking quads would be better)

Can someone explain why triangles are used in this demo and not quads?

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
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

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 DOn Wed, Jun 30, 2010 at 7:01 PM, Justin Coleman wrote:

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:

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:

Hello !

I’m a little confused.

Was looking at the NeHe SDL1.2+OpenGL 3d tutorial lesson 23 sources.
It displays a 3d world with floor, ceiling,& walls + movement with
[ARROW] keys& aim with mouse.
This lesson loads in a map file, but the information loaded to display
3d

world is triangles?

Why use triangles? Was thinking quads would be a better choice but
perhaps I am wrong?
(the 3d demo draws squares for floor, ceiling, and walls - so was
thinking quads would be better)

Can someone explain why triangles are used in this demo and not quads?

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
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org