GlWindow.h

Go to the documentation of this file.
00001 /*************** <auto-copyright.pl BEGIN do not edit this line> **************
00002  *
00003  * VR Juggler is (C) Copyright 1998-2005 by Iowa State University
00004  *
00005  * Original Authors:
00006  *   Allen Bierbaum, Christopher Just,
00007  *   Patrick Hartling, Kevin Meinert,
00008  *   Carolina Cruz-Neira, Albert Baker
00009  *
00010  * This library is free software; you can redistribute it and/or
00011  * modify it under the terms of the GNU Library General Public
00012  * License as published by the Free Software Foundation; either
00013  * version 2 of the License, or (at your option) any later version.
00014  *
00015  * This library is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  * Library General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU Library General Public
00021  * License along with this library; if not, write to the
00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00023  * Boston, MA 02111-1307, USA.
00024  *
00025  * -----------------------------------------------------------------
00026  * File:          $RCSfile$
00027  * Date modified: $Date: 2006-07-12 17:21:40 -0500 (Wed, 12 Jul 2006) $
00028  * Version:       $Revision: 19032 $
00029  * -----------------------------------------------------------------
00030  *
00031  *************** <auto-copyright.pl END do not edit this line> ***************/
00032 
00033 #ifndef _VJ_GL_WINDOW_H_
00034 #define _VJ_GL_WINDOW_H_
00035 
00036 #include <vrj/Draw/OGL/Config.h>
00037 #include <vector>
00038 
00039 #include <stdio.h>
00040 #include <vpr/vpr.h>
00041 
00042 #ifdef VPR_OS_Darwin
00043 #   include <OpenGL/gl.h>
00044 #else
00045 #   include <GL/gl.h>
00046 #endif
00047 
00048 #include <vrj/Display/Display.h>
00049 #include <vrj/Display/Viewport.h>
00050 
00051 #include <vpr/Util/Debug.h>
00052 
00053 
00054 namespace vrj
00055 {
00056 
00057 class Projection;
00058 class CameraProjection;
00059 
00066 class VJ_OGL_CLASS_API GlWindow
00067 {
00068 public:
00069    GlWindow()
00070       : mVrjDisplay(NULL)
00071       , mSwapCount(0)
00072       // The context is always dirty when the window is first created
00073       , mDirtyContext(true)
00074       , mDirtyViewport(true)
00075       , mInStereo(false)
00076       , mHasBorder(false)
00077       , mHideMouse(false)
00078       , mWindowIsOpen(false)
00079       , mWindowWidth(0)
00080       , mWindowHeight(0)
00081       , mOriginX(0)
00082       , mOriginY(0)
00083       // XXX: Sync problem on window id value assignment
00084       , mWindowId(getNextWindowId())
00085       , mIsEventSource(false)
00086    {
00087       /* Do nothing. */ ;
00088    }
00089 
00091    virtual ~GlWindow()
00092    {
00093       /* Do nothing. */ ;
00094    }
00095 
00096 public:
00097 
00102    virtual bool open()
00103    {
00104       return 1;
00105    }
00106 
00108    virtual bool close()
00109    {
00110       return 1;
00111    }
00112 
00117    virtual bool makeCurrent()
00118    {
00119       return false;
00120    }
00121 
00126    virtual void configWindow(vrj::Display* displayWindow);
00127 
00133    virtual void swapBuffers();
00134 
00138    virtual void checkEvents()
00139    {;}
00140 
00145    virtual void finishSetup();
00146 
00147 public:
00149    void setProjection(vrj::Projection* proj);
00150 
00155    void setLeftEyeProjection();
00156 
00161    void setRightEyeProjection();
00162 
00164    void setViewBuffer(vrj::Viewport::View view);
00165 
00177    void setViewport(float xo, float yo, float xSize, float ySize);
00178 
00180    void updateViewport();
00181 
00183    bool hasDirtyContext() const
00184    {
00185       return mDirtyContext;
00186    }
00187 
00189    void setDirtyContext(bool val=true)
00190    {
00191       mDirtyContext = val;
00192    }
00193 
00195    bool hasDirtyViewport() const
00196    {
00197       return mDirtyViewport;
00198    }
00199 
00201    void setDirtyViewport(bool val=true)
00202    {
00203       mDirtyViewport = val;
00204    }
00205 
00210    bool isOpen() const
00211    {
00212       return mWindowIsOpen;
00213    }
00214 
00219    bool isStereo() const
00220    {
00221       return mInStereo;
00222    }
00223 
00224    bool isEventSource() const
00225    {
00226       return mIsEventSource;
00227    }
00228 
00229    vrj::Display* getDisplay()
00230    {
00231       return mVrjDisplay;
00232    }
00233 
00237    int getId() const
00238    {
00239       return mWindowId;
00240    }
00241 
00243    // XXX: Should update Display configuration element in some way.
00244    void updateOriginSize(const int originX, const int originY, const int width,
00245                          const int height)
00246    {
00247       mOriginX      = originX;
00248       mOriginY      = originY;
00249       mWindowWidth  = width;
00250       mWindowHeight = height;
00251 
00252       // Update the display configuration
00253       mVrjDisplay->setOriginAndSize(originX, originY, width, height);
00254    }
00255 
00257    void getOriginSize(int& originX, int& originY, int& width,
00258                       int& height) const
00259    {
00260       originX = mOriginX;
00261       originY = mOriginY;
00262       width   = mWindowWidth;
00263       height  = mWindowHeight;
00264    }
00265 
00266    vpr::Uint64 getSwapCount()
00267    {
00268       return mSwapCount;
00269    }
00270 
00271    friend std::ostream& operator<<(std::ostream& out, GlWindow& win);
00272 
00273 protected:
00278    vrj::Display* mVrjDisplay;
00279 
00280    vpr::Uint64 mSwapCount; 
00282    bool mDirtyContext;  
00283    bool mDirtyViewport; 
00289    bool mInStereo;
00290 
00291    bool mHasBorder;     
00292    bool mHideMouse;     
00293    bool mWindowIsOpen;  
00294    int  mWindowWidth;
00295    int  mWindowHeight;
00296    int  mOriginX;       
00297    int  mOriginY;       
00298    int  mWindowId;      
00299    bool mIsEventSource; 
00301 private:
00302    static vpr::Mutex mWinIdMutex;
00303    static int        mCurMaxWinId;  
00305    static int getNextWindowId();
00306 };
00307 
00308 // ostream& operator<<(ostream& out, GlWindow& win);
00309 
00310 } // end namespace
00311 
00312 #endif

Generated on Thu Jan 4 10:56:51 2007 for VR Juggler by  doxygen 1.5.1