Results 1 to 5 of 5

Thread: gluLookAt strange behavior

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2009
    Posts
    2

    gluLookAt strange behavior

    I am making a platform game in the glOrtho projection, and when i use gluLookAt, the image is seen well, but when i move it, the glu look at doesent move, instead it just makes part of my game screen black, it cuts it off.

    The thing i want to accomplish is the camera GluLookat always looking at my player.

    this is the code

    //SCREEN_WIDTH=1024 and SCREEN_HEIGHT=768
    Code :
    bool init_GL()
    {	
    	glClearColor( 0, 0, 0, 0 );
     
    	glMatrixMode( GL_PROJECTION );
    	glLoadIdentity();
    	glOrtho( 0, SCREEN_WIDTH, 0, SCREEN_HEIGHT, -1, 1 );
     
    	glMatrixMode( GL_MODELVIEW );
    	glLoadIdentity();
     
    	gluLookAt(0,0,0,0,0,-1,0,1,0);




    now, the last line of code is gluLookAt, and only with these parameters gluLookAt(0,0,0,0,0,-1,0,1,0);

    does the whole screen show, when I, for instance change the reference point

    gluLookAt(0,0,0,200,200,-1,0,1,0);

    it doesent show anything just a black screen, and when i do something like this

    gluLookAt(0.003,0,0,0,0,-1,0,1,0);

    than it cuts my viewport in half, and i only see half of my game, the other half is black.

  2. #2
    Senior Member Regular Contributor trinitrotoluene's Avatar
    Join Date
    Sep 2008
    Location
    Montérégie,Québec
    Posts
    362

    Re: gluLookAt strange behavior

    now, the last line of code is gluLookAt, and only with these parameters gluLookAt(0,0,0,0,0,-1,0,1,0);

    does the whole screen show, when I, for instance change the reference point

    gluLookAt(0,0,0,200,200,-1,0,1,0);

    it doesent show anything just a black screen,
    This is normal, you have changed your view vector too much: from (0,0,-1) to (0.7071,0.7071,-0.0035). So at the eye position (0,0,0) with view vector (0.7071,0.7071,-0.0035) there is no object to see.

    and when i do something like this

    gluLookAt(0.003,0,0,0,0,-1,0,1,0);

    than it cuts my viewport in half, and i only see half of my game, the other half is black.
    I will make a guess here, maybe your object are clipped by the near or the far clipping plane if you draw them with z coordinate equal -1 (near) or 1 (far) which are the limit you give for glOrtho.


    See gluLookAt documentation for more information.

  3. #3
    Junior Member Newbie glavatar's Avatar
    Join Date
    Mar 2008
    Posts
    5

    Re: gluLookAt strange behavior

    You should try to change the camera orientation:

    gluLookAt(0,0,-1, 0,0,0, 0,1,0);

    This moves the eyes backward and looks to the axis origin.

    Best regards.
    OpenGL surrounds me.

  4. #4
    Junior Member Newbie
    Join Date
    Jan 2009
    Posts
    2

    Re: gluLookAt strange behavior

    I tried expanding the near and far clipping but the results were even more confusing, everytingh was larger and the clipping was still there.

    this code
    Code :
    bool init_GL()
    {	
    	glClearColor( 0, 0, 0, 0 );
     
    	glMatrixMode( GL_PROJECTION );
    	glLoadIdentity();
    	glOrtho( 0, SCREEN_WIDTH, 0, SCREEN_HEIGHT, 0, 0 );
     
     
     
    	glMatrixMode( GL_MODELVIEW );
    	glLoadIdentity();
     
    	gluLookAt(0,0,0,0,0,1,0,-1,0);


    Is at the beggining of each main loop, so that in the future maybe i can update the camera to folow my player through the level.

  5. #5
    Senior Member OpenGL Pro dletozeun's Avatar
    Join Date
    Jan 2006
    Location
    FRANCE
    Posts
    1,367

    Re: gluLookAt strange behavior

    Please, provide the full code and necessary data so we can check by ourself. It is difficult to help you without the whole source code in this kind of situation.

Similar Threads

  1. undefined behavior and gluLookAt()
    By akashiraffee in forum OpenGL: Basic Coding
    Replies: 7
    Last Post: 04-23-2009, 12:22 PM
  2. Replies: 6
    Last Post: 05-24-2005, 08:13 AM
  3. Strange CDialog behavior
    By brightbird in forum OpenGL: Windows
    Replies: 0
    Last Post: 03-29-2005, 09:51 AM
  4. Strange fps behavior...
    By Catman in forum OpenGL: Advanced Coding
    Replies: 7
    Last Post: 01-14-2003, 05:06 AM
  5. strange behavior
    By SirKnight in forum OpenGL: Advanced Coding
    Replies: 8
    Last Post: 01-03-2002, 12:34 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