Disgusting mistakes...

Started by
7 comments, last by Jacob84 20 years, 8 months ago
Hi everybody (First post over the OGL forum ) : Maybe this question is almost stupid, i don''t know, it''s probably a problem of concepts ''bout 3D, but at the moment I can''t find the answer. The problem appears when using space 3D management functions, like glTranslatef , for example, but after testing some things i don''t know if the problem is over the coordinates system (Is this possible???). The most disgusting aspect, is to me , that the problem appears even if I use examples , that you can find over webs (NeHe) or books (Programming over OpenGL). for example (Very simple) -> void Render(void){ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glTranslatef(-1.5f,0.0f,-6.0f); glBegin(GL_TRIANGLES); // Code of triangle here glEnd(); } Here glTranslatef moves the scene 1.5 units left, and 6 into the screen. Well, if I use this, the window appears black. But, if I use glTranslatef(0.0f,0.0f,0.0f) appears correctly. If I try to translate the scene 1 unit into the window appears ok, but if I try -1.1f appears black. It seems like the coordinates used in the NeHe example doesn''t work in my system!!! Thanks for reading, Jacob.
?J@cob=========================Computer Science Studentjacobmendozap@hotmail.com
Advertisement
if not stated otherwise glTranslatef(x,y,z); affects the current modelview matrix as in rewrites elements 12,13,14 with those supplied by you.The problem is that the projection plane is set "in front" of your triangle , try glTranslate-ing after drawing the triangle.
"If I try to translate the scene 1 unit into the window appears ok, but if I try -1.1f appears black."

then i would first check the near and far planes you set.
f@dzhttp://festini.device-zero.de
How are you drawing your triangle (i.e. what coords are you using) and how have you set up your projection matrix?

Yes i''d say its probably the near / far clipping planes. Strange that you even get an image with no translation, unless you''re coordinates have substantial negative z values.

~SPH

AIM ME: aGaBoOgAmOnGeR
or probably it''s just that he is in Projection-Matrix-Mode, and there coordinates are given INVERSED.
glMatrixMode(GL_PROJECTION);
glTranslatef(0.0f, 0.0f, -6.0f);
will translate towards the viewer.

the other posibility is that __they__ uses this:
glOrtho(-1, 1, -1, 1, -1, 1);
so you can only see things with -1 < x < 1; -1 < y < 1; -1 < z < 1 (homogenous space).
if you are in PROJECTION-matrix-mode and you reset it with glLoadIdentity() you should allways rebuild the projection-matrix via glOrtho or glFrustum/gluPerspective. Look into your tutorials for that.

to test in which matrixmode you are you can use
int i;
glGetIntegerv(GL_MATRIX_MODE, &i);
if( i == GL_MODELVIEW )
/*you are in modelview mode*/
else
/* you are in projection mode */


our new version has many new and good features. sadly, the good ones are not new and the new ones are not good
Hi, and first I'm sorry, I've had a 'delay', so thanks everybody for posting. Some problems have been solved.

I have been trying to set up my concepts, and I've questions ... Let's see a bit of functions ->

glViewport(0,0,width,height);

This function, sets the "space" where OpenGL can write. The two initial zeros sets where OpenGL starts the view???.

gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.0f,100.0f);

Ok, this is easier ... the first are the vision & direction degrees. Then width/height sets the aspect ratio. The last values sets the max planes (near/far). Question , using gluPerspective, if we're over a window of 640x480 (640/480 = 1,33), Is -1.33 to 1.33 the maxium line that we can draw over the X axis?

And, the last question. For those who have read till this point my congratulations . Thats a strange effect. If I create a window (800,600 f.e), and set a text that is just in the corner of the window (That's the desired effect), if I resize the window (1024,768 in window) that texts moves a bit down in the window. Why?

I hope everybody understands me...and ... thanks for reading, always.

Greetings,
Jacob.

[edited by - jacob84 on July 30, 2003 5:06:39 PM]
?J@cob=========================Computer Science Studentjacobmendozap@hotmail.com
gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.0f,100.0f);                                                     ^                                                     |                                                   wrong

The near clip plane must be positive.
that''s because the viewport needs to be resetuped every time the window changes it''s size. the aspect ratio needs to be positive because it is a relation between the top and the right plane.
the distance to the near plane needs to be a nonzero value because you divide through it while z-testing.
our new version has many new and good features. sadly, the good ones are not new and the new ones are not good

This topic is closed to new replies.

Advertisement