Disapearing objects

Hello

I am wondering if there is an command in SDL or OpenGL that specifies
the distance at which objects are not drawn any more. My problem is I am
trying to draw an 800x600 array of items as a cube each, but my problem
is that if I do–

Hypermedia Research Centre
Sanyo R&D Headquarters, Tokyo
http://www.sanyo.co.jp/R_and_D/3dm/
Tel: +81 (0)3 5803 3566
Fax: +81 (0)3 5803 3640
Email: jg at tk.hm.rd.sanyo.co.jp
Please use open standard file formats for attachments

Sorry about sending twice…

Hello

I am wondering if there is an command in SDL or OpenGL that specifies
the distance at which objects are not drawn any more. My problem is I am
trying to draw an 800x600 array of items as a cube each, but my problem
is that if I do

glTranslatef(-50.0, -30.0, -100.0);
it is fine to see but i can not see the whole area, if i change it to
-110 etc i do not see any of my cubes from my display list.

I looked at glEnable(GL_DEPTH_TEST) and also the SDL_* functions.

Maybe it is an SDL_GL_SwapBuffers(); problem??

Any ideas? I could not find the Depth specification function.
Sorry in advance if a solution is blindingly obvious.

JG

[…]

Yes, have a look at gluPerspective (), this sets up the frustum sanely.
It’s actually a wrapper around lower-level OpenGL functions but it is
using that you will set up your near and far clip planes. The general
rule of thumb is to set your near clip as far away as you can stand it and
your far clip as close as you can get away with it. The short explanation
is that the Z values you feed OpenGL have an expoential decay resolution,
meaning that you have lots of resolution up close and not so much far
away.

Setting the frustum up incorrectly causes “Z-fighting” where two things
drawn kinda flicker as they try to decide for themselves which is in
front. Also things that should be viewable by the camera but are clipped
or outright culled are common side effects.

Plugging the right values into gluPerspective or glOrtho are outside the
scope of this list pretty significantly. Buy yourself a copy of the
OpenGL red book (ISBN: 0-201-60458-2), it’ll do you a world of good. The
bad news is that it’s a spendy little book at US$49.95, but it’s well
worth the money.

I also happen to know that certain older editions of the book can be
downloaded in HTML format and at least in one case, from where. These
HTML versions are no substitute for the real thing, however if cash is a
big issue they’re certainly better than the gross travesty of programming
that is the NeHe OpenGL tutorials. As horrible as these are, they’ve
become the reference of choice for starving students around the world,
though everyone seems to hate the damned things at least as much as I do.

The latter can be found linked from the SDL page, ported to use it. The
former can be found on Google by searching for “OpenGL red book” and being
patient. Buying the book is the preferred solution since it’s a hell of a
lot more useful than either.On Wed, Sep 19, 2001 at 04:39:00PM +0900, J Grant wrote:

I am wondering if there is an command in SDL or OpenGL that specifies
the distance at which objects are not drawn any more. My problem is I am
trying to draw an 800x600 array of items as a cube each, but my problem
is that if I do

Joseph Carter Free software developer

  • Culus thinks we should go to trade shows and see how many people we
    can kill by throwing debian cds at them

-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20010919/f10152f3/attachment-0007.pgp

Check sites like half.com, and amazon.com for used copies that are usually in
good condition if $50 is pricey…

-EvilTypeGuyOn Wed, Sep 19, 2001 at 01:21:31AM -0700, Joseph Carter wrote:

On Wed, Sep 19, 2001 at 04:39:00PM +0900, J Grant wrote:
Plugging the right values into gluPerspective or glOrtho are outside the
scope of this list pretty significantly. Buy yourself a copy of the
OpenGL red book (ISBN: 0-201-60458-2), it’ll do you a world of good. The
bad news is that it’s a spendy little book at US$49.95, but it’s well
worth the money.

glTranslatef(-50.0, -30.0, -100.0);
it is fine to see but i can not see the whole area, if i change it to
-110 etc i do not see any of my cubes from my display list.

Look-up the glOrtho command.

void glOrtho(GLdouble Left,
GLdouble Right,
GLdouble Bottom,
GLdouble Top,
GLdouble Near,
GLdouble Far)

You should have something that looks like:

glOrtho(0.0f, 640.0f, 480.0f, 0.0f, -256.0f, 1.0f);

(Please note that these values makes OpenGL simulate screen coordinates)

The alternative is:

void gluOrtho2D(GLdouble left,
GLdouble right,
GLdouble bottom,
GLdouble top)

Which is equal to

glOrtho(left,right,bottom,top,-1,1);

OpenGL does not use screen coordinates , it uses floating point values of between 0 and 1 (or -1 and 1 rather) so punching in values into glTranslate that are greater than 1 or less than -1 will result in the object being translated off the screen past a clipping plane.

If you want to use screen coordinates. Use the glOrtho command like this:
glOrtho(0.0f, screenwidth, screenheight, 0.0f, -screendepth you want, 1.0f);
But remember that this will not have an effect on all gl commands.

Read it for free here:
http://ask.ii.uib.no/ebt-bin/nph-dweb/dynaweb/SGI_Developer/OpenGL_PG/
This link is from NeHe’s OpenGL tutorial page (http://nehe.gamedev.net), a
good reference site in it’s own right.

Decide if you want to buy a copy this way!
Shawn> ----- Original Message -----

From: EvilTypeGuy [mailto:eviltypeguy@qeradiant.com]
Sent: Wednesday, September 19, 2001 9:37 AM
To: sdl at libsdl.org
Subject: Re: [SDL] disapearing objects

On Wed, Sep 19, 2001 at 01:21:31AM -0700, Joseph Carter wrote:

On Wed, Sep 19, 2001 at 04:39:00PM +0900, J Grant wrote:
Plugging the right values into gluPerspective or glOrtho are outside the
scope of this list pretty significantly. Buy yourself a copy of the
OpenGL red book (ISBN: 0-201-60458-2), it’ll do you a world of good. The
bad news is that it’s a spendy little book at US$49.95, but it’s well
worth the money.

Check sites like half.com, and amazon.com for used copies that are usually
in
good condition if $50 is pricey…

-EvilTypeGuy


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl