some 3d space problems
I'm a little slow when it comes to this so please speak with small words ^_^
I've done quite a bit of OpenGL programming this summer (all 2d stuff) but as soon as I tried to add another dimension to my though the whole process kinda crapped out.
I'm writting a program that draws a box, thats it.
The problem I encounter with this damnedable box is when I try to translate the modelview. I'm trying to move it further into the screen so I can see the whole cube. But when I translate it more than -2 units into the screen, I get black and that's all. If I do -2, -1, or 0 I get one side of the cube (dimensions 2, 2, 2).
Oh I'm using glTranslatef(0.0, 0.0, -5.0) just so you know. Any help on this would be much appriciated.
what are your near and far clipping plane vales set to? it could just be that your far clip is set to some very small value so that translating your cube -2 puts it outside of the view frustum. otherwise do you have fog enabled?
-me
-me
My near and far clipping planes are set at 10 units and there isn't any fog enabled.
I think you are correct, it is a clipping problem. However, how would I fix that? I know there are a few commands to do such. Such as glFrustrum, gluPerspective and glOrtho, but I dont' know how to use them proper.
Time to go do some homework on this subject before coming back here to ask eh? Thanks for the hint.
[Edited by - asahetter on July 26, 2004 2:36:47 PM]
I think you are correct, it is a clipping problem. However, how would I fix that? I know there are a few commands to do such. Such as glFrustrum, gluPerspective and glOrtho, but I dont' know how to use them proper.
Time to go do some homework on this subject before coming back here to ask eh? Thanks for the hint.
[Edited by - asahetter on July 26, 2004 2:36:47 PM]
Quote: I know there are a few commands to do such. Such as glFrustrum, gluPerspective and glOrtho, but I dont' know how to use them proper.
Try setting the glOrtho in a changesize function, as shown here:
void changeSize(int w, int h){ if(h == 0) h = 1; float ratio = 1.0* w / h; glViewport(0, 0, w, h); // Set the viewport=entire window glMatrixMode(GL_PROJECTION); // Reset the coordinate system glLoadIdentity(); if (w <= h) glOrtho (-10.0, 10.0, -10.0*(GLfloat)h/(GLfloat)w,10.0*(GLfloat)h/(GLfloat)w, -10.0, 10.0); else glOrtho (-10.0*(GLfloat)w/(GLfloat)h,10.0*(GLfloat)w/(GLfloat)h, -10.0, 10.0, -10.0, 10.0); glutReshapeFunc(changeSize); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glutPostRedisplay();}
And remember to designate it in main/init. Play with the numbers used. And Google a function; the sourceforge definitions are quite useful.
Quote: Original post by asahetter
My near and far clipping planes are set at 10 units and there isn't any fog enabled.
You mean you have the near and far plane set at 10.0? That'll be a rather large problem right there. Use something like 1.0 and 100.0 or something to start with ( you can change it later if you like ).
If at first you don't succeed, redefine success.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement