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