79 #include <objc/message.h> 82 int32_t main(int32_t argc,
char **argv)
98 m_animationmanager(0),
99 m_soundclipmanager(0),
109 m_changelisteners() {
114 cocoa_lib = dlopen(
"/System/Library/Frameworks/Cocoa.framework/Cocoa", RTLD_LAZY );
115 void (*nsappload)(void);
116 nsappload = (void(*)()) dlsym( cocoa_lib,
"NSApplicationLoad");
121 Class NSAutoreleasePool = objc_getClass(
"NSAutoreleasePool");
122 m_autoreleasePool = class_createInstance(NSAutoreleasePool, 0);
124 objc_object *NSAutoreleasePool = objc_getClass(
"NSAutoreleasePool");
126 objc_msgSend(NSAutoreleasePool, sel_registerName(
"new"));
154 (*i)->onScreenModeChanged(mode);
163 FL_LOG(
_log,
"================== Engine initialize start =================");
182 if (SDL_Init(SDL_INIT_NOPARACHUTE | SDL_INIT_TIMER) < 0) {
183 throw SDLException(SDL_GetError());
202 if (rbackend ==
"SDL") {
208 FL_LOG(
_log,
"OpenGL Render backend created");
213 FL_WARN(
_log,
"Tried to select OpenGL, even though it is not compiled into the engine. Falling back to SDL Render backend");
237 if (std::find (drivers.begin(), drivers.end(), driver) == drivers.end()) {
238 FL_WARN(
_log,
"Selected video driver is not supported for your Operating System! Reverting to default driver.");
250 if (std::find (drivers.begin(), drivers.end(), driver) == drivers.end()) {
251 FL_WARN(
_log,
"Selected render driver is not supported for your Operating System! Reverting to default driver.");
306 FL_LOG(
_log,
"Adding grid prototypes to model");
337 std::vector<RendererBase*>::iterator rendererIter =
m_renderers.begin();
338 for ( ; rendererIter !=
m_renderers.end(); ++rendererIter)
340 delete *rendererIter;
352 objc_msgSend(m_autoreleasePool, sel_registerName(
"release"));
355 FL_LOG(
_log,
"================== Engine destructed ==================");
396 if ((*i) == listener) {
EngineSettings m_settings
#define FL_WARN(logger, msg)
uint16_t getHeight() const
Returns the height of the screen mode.
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.
void setMonochromeEnabled(bool enabled)
Enables or disables monochrome rendering.
void setVideoDriverName(const std::string &driver)
Sets the name of the video driver.
bool isColorKeyEnabled() const
Gets whether the colorkey feature is in use.
uint16_t getFrameLimit() const
Gets the frame limit.
std::vector< std::string > getAvailableVideoDrivers() const
Gets the available video drivers for your operating system.
Helper class to create log strings out from separate parts Usage: LMsg("some text") << variable << "...
uint32_t getActiveCameraCount() const
Return the number of enabled cameras in this model.
const std::string & getSDLDriver() const
Gets the used SDL render driver.
RenderBackend * m_renderbackend
The main class of the SDL-based renderer.
std::vector< std::string > getAvailableRenderDrivers() const
Gets the available render drivers for your operating system.
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).
uint8_t getDisplay() const
Gets the display index, starts with 0.
const DeviceCaps & getDeviceCaps() const
Gets device capabilities.
void update()
Called periodically to update events on model.
static Logger _log(LM_AUDIO)
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...
TextureFiltering getGLTextureFiltering() const
Gets current texture filter which uses OpenGL.
void setFramebufferEnabled(bool enabled)
Enables or disable the usage of the framebuffer, if available.
virtual void init(const std::string &driver)=0
Initializes the backend.
SoundManager * m_soundmanager
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.
void init()
Initializes the engine.
EngineSettings & getSettings()
Gets settings class for engine.
LogManager * m_logmanager
float getGLAlphaTestValue() const
Gets current alpha test value which uses OpenGL.
void setNativeImageCursorEnabled(bool native_image_cursor_enabled)
Enables or disables the native image cursor feature.
virtual void draw()
draws cursor on screen
Provider for OS directories.
void setVolume(float vol)
Sets the Master Volume.
bool isFrameLimitEnabled() const
Gets whether the frame limiter is in use.
bool isVSync() const
True, if vsync is enable, otherwise false.
virtual void startFrame()
Called when a new frame starts.
void setMipmappingEnabled(bool enabled)
Enables or disables the usage of mipmapping.
void setAlphaTestValue(float alpha)
Sets the value for alpha test.
void setFrameLimit(uint16_t framelimit)
Sets the frame limit.
void setNPOTEnabled(bool enabled)
Enables or disable the usage of npot, if available.
const SDL_Color & getColorKey() const
Gets the global colorkey setting.
void removeChangeListener(IEngineChangeListener *listener)
Removes associated change listener.
uint16_t getRefreshRate() const
Gets the refresh rate.
EventManager * m_eventmanager
float getMouseSensitivity() const
Gets mouse sensitivity.
const std::string & getWindowIcon() const
Gets the icon in the window title bar.
bool isGLUseDepthBuffer() const
Tells if OpenGL renderbackend should use depth buffer.
void update()
Called once a frame and updates the sound objects.
TimeManager * m_timemanager
void addSource(VFSSource *source)
Add a new VFSSource.
uint8_t getBitsPerPixel() const
Gets currently set bits per pixel value.
virtual void resizeTopContainer(uint32_t x, uint32_t y, uint32_t width, uint32_t height)=0
Resizes the top container.
bool isGLCompressImages() const
Tells if images are compress by video driver in OpenGL renderbackend.
void setTextureFiltering(TextureFiltering filter)
Sets the texture filtering method.
AnimationManager * m_animationmanager
A model is a facade for everything in the model.
CellSelectionRenderer renders a frame around selected cells.
uint32_t getLightingModel() const
Gets the currently set light model.
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.
OffRenderer * m_offrenderer
IGUIManager * m_guimanager
virtual void invalidateAll()
void setRenderDriverName(const std::string &driver)
Sets the name of the render driver.
void setDepthBufferEnabled(bool enabled)
Enables or disables depth buffer rendering.
bool isFullScreen() const
True, if set to fullscreen.
Event Manager manages all events related to FIFE.
virtual ~Engine()
Destructor.
bool isMouseAccelerationEnabled() const
Returns if mouse acceleration is enabled or not.
#define FL_LOG(logger, msg)
virtual void endFrame()
Called when a frame is finished and ready to be displayed.
static LogManager * instance()
Returns instance to log manager.
uint16_t getScreenWidth() const
Gets screen width (pixels)
void fillDeviceCaps()
Should be called AFTER SDL_Init() has been called.
bool isNativeImageCursorEnabled() const
Returns whether cursors set to an image or an animation are drawn natively.
Cursor class manages mouse cursor handling.
void setFrameLimitEnabled(bool limited)
Sets whether to use the frame limiter.
std::vector< RendererBase * > m_renderers
the main VFS (virtual file system) class
void setJoystickSupport(bool support)
Sets the joystick support to enabled or disabled.
float getInitialVolume() const
Gets initial engine sound volume.
void adoptPather(IPather *pather)
Adds pather to model.
const std::string & getVideoDriver() const
Gets the video driver.
void update()
Called once a frame and updates the timer objects and events.
bool isGLUseNPOT() const
Tells if OpenGL renderbackend should use NPOT Textures.
const std::string & getWindowTitle() const
Gets the current window title.
bool isJoystickSupport() const
Returns whether joystick and gamepad support is enabled or not.
const std::string & getRenderBackend() const
Gets currently set renderbackend name.
The most basic VFSSource for "normal" filesystems.
A VFS provider for Zip archives.
bool isGLUseMonochrome() const
Tells if OpenGL renderbackend should render only monochrome.
void setMouseSensitivity(float sensitivity)
Sets mouse sensitivity The sensitivity is limited to the range -0.99 - 10.0.
uint16_t getWidth() const
Returns the width of the screen mode.
void processEvents()
Process the SDL event queue.
SoundClipManager * m_soundclipmanager
void setImageCompressingEnabled(bool enabled)
Enables or disable compressing images by video driver.
uint16_t getScreenHeight() const
Gets screen height (pixels)
void setVSyncEnabled(bool vsync)
Sets whether to use VSync.
bool isGLUseMipmapping() const
Tells if OpenGL renderbackend should use mipmapping.
The main class of the OpenGL-based renderer.
bool isGLUseFramebuffer() const
Tells if OpenGL renderbackend should use FramebufferObject.
virtual void setLightingModel(uint32_t lighting)=0
Initializes the light.
void changeScreenMode(const ScreenMode &mode)
Changes the screen mode.