80 #include <objc/message.h>
83 int32_t main(int32_t argc,
char **argv)
99 m_soundclipmanager(0),
107 m_changelisteners() {
112 cocoa_lib = dlopen(
"/System/Library/Frameworks/Cocoa.framework/Cocoa", RTLD_LAZY );
113 void (*nsappload)(void);
114 nsappload = (void(*)()) dlsym( cocoa_lib,
"NSApplicationLoad");
118 objc_object *NSAutoreleasePool = objc_getClass(
"NSAutoreleasePool");
120 objc_msgSend(NSAutoreleasePool, sel_registerName(
"new"));
146 (*i)->onScreenModeChanged(mode);
154 FL_LOG(
_log,
"================== Engine initialize start =================");
173 if (SDL_Init(SDL_INIT_NOPARACHUTE | SDL_INIT_TIMER) < 0) {
174 throw SDLException(SDL_GetError());
177 SDL_EnableUNICODE(1);
178 SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
193 if (rbackend ==
"SDL") {
198 if (rbackend ==
"OpenGLe") {
200 FL_LOG(
_log,
"OpenGLe Render backend created");
201 FL_LOG(
_log,
"This is highly experimental so bear in mind some features may not work/work correctly.");
204 FL_LOG(
_log,
"OpenGL Render backend created");
210 FL_WARN(
_log,
"Tried to select OpenGL, even though it is not compiled into the engine. Falling back to SDL Render backend");
230 if (std::find (drivers.begin(), drivers.end(), driver) == drivers.end()) {
231 FL_WARN(
_log,
"Selected driver is not supported for your Operating System! Reverting to default driver.");
263 SDL_EnableUNICODE(1);
287 FL_LOG(
_log,
"Adding grid prototypes to model");
315 std::vector<RendererBase*>::iterator rendererIter =
m_renderers.begin();
316 for ( ; rendererIter !=
m_renderers.end(); ++rendererIter)
318 delete *rendererIter;
330 objc_msgSend(m_autoreleasePool, sel_registerName(
"release"));
333 FL_LOG(
_log,
"================== Engine destructed ==================");
373 if ((*i) == listener) {
EngineSettings m_settings
#define FL_WARN(logger, msg)
void pump()
Runs one cycle for the engine.
This class defines the engine settings on engine init.
virtual void turn()=0
Performs the GUI logic and draws the GUI accordingly.
void adoptCellGrid(CellGrid *grid)
Adds cellgrid to model.
ImageManager * m_imagemanager
void addProvider(VFSSourceProvider *provider)
add new VFSSourceProvider
void addChangeListener(IEngineChangeListener *listener)
Adds new change listener.
bool isColorKeyEnabled() const
Gets whether the colorkey feature is in use.
RenderBackend * m_renderbackend
The main class of the SDL-based renderer.
void finalizePumping()
Finalizes the continuous processing of the engine Call this only once in your program, after you have called initializePumping + (pump() * N times)
std::vector< IEngineChangeListener * > m_changelisteners
void destroy()
Explicit destruction of engine.
virtual void createMainScreen(const ScreenMode &mode, const std::string &title, const std::string &icon)=0
Creates the mainscreen (the display window).
void update()
Called periodically to update events on model.
static Logger _log(LM_AUDIO)
bool isFrameLimitEnabled() const
Gets whether the frame limiter is in use.
TargetRenderer * m_targetrenderer
void setColorKeyEnabled(bool colorkeyenable)
Sets whether to use the colorkey feature.
void setMouseAccelerationEnabled(bool acceleration)
Sets mouse acceleration if mouse acceleration is enabled, then the mouse sensitivity is used as speed...
void setFramebufferEnabled(bool enabled)
Enables or disable the usage of the framebuffer, if available.
uint16_t getScreenHeight() const
Gets screen height (pixels)
virtual void init(const std::string &driver)=0
Initializes the backend.
const SDL_Color & getColorKey() const
Gets the global colorkey setting.
SoundManager * m_soundmanager
const std::string & getVideoDriver() const
void initializePumping()
Initializes the continuous processing of the engine Call this only once in your program.
virtual void clearBackBuffer()=0
Forces a clear of the backbuffer.
ScreenMode getNearestScreenMode(uint16_t width, uint16_t height, uint16_t bpp, const std::string &renderer, bool fs) const
Gets the nearest valid screen mode based on the arguments passed.
const std::string & getWindowTitle() const
Gets the current window title.
bool isGLUseNPOT() const
Tells if OpenGL renderbackend should use NPOT Textures.
uint16_t getScreenWidth() const
Gets screen width (pixels)
void init()
Initializes the engine.
EngineSettings & getSettings()
Gets settings class for engine.
float getMouseSensitivity() const
Gets mouse sensitivity.
LogManager * m_logmanager
bool isGLCompressImages() const
Tells if images are compress by video driver in OpenGL renderbackend.
virtual void draw()
draws cursor on screen
Provider for OS directories.
void setVolume(float vol)
Sets the Master Volume.
std::vector< std::string > getAvailableDrivers() const
Gets the available graphics drivers for your operating system.
virtual void startFrame()
Called when a new frame starts.
uint32_t getMapCount() const
Return the number of maps in this model.
void setFrameLimit(uint16_t framelimit)
Sets the frame limit.
void setNPOTEnabled(bool enabled)
Enables or disable the usage of npot, if available.
float getInitialVolume() const
Gets initial engine sound volume.
const DeviceCaps & getDeviceCaps() const
Gets device capabilities.
void removeChangeListener(IEngineChangeListener *listener)
Removes associated change listener.
const std::string & getRenderBackend() const
Gets currently set renderbackend name.
EventManager * m_eventmanager
uint8_t getBitsPerPixel() const
Gets currently set bits per pixel value.
TimeManager * m_timemanager
uint16_t getHeight() const
Returns the height of the screen mode.
void addSource(VFSSource *source)
Add a new VFSSource.
virtual void resizeTopContainer(uint32_t x, uint32_t y, uint32_t width, uint32_t height)=0
Resizes the top container.
A model is a facade for everything in the model.
CellSelectionRenderer renders a frame around selected cells.
OffRenderer * m_offrenderer
uint16_t getWidth() const
Returns the width of the screen mode.
IGUIManager * m_guimanager
virtual void invalidateAll()
Event Manager manages all events related to FIFE.
virtual ~Engine()
Destructor.
#define FL_LOG(logger, msg)
bool isMouseAccelerationEnabled() const
Returns if mouse acceleration is enabled or not.
virtual void endFrame()
Called when a frame is finished and ready to be displayed.
static LogManager * instance()
Returns instance to log manager.
void fillDeviceCaps()
Should be called AFTER SDL_Init() has been called.
uint16_t getFrameLimit() const
Gets the frame limit.
Cursor class manages mouse cursor handling.
bool isGLUseFramebuffer() const
Tells if OpenGL renderbackend should use FramebufferObject.
void setFrameLimitEnabled(bool limited)
Sets whether to use the frame limiter.
std::vector< RendererBase * > m_renderers
the main VFS (virtual file system) class
bool isFullScreen() const
True, if set to fullscreen.
void adoptPather(IPather *pather)
Adds pather to model.
void update()
Called once a frame and updates the timer objects and events.
The main class of the OpenGL-based experimental renderer.
uint32_t getLightingModel() const
Gets the currently set light model.
The most basic VFSSource for "normal" filesystems.
A VFS provider for Zip archives.
const std::string & getWindowIcon() const
Gets the icon in the window title bar.
void setMouseSensitivity(float sensitivity)
Sets mouse sensitivity The sensitivity is limited to the range -0.99 - 10.0.
void processEvents()
Process the SDL event queue.
SoundClipManager * m_soundclipmanager
void setImageCompressingEnabled(bool enabled)
Enables or disable compressing images by video driver.
virtual void setScreenMode(const ScreenMode &mode)=0
Sets the mainscreen display mode.
The main class of the OpenGL-based renderer.
virtual void setLightingModel(uint32_t lighting)=0
Initializes the light.
void changeScreenMode(const ScreenMode &mode)
Changes the screen mode.