openal and fontft memleak fixes from keltar
[fegdk.git] / core / code / system / f_application.h
blob1f2b00d35681e7657c538a70c75e4d84743465ad
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 * @return value, which is usually will be set as the WM window title.
78 virtual const char* getTitle( void ) const;
80 /**
81 * @return relative path to directory which will be set as virtual filesystem root.
83 virtual const char* dataPath( void ) const;
84 /**
85 * You can handle keyboard keypresses here. Note: although all keycodes are listed in a single enumeration, different devices can get different codes.
86 * @param keycode contains key code (from f_keycodes.h). If OR'ed with Key_CharFlag - it is a printable character.
88 virtual void keyDown( int keycode );
90 /**
91 * You can handle key releases here
92 * @param keycode code of the released key (see application::keyDown for details)
94 virtual void keyUp( int keycode );
96 /**
97 * Mouse movement handler.
98 * Recieves absolute window-relative position of mouse pointer.
99 * @param x new horizontal position of mouse pointer
100 * @param y new vertical position of mouse pointer
102 virtual void mouseMove( int x, int y );
105 * Mouse button press handler.
106 * @param keycode code of mouse button, one of Key_Mouse1...Key_Mouse5.
108 virtual void mouseDown( int keycode );
111 * Mouse pbutton release handler.
112 * @param keycode code of mouse button, one of Key_Mouse1...Key_Mouse5.
114 virtual void mouseUp( int keycode );
116 * Mouse wheel rotation handler.
117 * @param delta amount of rotation (signed).
119 virtual void mouseWheel(int delta);
122 * Method used to update the application's behavior.
123 * Move tanks and planes, fire weapons, play sounds, etc here.
124 * No, you cannot do it in render method (it was made 'const' intentionally).
126 virtual void update( void );
129 * Method used to render the visuals.
130 * You cannot really update anything serious here, cause the method is 'const'.
131 * Use 'update' for that kind of stuff.
132 * You don't need to do funky stuff like 'SwapBuffers' or 'Present'.
133 * It is done by the engine automatically.
134 * If different behavior needed - please contact waker@users.sf.net directly.
136 virtual void render( void ) const;
142 #endif // __F_APPLICATION_H