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 5 of 5

Thread: Reshape window

  1. #1
    Junior Member Regular Contributor
    Join Date
    Mar 2003
    Location
    Slovakia
    Posts
    108

    Reshape window

    i have a problem with reshape function if it is not registered with glut

    glutReshapeFunc(reshape);

    everything looks good but when it is registered the screen is showed only once and then black screen
    the code:
    void reshape ( int w, int h ) // Create The Reshape Function (the viewport)
    {
    float ratio;
    if(h == 0)
    h = 1;

    ratio = 1.0f * w / h;
    // Reset the coordinate system before modifying
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();

    // Set the viewport to be the entire window
    glViewport(0, 0, w, h);

    // Set the clipping volume
    gluPerspective(80,ratio,1,200);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    gluLookAt(0, 0, 0,
    0,0,-1,
    0.0f,1.0f,0.0f);
    }

  2. #2
    Junior Member Regular Contributor
    Join Date
    Oct 2002
    Location
    King George, Virginia
    Posts
    132

    Re: Reshape window

    try moving the glViewport() call above the glMatrixMode(GL_PROJECTION) call. i'm not sure if that is necessary, but that's how i've seen most all reshape funcs. also, make sure that there is an object to view in your scene. your view is at the origin looking down the neg. z axis, and if all your objects are behind the view, then you wont see anything. other than that, your code looks fine ...

    jebus

  3. #3
    Senior Member OpenGL Guru
    Join Date
    Jun 2000
    Location
    Gastonia, NC, USA
    Posts
    2,070

    Re: Reshape window

    What about your display code, sounds like it could be something in there causing it.
    Post the code for us to look at.

  4. #4
    Junior Member Regular Contributor
    Join Date
    Mar 2003
    Location
    Slovakia
    Posts
    108

    Re: Reshape window

    It's working now but can i have an explanation about clipping planes ? i don't actualy know what does it mean in gluPerspective and MSDN is bit short about it(english is not my native language)Thanks

  5. #5
    Senior Member OpenGL Guru
    Join Date
    Jun 2000
    Location
    Gastonia, NC, USA
    Posts
    2,070

    Re: Reshape window

    Since your english is not good and even if it is, better that you see a example with graphics on how the perspective view works.

    Nate Robins has a good tutor about projection on his site on how the perspective and ortho projections work.
    The tutor graphicly shows you how each function works and let you change each setting used by perspecitve.
    http://www.xmission.com/~nate/opengl.html


    Originally posted by Vlasko:
    It's working now but can i have an explanation about clipping planes ? i don't actualy know what does it mean in gluPerspective and MSDN is bit short about it(english is not my native language)Thanks

Posting Permissions

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