Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

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-2003 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: GlWindow.h,v $
00027  * Date modified: $Date: 2004/02/18 17:13:54 $
00028  * Version:       $Revision: 1.51 $
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/vrjConfig.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 #include <boost/concept_check.hpp>
00054 
00055 
00056 namespace vrj
00057 {
00058 
00059 class Projection;
00060 class CameraProjection;
00061 
00068 class VJ_CLASS_API GlWindow
00069 {
00070 public:
00071    GlWindow()
00072       : mVrjDisplay(NULL)
00073       , mDirtyContext(true)
00074       , mDirtyViewport(true)
00075       , in_stereo(false)
00076       , border(false)
00077       , window_is_open(false)
00078       , window_width(0)
00079       , window_height(0)
00080       , origin_x(0)
00081       , origin_y(0)
00082       // XXX: Sync problem on window id value assignment
00083       , mWindowId(getNextWindowId())
00084       , mAreEventSource(false)
00085    {
00086       // The context is always dirty when the window is first created
00087    }
00088 
00089    // Virtual destructor
00090    virtual ~GlWindow()
00091    {;}
00092 
00093 public:
00094 
00099    virtual int open()
00100    {
00101       return 1;
00102    }
00103 
00105    virtual int close()
00106    {
00107       return 1;
00108    }
00109 
00114    virtual bool makeCurrent()
00115    {
00116       return false;
00117    }
00118 
00123    virtual void configWindow(vrj::Display* displayWindow);
00124 
00130    virtual void swapBuffers()
00131    {;}
00132 
00136    virtual void checkEvents()
00137    {;}
00138 
00142    virtual void finishSetup();
00143 
00144 public:
00146    void setProjection(vrj::Projection* proj);
00147 
00152    void setLeftEyeProjection();
00153 
00158    void setRightEyeProjection();
00159 
00161    void setViewBuffer(vrj::Viewport::View view);
00162 
00174    void setViewport(float xo, float yo, float xSize, float ySize);
00175 
00177    void updateViewport();
00178 
00180    bool hasDirtyContext() const
00181    {
00182       return mDirtyContext;
00183    }
00184 
00186    void setDirtyContext(bool val=true)
00187    {
00188       mDirtyContext = val;
00189    }
00190 
00192    bool hasDirtyViewport() const
00193    {
00194       return mDirtyViewport;
00195    }
00196 
00198    void setDirtyViewport(bool val=true)
00199    {
00200       mDirtyViewport = val;
00201    }
00202 
00207    bool isOpen() const
00208    {
00209       return window_is_open;
00210    }
00211 
00216    bool isStereo() const
00217    {
00218       return in_stereo;
00219    }
00220 
00221    bool isEventSource() const
00222    {
00223       return mAreEventSource;
00224    }
00225 
00226    vrj::Display* getDisplay()
00227    {
00228       return mVrjDisplay;
00229    }
00230 
00234    int getId() const
00235    {
00236       return mWindowId;
00237    }
00238 
00239    // Called by event function to update size info
00240    // XXX: Should update Display configuration element in some way
00241    void updateOriginSize(int o_x, int o_y, int width, int height)
00242    {
00243       origin_x = o_x; origin_y = o_y;
00244       window_width = width; window_height = height;
00245 
00246       // Update the display configuration
00247       mVrjDisplay->setOriginAndSize(o_x, o_y, width, height);
00248    }
00249 
00251    void getOriginSize(unsigned& o_x, unsigned& o_y, unsigned& width,
00252                       unsigned& height) const
00253    {
00254       o_x = origin_x;
00255       o_y = origin_y;
00256       width = window_width;
00257       height = window_height;
00258    }
00259 
00260    friend std::ostream& operator<<(std::ostream& out, GlWindow& win);
00261 
00262 public:
00263    virtual bool createHardwareSwapGroup(std::vector<GlWindow*> wins)
00264    {
00265       boost::ignore_unused_variable_warning(wins);
00266       vprDEBUG(vprDBG_ALL,vprDBG_WARNING_LVL)
00267          << "WARNING: hardware swap not supported.\n" << vprDEBUG_FLUSH;
00268       return false;
00269    }
00270 
00271 protected:
00272      // we store a pointer to the display that we're
00273      // created from, to config & to get the viewing
00274      // transforms from.
00275    vrj::Display* mVrjDisplay;
00276 
00277    bool mDirtyContext;  
00278    bool mDirtyViewport; 
00284    bool in_stereo;
00285 
00286    bool border;         
00287    bool window_is_open; 
00288    int  window_width, window_height;
00289    int  origin_x, origin_y;         
00290    int  mWindowId;                  
00291    bool mAreEventSource;  
00293 private:
00294    static vpr::Mutex mWinIdMutex;
00295    static int        mCurMaxWinId;  
00297    static int getNextWindowId();
00298 };
00299 
00300 // ostream& operator<<(ostream& out, GlWindow& win);
00301 
00302 
00303 } // end namespace
00304 #endif

Generated on Sun May 2 15:10:17 2004 for VR Juggler by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002