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
20 waker@users.sourceforge.net
27 #include "f_baseobject.h"
29 #include "f_helpers.h"
44 #ifndef SOUND_DISABLED
45 class baseSoundDriver
;
63 extern cvar_t
*sys_int_mainloop
;
64 extern cvar_t
*sys_profile
;
65 extern cvar_t
*sys_mainscript
;
66 extern cvar_t
*sys_debug_freetype
;
67 extern cvar_t
*sys_stack_size
;
69 class FE_API engine
: public baseObject
75 * Specifies size of buffer returned by tmpBuffer
76 * FIXME: should be set by configure script
78 enum { default_tmpbuffer_size
= 65536 };
81 smartPtr
<baseRenderer
> mpRenderer
;
82 smartPtr
<baseViewport
> mpViewport
;
83 smartPtr
<fileSystem
> mpFileSystem
;
84 smartPtr
<inputDevice
> mpInputDevice
;
85 smartPtr
<application
> mpApp
;
86 smartPtr
<logger
> mpLogger
;
87 smartPtr
<timer
> mpTimer
;
88 smartPtr
<console
> mpConsole
;
89 smartPtr
<effectParms
> mpEffectParms
;
90 smartPtr
<parmMgr
> mpParmMgr
;
91 #ifndef SOUND_DISABLED
92 smartPtr
<baseSoundDriver
> mpSoundDriver
;
94 smartPtr
<resourceMgr
> mpResourceMgr
;
95 smartPtr
<drawUtil
> mpDrawUtil
;
96 smartPtr
<rBackend
> mpRBackend
;
97 smartPtr
<sceneManager
> mpSceneManager
;
98 smartPtr
<keyBinder
> mpKeyBinder
;
99 smartPtr
<script
> mpScript
;
100 smartPtr
<entityManager
> mpEntManager
;
101 smartPtr
<metaShader
> mpMetaShader
;
102 smartPtr
<fontFT
> mpSysFont
;
103 smartPtr
<animSequencer
> mpAnimSequencer
;
104 smartPtr
<stackAllocator
> mpStackAllocator
;
105 smartPtr
<cvarManager
> mpCVarManager
;
107 // initializes subsystems which are *shared* between all engine usage patterns
108 // i mean different 'run' methods
109 void sharedInit (void);
110 void initResourceMgr (void);
112 // platform-specific stuff
113 void mainLoop (void);
114 void beginScene (void);
115 void endScene (void);
123 * Use this one if your application has own renderer/mainloop (e.g. FEditor uses this scheme).
124 * Be aware that this method is gonna be abandoned someday, cause it causes compatibility problems.
125 * @param renderer pointer to a renderer object
126 * @param dataPath VFS root
128 void run (const smartPtr
<baseRenderer
> &renderer
, const char *dataPath
= "./");
131 * Use this if u wanna use internal renderer/mainloop (see feApplication for reference and usage tutorial)
132 * @param app pointer to application object
134 void run (const smartPtr
<application
> &app
, int argc
, char *argv
[]);
136 // TODO: do 2 more 'run' methods -- internal renderer vs own mainloop; internal mainloop vs own renderer
139 * This can be used to close application by user choice
140 * console 'quit' command uses this
145 * Normal engine tick, performs usual stuff -- update states, render stuff, etc
146 * Shouldn't it be private? :-/
151 * Use that if u need to emulate keydown event
153 void keyDown (int code
);
156 * Use that when ur gonna emulate keyup event
158 void keyUp (int code
);
161 * @return application pointer.
162 * \deprecated Some subsystems used this to check renderer requirements, etc. It is now controlled through cvars.
164 application
* getApplication (void) const;
168 * You don't gonna need one in usual portable application.
169 * You may use it to query supported vidmodes, renderer info, etc.
170 * @return renderer pointer.
172 baseRenderer
* getRenderer (void) const;
174 #ifndef SOUND_DISABLED
176 * @return sound mixer object pointer
178 smartPtr
<baseSoundDriver
> getSoundDriver (void) const;
182 * @return the main filesystem object used by the engine to load resources
184 fileSystem
* getFileSystem (void) const;
187 * @return current viewport. can be NULL if u want it that way.
189 baseViewport
* getViewport (void) const;
192 * Changes current viewport. Used mostly in FEditor.
193 * @param vp new current viewport object pointer
195 void setViewport (baseViewport
* vp
);
198 * @return input system object
200 inputDevice
* getInputDevice (void) const;
203 * Faster than any malloc, but must be used carefully, since many internal routines use it as a temporary storage.
204 * It is constant storage, so it is NOT THREAD-SAFE and risky even in single-threaded environment.
205 * @param sz size of buffer required
206 * @return temporary sysmem buffer of requested size if it is less than default_tmpbuffer_size, or NULL otherwise
208 ubyte
* getTmpBuffer (int sz
) const;
211 * @return logger object ptr
213 logger
* getLogger (void);
216 * @return main system timer, used to sync everything in the game
218 timer
* getTimer (void) const;
221 * Should be available always, even if not visible/renderable (even in non-graphical apps, such as 'fgp').
222 * @return console object pointer.
224 console
* getConsole (void);
227 * @return effect file parameter manager
229 effectParms
* getEffectParms (void) const;
232 * @return global parameter manager, used in feMathExpression class and maybe somewhere else
234 parmMgr
* getParmMgr (void) const;
237 * @return global resource manager
239 resourceMgr
* getResourceMgr (void) const;
242 * @return feDrawUtil object
244 drawUtil
* getDrawUtil (void) const;
247 * @return render backend object
249 rBackend
* getRBackend (void) const;
252 * @return scene manager object
254 sceneManager
* getSceneManager (void) const;
257 * @return keybinder object
259 keyBinder
* getKeyBinder (void) const;
262 * @return entity manager object
264 entityManager
* getEntManager (void) const;
267 * @return metashader object
269 metaShader
* getMetaShader (void) const;
272 * @return system font used to draw console, etc
274 fontFT
* getSysFont (void) const;
277 * @return animation sequencer object
279 animSequencer
* getAnimSequencer (void) const;
282 * @return global stack allocator
284 stackAllocator
*getStackAllocator (void) const;
287 * [re]starts video subsystem
289 void restartVideo (void);
292 * [re]starts audio subsystem
294 void restartAudio (void);
297 * @return console variable manager
299 cvarManager
* getCVarManager (void) const;
302 extern FE_API engine
*g_engine
;
306 #endif // __F_ENGINE_H