Various OpenGL questions

I was wondering about a few things:
A)
How do i set the viewdistance?
When i run NeHe´s framework,
OpenGL stops drawing objects behind a
surtain distance.
Is there any way to manipulate this?
B)
When OpenGL translate´s objects into
3D, is there anyway i can use them for
game-physics?
C)
Can i tell OpenGL to draw the viewport
to a 2D-surface?
Im thinking about makeing a editor to
my OpenGL-engine, and i wonder if i can
tell OpenGL to draw the viewport to a
2D-surface, and draw the 2D-surface in a
editor GUI (also based upon OpenGL,
not WIN32 GUI or X11 or something like
that).
D)
Does OpenGL remove objects not visible?
Do i have to do it myself?

Ill appriciate any help!

Oh and i forgot,
how do i draw point and line primitives?
I know how to draw quads and triangels,
but how do i draw points and lines?

Hi !

A - Both glOrtho and glPerspective has a near and far clipping plane that you specify, this indicates what should be vissible (distance from camera), everything in fron of near plane is clipped and also everything beyond the far plane.

B - Yes, but there is no support in OpenGL for it, you need to add some code on your own or use some library to handle it.

C - Sorry, not sure what you mean here.

D - All triangles that you send to the OpenGL pipe line is clipped if it is oustide the cameras view so you don’t “need” to do anything, with that said, many times if you have lots of geometry you can speed things up by skipping objects that are not visible yourself.

Mikael

glBegin(GL_LINES/GL_LINE_LOOP/GL_POINTS);

On your C,
What I think you want is called render to a texture.

You can render a 3D scene to a image(texture) then draw it on a 2D surface.

Without displaying the 3D scene and then the 2D surface is what you displayed.

Thanks for the help guys!

M/\dm/

Frequent Contributor
posted 03-29-2003 03:18 AM
glBegin(GL_LINES/GL_LINE_LOOP/GL_POINTS);


Line loop???
Whats a GL_LINE_LOOP?
Can you show me how to

glBegin(GL_LINES/GL_LINE_LOOP/GL_POINTS);
// What to do here?
glEnd();


nexusone
Frequent Contributor
posted 03-29-2003 05:22 AM
On your C,
What I think you want is called render to a texture.You can render a 3D scene to a image(texture) then draw it on a 2D surface.
Without displaying the 3D scene and then the 2D surface is what you displayed.

Yes!!
Thats precisly what i meant!
How do i do it?

And about removeing non-vicible objects,
i assumed that it clips away those
outside the borders of the screen,
but what about those inside the
screen- borders,
but obstructed by other object(s)?

And i forgot to say,
i code in C++.
Appriciate your help guys!

I really think you need to read the red book. I think every single living creature trying to learn OGL and graphics should start here.

Links: http://tc1.chemie.uni-bielefeld.de/doc/OpenGL/hp/OpenGL.html http://fly.srk.fer.hr/%7eunreal/theredbook/

Miguel Castillo

Let me add another link…
http://www.opengl.org/developers/code/tutorials.html

[This message has been edited by mancha (edited 03-29-2003).]

No problem that is what we are here for.

Is it best if you don’t know how to work with the opengl basics to start there before
trying to do render to texture.

Once you have some of the basic openGL stuff under your belt the other will far into place easier.

but nehe.gamedev.net will give you all the tutors on how to program from the basic openGL scene to a very advanced openGL project.

Originally posted by Whisky Bob:
And i forgot to say,
i code in C++.
Appriciate your help guys!

Hi again !

Object hidden by other objects are “rendered”, but OpenGL uses something called a depth buffer to handle this, so even though it will render an object hidden behind another one it will not put any pixels on the screen if it is 100% hidden.

That’s what I meant that you don’t need to take care of it, but when you have lots of objects you might speed things up bu doing this “clipping” on your own, but you don’t need to do it and I don’t think you should mess with it in the beginning.

There are some OpenGL books available on line, with a little luck you might find one here:
http://fly.cc.fer.hr/~unreal/theredbook/

Mikael

Mikael