Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: How to use glFrustumf?

  1. #1
    Intern Newbie anime.igala.net's Avatar
    Join Date
    Jul 2008
    Location
    France
    Posts
    32

    How to use glFrustumf?

    Hello all,

    I would like to make my scene always "fit to screen", I mean my scene is as big as possible but the user always can see my entire scene.

    I don't know how to use glFrustumf to do this.

    Thanks all,
    Relax in break time: http://igala.net
    Android Core http://androidcore.com

  2. #2
    Senior Member OpenGL Guru knackered's Avatar
    Join Date
    Aug 2001
    Location
    UK
    Posts
    2,833

    Re: How to use glFrustumf?

    it's in the wiki, which is referenced at the top of every single forum.
    http://www.opengl.org/wiki/index.php/Vie...d_up_vector..29
    Knackered

  3. #3
    Intern Newbie anime.igala.net's Avatar
    Join Date
    Jul 2008
    Location
    France
    Posts
    32

    Re: How to use glFrustumf?

    please see this thread: http://www.opengl.org/discussion_boards/...0949#Post240949


    I have tried this, but i cannot see anything on the screen. My current code is:

    Code :
    glClearColor        (0.f,0.f,0.f,1.f);
    glMatrixMode        (GL_PROJECTION);
    glFrustumf (-100.f,1000.f,-1000.f,500.f,3.f,300.f);
    glMatrixMode        (GL_MODELVIEW);
    glShadeModel        (GL_SMOOTH);
    glTranslatef            (-1400.f, 1000.f, -3.f);
    glScalef(2.0, 2.0, 2.0);
    glColor4f(0,1,0,1);
     
    DrawScene();




    The code that i CANNOT see anything on the screen:



    Code :
    glClearColor        (0.f,0.f,0.f,1.f);
     
    	float diam = 1000;
    	float zNear = 3.f;
    	float zFar = zNear + diam;
     
    	int cx = 0, cy = 0;
     
    	float left = cx - diam;
    	float right = cx + diam;
    	float bottom = cy - diam;
    	float top = cy + diam;
     
    	glMatrixMode(GL_PROJECTION);
    	glLoadIdentity();
     
    	float aspect = (float) iScreenWidth / iScreenHeight;
     
    	if ( aspect < 1.0 ) { // window taller than wide
    		bottom /= aspect;
    		top /= aspect;
    	} else {
    		left *= aspect;
    		right *= aspect;
    	}	
     
    	//glOrtho(left, right, bottom, top, zNear, zFar);
    	glOrthof(left, right, bottom, top, zNear, zFar);
    	glMatrixMode(GL_MODELVIEW);
    	glLoadIdentity();
     
    	glColor4f(0,1,0,1);
    Relax in break time: http://igala.net
    Android Core http://androidcore.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •