changed copyright years in source files
[fegdk.git] / core / code / system / f_application.h
blob9ec352f609a2c5ae199aaba4f6b52d9a84ed0b70
1 /*
2 fegdk: FE Game Development Kit
3 Copyright (C) 2001-2008 Alexey "waker" Yakovenko
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with this library; if not, write to the Free
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 Alexey Yakovenko
20 waker@users.sourceforge.net
23 #ifndef __F_APPLICATION_H
24 #define __F_APPLICATION_H
26 #include "f_types.h"
27 #include "f_baseobject.h"
29 namespace fe
32 /**
33 * This class is used to create typical application using FEGDK.
34 * Usage is simple. Derive own class off of application,
35 * implement all methods that are needed by your app.
36 * Then create instance of an object of your new application class.
37 * Create feEngine instance. Pass pointer to your app to feEngine::run.
38 * You're done.
39 * This class may be used even for full-scale big projects,
40 * but it is not suitable for some types of applications.
41 * E.g. see how FEditor uses the feEngine providing own renderer class and own mainloop.
43 class FE_API application : public baseObject
46 protected:
48 application (void);
49 virtual ~application (void);
51 public:
53 /**
54 * This method is called just after console is created. All other systems are down yet.
55 * Application is responsible for loading all it's stuff into cvars.
56 * Default implementation just loads autoexec.cfg (it's enough for most needs).
58 virtual void configure (void);
60 /**
61 * This method is called by the engine just before mainloop starts.
62 * You can load required resources here and initialize some stuff.
63 * Most of the engine stuff is accessible at this point,
64 * but mainloop was not started yet
66 virtual void init( void );
68 /**
69 * This method is called by the engine right after mainloop exits.
70 * You can stop playing sounds/music here, and do similar stuff.
72 virtual void free( void );
74 /**
75 * Sets application name or window title or whatever.
76 * Please, notice feStr usage - it is a char/wchar mapping type, so use TCHARS instead of char or wchar_t. It is required for unicode version of the engine.
77 * @return value, which is usually will be set as the WM window title.
79 virtual const TCHAR* getTitle( void ) const;
81 /**
82 * @return relative path to directory which will be set as virtual filesystem root.
84 virtual const char* dataPath( void ) const;
85 /**
86 * You can handle keyboard keypresses here. Note: although all keycodes are listed in a single enumeration, different devices can get different codes.
87 * @param keycode contains key code (from f_keycodes.h). If OR'ed with Key_CharFlag - it is a printable character.
89 virtual void keyDown( int keycode );
91 /**
92 * You can handle key releases here
93 * @param keycode code of the released key (see application::keyDown for details)
95 virtual void keyUp( int keycode );
97 /**
98 * Mouse movement handler.
99 * Recieves absolute window-relative position of mouse pointer.
100 * @param x new horizontal position of mouse pointer
101 * @param y new vertical position of mouse pointer
103 virtual void mouseMove( int x, int y );
106 * Mouse button press handler.
107 * @param keycode code of mouse button, one of Key_Mouse1...Key_Mouse5.
109 virtual void mouseDown( int keycode );
112 * Mouse pbutton release handler.
113 * @param keycode code of mouse button, one of Key_Mouse1...Key_Mouse5.
115 virtual void mouseUp( int keycode );
117 * Mouse wheel rotation handler.
118 * @param delta amount of rotation (signed).
120 virtual void mouseWheel(int delta);
123 * Method used to update the application's behavior.
124 * Move tanks and planes, fire weapons, play sounds, etc here.
125 * No, you cannot do it in render method (it was made 'const' intentionally).
127 virtual void update( void );
130 * Method used to render the visuals.
131 * You cannot really update anything serious here, cause the method is 'const'.
132 * Use 'update' for that kind of stuff.
133 * You don't need to do funky stuff like 'SwapBuffers' or 'Present'.
134 * It is done by the engine automatically.
135 * If different behavior needed - please contact waker@users.sf.net directly.
137 virtual void render( void ) const;
143 #endif // __F_APPLICATION_H