PDA

View Full Version : lots of questions.....

06-22-2001, 01:04 PM
glBegin ( GL_LOTS_OF_QUESTIONS );

I'm new to OpenGL programming and there are lots of things i don't understand:

is it needed that every new frame be cleared and drawn from the beginning? (i'm still using GLUT :)
why do i need GL_TRIANGLES for example, when i can use GL_POLYGON instead?

i've read some questions about walls or floors, how can such thing be made? (polygons and textures?)

are there any limits on the space..... hmm...... i mean how many objects (lines, points, polygons, etc.) can be placed and what's the maximum distance from the view point?
when i draw a large scene do i have to draw all the objects, even those that are behind the view point? (hmmm.... excuse my english :)
and.... in the examples i've read, coordinates are given in the range 0.0 - 1.0, i can't understand the idea (i've worked with pixels so far :)

there are more questions i have, but i think i can find their answers in the books.....

glEnd ( GL_THANKS_IN_ADVANCE_: );

Rottbott
06-22-2001, 01:18 PM
I'm new too, but with regards to:

"when i draw a large scene do i have to draw all the objects, even those that are behind the view point?"

If you can write a function to determine whether an object is in the viewport, then it's easy enough to check first and only render it if so. The hard bit is writing the function.

Eber Kain
06-22-2001, 01:48 PM
yes, you have to clear every frame, and draw the next from scratch.

the reason you have GL_TRIANGLES and GL_QUADS is that you can draw multiple ones inside a single set of
glBegin();
glEnd();
if you supply 6 vertex points with GL_TRIANGLES it draws 2 useing the first 3, then the next 3, if you use GL_POLYGON it draws one ploy with 6 points.

Yes everything is done with polys, generally triangles, or Quads.

You can draw as many thinga as you want, your computer just might not be able to keep up, so you get less than 1 fps.

The far clip plane is supplied by you, its the last number in gluPerspective, that haw many units away you can see.

You might waste time computeing coordnates for things that you cant see, which you probably need to do anyhow, but when opengl knows there off camera it wont worry with them.

coordnates can be anything thats within the range of a float in C++, when you call glColor3f; you need only pass values from 0 to 1.

ffish
06-22-2001, 05:41 PM
Triangles are the most important primitive for one main reason - they're guaranteed to be planar.

For example, say you had a flat quad in the xz plane with all y values = 0. Then if you changed one of the y values to y = 1, you'd still have a legal OpenGL quad, but it wouldn't be planar anymore. If you rotate that quad to a certain angle, you'd have a polygon that intersects itself, and the display behaviour is unspecified (i.e. it wouldn't work properly)

Of course, this isn't a problem if you manage your polygons properly and ensure they are always convex, non-self-intersecting and planar but with triangles this is always guaranteed.

Hope that helps.

DFrey
06-22-2001, 07:45 PM
is it needed that every new frame be cleared and drawn from the beginning?
Generally yes. However, if you manage the z-buffer correctly and can ensure that all pixels will get updated every frame, then you can draw frames without clearing either the color buffer or depth buffer.