Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Nehe's opengl tutorial and glTranslatef

  1. #1
    Member Newbie
    Join Date
    Jun 2000
    Posts
    32

    Nehe's opengl tutorial and glTranslatef

    I have been going through Nehe's opengl tutorials lately and have fully completed the first one...making my own header to simplify my commands and everything. I even used a timer to get a specific frame rate. I moved on to tutorial 2...everything seemed fine except for glTranslatef. If I don't use the translate to move some amount negativly on the z-axis I cannot see the triangle or quad. I don't understand how the glTranslatef function works. glLoadIdentity is suppose to bring you back to viewing the center of the screen... so if I drew in the triangle and quad I should be able to see them, however I can't without using glTranslatef. It works with the values Nehe used for translate, and it also works with a translation on z-axis that is negative.
    SORRY FOR THE LONG POST, I just wanted to make sure you understood what I was saying. Could someone please tell me what the glTranslatef function is suppose to do, and why I cannot see the figures without using it first. Thanks a lot!

    [This message has been edited by blide (edited 06-27-2000).]

  2. #2
    Member Contributor
    Join Date
    Feb 2000
    Location
    Breda, Netherlands
    Posts
    57

    Re: Nehe's opengl tutorial and glTranslatef

    Hi!

    glTranslate is used to move your "camera" ala viewpoint to anywhere you want. if you call glLoadIdentity() then the identity matrix is loaded and the camera is at the center of everything (0,0,0) looking at the positive z-axis (into the screen). When calling glTranslatef(0, 0, -10); the camera moves back, zooms out if you will, and all objects drawn at (x, y, -5) for example become visible.

    John

  3. #3
    Member Newbie
    Join Date
    Jun 2000
    Posts
    32

    Re: Nehe's opengl tutorial and glTranslatef

    Thanks for the help, but I still am a little confused...
    First off...according to Nehe, if you move negativly on the z-axis, your moving into the screen, not toward the viewer(positive would be "zooming out" toward the viewer)
    Second, say you were right about negative moving toward the viewer, that would mean that if I left myself at 0,0,0(no translation), that I should be able to see something drawn on the positive z-axis, however I still cannot see it.
    Third...if Nehe is right that positive is moving toward the viewer, that means that at 0,0,0 I should be able to see something on the negative z-axis, which I cannot!
    Thanks again.

    [This message has been edited by blide (edited 06-27-2000).]
    Wait, now I can see things on the negative z-axis from 0,0,0...which means Nehe was right.
    Thanks for the help!

    [This message has been edited by blide (edited 06-27-2000).]

  4. #4
    Member Newbie
    Join Date
    Jun 2000
    Posts
    32

    Re: Nehe's opengl tutorial and glTranslatef

    Ok, now I am even more confused!!!!
    When I get rid of the glTranslatef and leave myself at 0,0,0 I am able to see things on the negative z-axis which is how it should be, since negative z is away from the viewer, but when I translate negativly on the z-axis(ie glTranslatef(0,0,-10)) I start backing up, as in moving toward the viewer like positivly on the z-axis!!!! That does not make any sense to me considering that negative on the z-axis means moving into the scene and not backing up!!

  5. #5
    Senior Member Regular Contributor
    Join Date
    Mar 2000
    Location
    Aurora, Illinois, USA
    Posts
    192

    Re: Nehe's opengl tutorial and glTranslatef

    okay, z axis INTO the screen is (-), and out towards you is (+).


    so if you draw an object at (0,0,-10)
    and at (0,0,10), but you are at the center and LOOKING FORWARD!!! (make sure you have this right). You should see the object at (0,0,-10)... by the way, are you looking forward????? gluLookat()
    Navreet Gill [img]/forum/images/%%GRAEMLIN_URL%%/smile.gif[/img]

  6. #6
    Member Newbie
    Join Date
    Jun 2000
    Posts
    32

    Re: Nehe's opengl tutorial and glTranslatef

    I got that negative z-axis is into the scene and positive z is outwards toward the viewer, however when I use glTranslatef, and move on the NEGATIVE z-axis(ie glTranslatef(0,0,-10) it doesnt move me into the scene like it should, instead it moves me outward toward the viewer!!!!! can someone tell me why that is!!!!!......
    UNLESS...when you translate negativly on the z-axis it automatically turns you around which would explain why it seems like I back away and zoom out....is this the case?
    Thanks again!

  7. #7
    Member Contributor
    Join Date
    May 2000
    Location
    Ottawa, Ontario, Canada
    Posts
    75

    Re: Nehe's opengl tutorial and glTranslatef

    I don't know what the bug is but we all got the theory right. Translate negative on the z axis should move into the scene, and visa-versa. For sure a bug here in your code. Sorry not more help than that. What I do in cas like this is start over. Actually what I did was build a "test bed" that I can re-use to try out different scenarios. Might work for you.

  8. #8
    Member Contributor
    Join Date
    May 2000
    Location
    Ottawa, Ontario, Canada
    Posts
    75

    Re: Nehe's opengl tutorial and glTranslatef

    I'm also thinking that maybe you rotated or translated without using PushMatrix/PopMatrix. glTranslates are cumulative; that is they work on the current translation/rotation. Check that out.

  9. #9
    Member Contributor
    Join Date
    Feb 2000
    Location
    Breda, Netherlands
    Posts
    57

    Re: Nehe's opengl tutorial and glTranslatef

    Hi..

    Hmm. I never thought about it, but it actually seems weird. In my programs, i allways zoom out by using glTranslatef(0.0, 0.0, -10); or some value like that. So I'm not really bothered by it. IMHO: get used to it

    John

  10. #10
    Member Newbie
    Join Date
    Jun 2000
    Posts
    32

    Re: Nehe's opengl tutorial and glTranslatef

    Hehehe, looks like I confused you guys also oh well....actually from what I believe I now know why it does that...glTranslatef doesn't move you, it translates everything around you, so glTranslatef(0, 0, -10) would take every plotted vertex on screen after the command and subtract 10 from the z-value, thereby moving it farther away from me!
    Thanks for all the help anywasy hehe

Page 1 of 2 12 LastLast

Similar Threads

  1. NeHe tutorial on Bitmap Fonts (tutorial 13) error
    By Mariusz in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 02-03-2012, 09:16 AM
  2. nehe's tutorial in vs.net???
    By coolGL in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 04-05-2002, 01:40 AM
  3. ?!?! NeHe OpenGL Tutorial Les.1 ??!?!?!!
    By in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 06-20-2001, 08:21 AM
  4. NeHe Tutorial
    By Ace_Man in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 11-07-2000, 08:24 PM
  5. Who has tried Nehe's Tutorial #10? . . . .
    By Schlogenburg in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 05-29-2000, 07:10 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean