Results 1 to 5 of 5

Thread: changing viewport at each frame is bad ?

  1. #1

    changing viewport at each frame is bad ?

    Hi, is it bad to change the viewport and call gluPerspective at each frame ?
    Is it too consuming or i can do that ?

    thanks
    If you save your data in a proprietary format, the owner of the format owns your data.
    <br /><A href="http://msx80.blogspot.com">http://msx80.blogspot.com</A>

  2. #2

    changing viewport at each frame is bad ?

    I don't think it's too consuming but I guess you better use glRotate and glTranslate functions if possible.

  3. #3

    changing viewport at each frame is bad ?

    Premature optimisation is the root of all evil, really. Theres a ton of stuff that you are probablly doing thausands of times per frame and that is worth optimiseing, stuff you do only once per frame isn't. gluPerspective does some multiplications, some divisions and a matrix multiply, you're likelly doing this kind of stuff for every model yourself.

  4. #4

    changing viewport at each frame is bad ?

    Quote Originally Posted by Paulius
    Premature optimisation is the root of all evil, really. Theres a ton of stuff that you are probablly doing thausands of times per frame and that is worth optimiseing, stuff you do only once per frame isn't. gluPerspective does some multiplications, some divisions and a matrix multiply, you're likelly doing this kind of stuff for every model yourself.
    This is a great true
    Thanks paulius!
    If you save your data in a proprietary format, the owner of the format owns your data.
    <br /><A href="http://msx80.blogspot.com">http://msx80.blogspot.com</A>

  5. #5

    changing viewport at each frame is bad ?

    What I have done, and what we do in our commercial game engine, is to store the matrix and only recalculate it if something changed. To avoid recalculating on every change though, we just set a flag that lets us know the matrix is "dirty" and needs to be recalculated.

    Say we change the camera position. We set the vector describing the camera position and set a dirty flag. The next time the scene is drawn, we check the dirty flag. Because it is set, we recalculate the projection matrix, use it, and store it. Next frame, if the camera didn't move, we just use the stored matrix.

    We do this for our views, our models, animations, everything that can be stored and re-used without having to recalculate the same thing over and over if nothing changed.

Bookmarks

Posting Permissions

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