root/juggler/branches/1.0/Kernel/vjApp.h
| Revision 11884, 6.1 kB (checked in by patrickh, 6 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_APP_ |
| 36 | #define _VJ_APP_ |
| 37 | |
| 38 | #include <vjConfig.h> |
| 39 | #include <Kernel/vjDebug.h> |
| 40 | #include <Kernel/vjConfigChunkHandler.h> |
| 41 | class vjDrawManager; |
| 42 | class vjKernel; |
| 43 | |
| 44 | //---------------------------------------------------------------- |
| 45 | //: Encapsulates the actually application. |
| 46 | // |
| 47 | // This class defines the class that all API specific |
| 48 | // application classes should be derived from. The interface |
| 49 | // given is the interface that the Kernel expects in order to |
| 50 | // interface with the application. Most of the application's |
| 51 | // interface will be defined in the derived API specific classes. |
| 52 | // |
| 53 | // Users should sub-class the API specific classes to create |
| 54 | // user-defined applications. A user application is required |
| 55 | // to provide function definitions for any of the virual functions |
| 56 | // that the application needs to use. This is the method that |
| 57 | // the application programmer uses to interface with VR Juggler. |
| 58 | // |
| 59 | // The control loop will look similar to this: <br> <br> |
| 60 | // NOTE: One time through the loop is a Juggler Frame <br> |
| 61 | // |
| 62 | // while (drawing) <br> |
| 63 | // { <br> |
| 64 | // <b>preFrame()</b>; <br> |
| 65 | // draw(); <br> |
| 66 | // <b>intraFrame()</b>; <br> |
| 67 | // sync(); <br> |
| 68 | // <b>postFrame()</b>; <br> |
| 69 | // <br> |
| 70 | // UpdateTrackers(); <br> |
| 71 | // } <br> |
| 72 | // |
| 73 | // @author Allen Bierbaum |
| 74 | // Date: 9-8-97 |
| 75 | //!PUBLIC_API: |
| 76 | //------------------------------------------------------------------ |
| 77 | class vjApp : public vjConfigChunkHandler |
| 78 | { |
| 79 | public: |
| 80 | //: Constructor |
| 81 | //! ARGS: kern - The vjKernel that is active. So application has easy access to kernel |
| 82 | vjApp(vjKernel* kern); |
| 83 | |
| 84 | // Just call vjApp(vjKernel::instance()) |
| 85 | vjApp(); |
| 86 | |
| 87 | virtual ~vjApp() |
| 88 | { |
| 89 | /* Do nothing. */ ; |
| 90 | } |
| 91 | |
| 92 | public: |
| 93 | //: Application init function |
| 94 | // Execute any initialization needed before the API is started |
| 95 | virtual void init() |
| 96 | {;} |
| 97 | |
| 98 | //: Application API init function |
| 99 | // Execute any initialization needed <b>after</b> API is started |
| 100 | // but before the drawManager starts the drawing loops. |
| 101 | virtual void apiInit() |
| 102 | {;} |
| 103 | |
| 104 | //: Execute any final cleanup needed for the application |
| 105 | virtual void exit() |
| 106 | {;} |
| 107 | |
| 108 | //: Function called before juggler frame starts. |
| 109 | // Called after tracker update but before start of a new frame |
| 110 | virtual void preFrame() |
| 111 | {;} |
| 112 | //: Function called <b>during</b> the application's drawing time |
| 113 | virtual void intraFrame() |
| 114 | {;} |
| 115 | //: Function called before updating trackers but after the frame is complete |
| 116 | virtual void postFrame() |
| 117 | {;} |
| 118 | |
| 119 | |
| 120 | //: Reset the application |
| 121 | // This is used when the system (or applications) would like the application |
| 122 | // to reset to the initial state that it started in. |
| 123 | virtual void reset() {;} |
| 124 | |
| 125 | //: Does the application currently have focus |
| 126 | // If an application has focus: |
| 127 | // - The user may be attempting to interact with it, so the app should process input |
| 128 | // If not, |
| 129 | // - The user is not interating with it, so ignore all input |
| 130 | // - BUT, the user may still be viewing it, so render and update any animations, etc. |
| 131 | // |
| 132 | // This is akin to the way a user can only interact with a GUI window that has focus |
| 133 | // (ie.The mouse is over the window) |
| 134 | bool haveFocus() { return mHaveFocus;} |
| 135 | |
| 136 | //: Called when the focus state changes |
| 137 | virtual void focusChanged() |
| 138 | {;} |
| 139 | |
| 140 | //: Sets the focus state |
| 141 | // POST: If state has changed, then calls focusChanged |
| 142 | void setFocus(bool newState) |
| 143 | { |
| 144 | if(newState != mHaveFocus) |
| 145 | { |
| 146 | mHaveFocus = newState; |
| 147 | this->focusChanged(); |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | public: // --- DEfault config handlers: (inherited from vjConfigChunkHandler) --- // |
| 152 | // Default to not handling anything |
| 153 | virtual bool configCanHandle(vjConfigChunk* chunk) |
| 154 | { return false; } |
| 155 | |
| 156 | //: Are any application dependencies satisfied |
| 157 | // If the application requires anything special of the system for successful |
| 158 | // initialization, check it here. |
| 159 | // If retval == false, then the application will not be started yet |
| 160 | // retval == true, application will be allowed to enter the system |
| 161 | virtual bool depSatisfied() |
| 162 | { return true; } |
| 163 | |
| 164 | protected: |
| 165 | //! NOTE: Inherited from vjConfigChunkHandler |
| 166 | virtual bool configAdd(vjConfigChunk* chunk) |
| 167 | { vjASSERT(false); return false; } |
| 168 | //! NOTE: INherited from vjConfigChunkHandler |
| 169 | virtual bool configRemove(vjConfigChunk* chunk) |
| 170 | { vjASSERT(false); return false; } |
| 171 | |
| 172 | public: |
| 173 | //vjAPI api; // Used to signal which API this application works with |
| 174 | vjKernel* kernel; // The library kernel (here for convienence) |
| 175 | bool mHaveFocus; |
| 176 | |
| 177 | public: // --- Factory functions --- // |
| 178 | //: Get the DrawManager to use |
| 179 | //! NOTE: Each derived app MUST implement this function |
| 180 | virtual vjDrawManager* getDrawManager() = 0; |
| 181 | }; |
| 182 | |
| 183 | #endif |
Note: See TracBrowser for help on using the browser.
