Advertisement

Rendering Far/Near

Started by December 19, 2000 05:53 PM
4 comments, last by penetrator 23 years, 11 months ago
In 3d games you can setup the rendering distance. I noticed in my projects that it renders very very near, so mountains are drawn very close from the camera eye, and that is pretty nasty to see... is there a way to tell openGL to render object more far away? Thanks
Simply glTranslatef() the mountains, or whatever (model view matrix) back a bit.

glTranslatef(0.0f, 0.0f, -20.0f);

This will translate the scene 20 units "deeper" into the monitor.

______________Martin EstevaolpSoftware
Advertisement
you might want to do a double pass on the drawgl function to do something like this...

1) call glClear
2) call ReSizeGLScene with near far set to 10, 1000
3) call glLoadIdentity
4) call the function to draw the distant objects (mountains terrain ect...)
5) call ReSizeGLScene with the near far set to 0.1, 10
6) call glLoadIdentity
7) call the function to draw the local area (the ground your about to crash into, the building you just nuked, etc...)
8) call SwapBuffers

I''m doing this in a program I''m currently working on but I actually have 4 layers of resize and draw.
------------------------------Piggies, I need more piggies![pig][pig][pig][pig][pig][pig]------------------------------Do not invoke the wrath of the Irken elite. [flaming]
Resizing all the time sounds abit dodgy to me. I would just make everything to scale.

You could decide what units you''re going to use in the game, say centimetres, then measure the distance from the monitor to your eye (using a 90 degree FOV), and make the models the right size in centimetres.

It''s been working out okay for me so far.

- Peter
It has had an unmesurable performance hit for me! As for the useing one scale idea...
Drawing a terrain that''s 100mi away and a plate on a table 2 feet away if your scale was in feet then you''d have near/far planes like 0.1 (1 inch) / 528000 (100mi)
This causes problem with the depth buffer not being able to keep a good resolution!
------------------------------Piggies, I need more piggies![pig][pig][pig][pig][pig][pig]------------------------------Do not invoke the wrath of the Irken elite. [flaming]
I just realized that I had forgot that between each drawing pass you need to call glClear(GL_DEPTH_BUFFER_BITS);
------------------------------Piggies, I need more piggies![pig][pig][pig][pig][pig][pig]------------------------------Do not invoke the wrath of the Irken elite. [flaming]

This topic is closed to new replies.

Advertisement