root/juggler/tags/1.0.5/Kernel/vjDisplay.h

Revision 7539, 5.6 kB (checked in by anonymous, 7 years ago)

This commit was manufactured by cvs2svn to create tag
'RELENG_1_0_5_RELEASE'.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 /*************** <auto-copyright.pl BEGIN do not edit this line> **************
2  *
3  * VR Juggler is (C) Copyright 1998, 1999, 2000 by Iowa State University
4  *
5  * Original Authors:
6  *   Allen Bierbaum, Christopher Just,
7  *   Patrick Hartling, Kevin Meinert,
8  *   Carolina Cruz-Neira, Albert Baker
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Library General Public
12  * License as published by the Free Software Foundation; either
13  * version 2 of the License, or (at your option) any later version.
14  *
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  * Library General Public License for more details.
19  *
20  * You should have received a copy of the GNU Library General Public
21  * License along with this library; if not, write to the
22  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23  * Boston, MA 02111-1307, USA.
24  *
25  * -----------------------------------------------------------------
26  * File:          $RCSfile$
27  * Date modified: $Date$
28  * Version:       $Revision$
29  * -----------------------------------------------------------------
30  *
31  *************** <auto-copyright.pl END do not edit this line> ***************/
32
33
34 #ifndef _VJ_DISPLAY_H_
35 #define _VJ_DISPLAY_H_
36
37 #include <vjConfig.h>
38
39 #include <Math/vjVec3.h>
40 #include <Input/vjPosition/vjPosition.h>
41 #include <Input/InputManager/vjPosInterface.h>
42 #include <Kernel/vjUser.h>
43 #include <Performance/vjPerfDataBuffer.h>
44 #include <Environment/vjEnvironmentManager.h>
45 #include <Kernel/vjKernel.h>
46
47     // Config stuff
48 #include <Config/vjConfigChunkDB.h>
49
50 //---------------------------------------------------------------------
51 //: Base class for Display windows.
52 //
53 // Base class for all window system independant data about a display.
54 //
55 // Stores location of window and projection data used.
56 //
57 // @author Allen Bierbaum
58 //  Date: 9-8-97
59 //-----------------------------------------------------------------------
60 class vjDisplay
61 {
62 public:
63    vjDisplay() : mUser(NULL), mDisplayChunk(NULL)
64    {
65       _xo = _yo = _xs = _ys = -1;
66       mType = vjDisplay::UNDEFINED;
67       mDisplayChunk = NULL;
68       mPipe = vjDisplay::NONE;
69       mLatencyMeasure = NULL;
70    }
71
72    virtual ~vjDisplay() {
73        if (mLatencyMeasure) {
74            vjKernel::instance()->getEnvironmentManager()->removePerfDataBuffer (mLatencyMeasure);
75
76        }
77    }
78
79
80     // i'm probably gonna regret this
81     void recordLatency (int trackertimeindex, int currenttimeindex) {
82         mLatencyMeasure->set (trackertimeindex, *(mUser->getHeadUpdateTime()));
83         mLatencyMeasure->set (currenttimeindex);
84     }
85
86
87    enum DisplayType { UNDEFINED, SURFACE, SIM};             // What type of display is it
88    enum DisplayView { NONE=0, LEFT_EYE=1, RIGHT_EYE=2, STEREO=3 };      // For referring to which eye(s) to draw
89
90 public:
91       //: Takes a display chunk and configures the display based one it.
92       //! PRE: chunk is a valid chunk
93       //! POST: display is configured
94       //+       If there is an error is the specified config, we output error
95       //+       and "fix" the error.
96       //! NOTE: All derived display classes MUST call this function
97       //+       after doing local configuration.
98    virtual void config(vjConfigChunk* chunk);
99
100    //: Updates the projection data for this display
101    // Uses the data for the head position for this window
102    virtual void updateProjections() = 0;
103
104 public:
105    DisplayType getType()
106    { return mType;}
107
108    bool isSimulator()
109    { return (mType == SIM); }
110
111    bool isSurface()
112    { return (mType == SURFACE); }
113
114    bool isActive()
115    { return mActive; }
116
117    void setName(std::string name)
118    { mName = name; }
119
120    //: Get the name of the display
121    std::string getName()
122    { return mName;}
123
124    bool  shouldDrawBorder()
125    { return mBorder;}
126
127    //!NOTE: If we are in simulator, we can not be in stereo
128    bool inStereo()
129    { return (mView == STEREO); }
130
131    // Which view are we supposed to render
132    DisplayView getView()
133    { return mView; }
134
135    void setOriginAndSize(int xo, int yo, int xs, int ys)
136    { _xo = xo; _yo = yo; _xs = xs; _ys = ys;}
137    void getOriginAndSize(int& xo, int& yo, int& xs, int& ys)
138    {
139       vjASSERT(xo != -1);     // Make sure we have been configured
140       xo = _xo; yo = _yo; xs = _xs; ys = _ys;
141    }
142
143    void setPipe(int pipe)
144    { mPipe = pipe; }
145    int getPipe()
146    { return mPipe; }
147
148    //: Get the config chunk that configured this display
149    vjConfigChunk* getConfigChunk()
150    { return mDisplayChunk; }
151
152    //: Get the user associated with this display
153    vjUser*  getUser()
154    { return mUser;}
155
156    virtual std::ostream& outStream(std::ostream& out);
157    friend std::ostream& operator<<(std::ostream& out, vjDisplay& disp);
158
159 protected:
160    vjUser*           mUser;         //: The user being rendered by this window
161
162 protected:
163    DisplayType mType;                  //: The type of display
164    std::string mName;                  //: Name of the display
165    int         _xo, _yo, _xs, _ys;     //: X and Y origin and size of the view
166    bool        mBorder;                //: Should we have a border
167    int         mPipe;                  //: Hardware pipe. Index of the rendering hardware
168    bool        mActive;                //: Is the display active or not
169    DisplayView  mView;                 //: Which buffer(s) to display (left, right, stereo)
170
171    vjConfigChunk* mDisplayChunk;        //: The chunk data for this display
172
173     vjPerfDataBuffer *mLatencyMeasure;   //: measures of user tracking latency
174
175 };
176
177 //std::ostream& operator<<(std::ostream& out, vjDisplay* disp);
178
179 #endif
Note: See TracBrowser for help on using the browser.