FIFE
be64c707dea6b3250bd4355bf5c825d25920087d
|
The main class of the SDL-based renderer. More...
#include <renderbackendsdl.h>
Public Member Functions | |
RenderBackendSDL (const SDL_Color &colorkey) | |
virtual | ~RenderBackendSDL () |
virtual const std::string & | getName () const |
The name of the renderbackend. More... | |
virtual void | startFrame () |
Called when a new frame starts. More... | |
virtual void | endFrame () |
Called when a frame is finished and ready to be displayed. More... | |
virtual void | init (const std::string &driver) |
Initializes the backend. More... | |
virtual void | clearBackBuffer () |
Forces a clear of the backbuffer. More... | |
virtual void | setLightingModel (uint32_t lighting) |
Initializes the light. More... | |
virtual uint32_t | getLightingModel () const |
Gets the current light model. More... | |
virtual void | setLighting (float red, float green, float blue) |
Set colors for lighting. More... | |
virtual void | resetLighting () |
Reset lighting with default values. More... | |
virtual void | resetStencilBuffer (uint8_t buffer) |
Reset stencil buffer with given value. More... | |
virtual void | changeBlending (int32_t scr, int32_t dst) |
Change the Blendingmodel. More... | |
virtual void | createMainScreen (const ScreenMode &mode, const std::string &title, const std::string &icon) |
Creates the mainscreen (the display window). More... | |
virtual void | setScreenMode (const ScreenMode &mode) |
Sets the mainscreen display mode. More... | |
virtual Image * | createImage (IResourceLoader *loader=0) |
virtual Image * | createImage (const std::string &name, IResourceLoader *loader=0) |
virtual Image * | createImage (const uint8_t *data, uint32_t width, uint32_t height) |
Creates an Image suitable for this renderbackend. More... | |
virtual Image * | createImage (const std::string &name, const uint8_t *data, uint32_t width, uint32_t height) |
virtual Image * | createImage (SDL_Surface *surface) |
Helper function to create images from SDL_Surfaces. More... | |
virtual Image * | createImage (const std::string &name, SDL_Surface *surface) |
virtual void | renderVertexArrays () |
Render the Vertex Arrays, only for primitives (points, lines,...) More... | |
virtual void | addImageToArray (uint32_t id, const Rect &rec, float const *st, uint8_t alpha, uint8_t const *rgba) |
Add the Image data to the array. More... | |
virtual void | changeRenderInfos (RenderDataType type, uint16_t elements, int32_t src, int32_t dst, bool light, bool stentest, uint8_t stenref, GLConstants stenop, GLConstants stenfunc, OverlayType otype=OVERLAY_TYPE_NONE) |
Dirty helper function to change the render infos. More... | |
virtual void | captureScreen (const std::string &filename) |
Creates a Screenshot and saves it to a file. More... | |
virtual void | captureScreen (const std::string &filename, uint32_t width, uint32_t height) |
Creates a Screenshot with the given size(w,h) and saves it to a file. More... | |
virtual bool | putPixel (int32_t x, int32_t y, uint8_t r, uint8_t g, uint8_t b, uint8_t a=255) |
Writes pixel to given position. More... | |
virtual void | drawLine (const Point &p1, const Point &p2, uint8_t r, uint8_t g, uint8_t b, uint8_t a=255) |
Draws line between given points with given RGBA. More... | |
virtual void | drawThickLine (const Point &p1, const Point &p2, uint8_t width, uint8_t r, uint8_t g, uint8_t b, uint8_t a=255) |
Draws line between given points with given RGBA and width. More... | |
virtual void | drawPolyLine (const std::vector< Point > &points, uint8_t width, uint8_t r, uint8_t g, uint8_t b, uint8_t a=255) |
Draws lines between given points with given RGBA and width. More... | |
virtual void | drawBezier (const std::vector< Point > &points, int32_t steps, uint8_t width, uint8_t r, uint8_t g, uint8_t b, uint8_t a=255) |
Draws bezier curve between given points with given RGBA and width. More... | |
virtual void | drawTriangle (const Point &p1, const Point &p2, const Point &p3, uint8_t r, uint8_t g, uint8_t b, uint8_t a=255) |
Draws triangle between given points with given RGBA. More... | |
virtual void | drawRectangle (const Point &p, uint16_t w, uint16_t h, uint8_t r, uint8_t g, uint8_t b, uint8_t a=255) |
Draws an axis parallel rectangle. More... | |
virtual void | fillRectangle (const Point &p, uint16_t w, uint16_t h, uint8_t r, uint8_t g, uint8_t b, uint8_t a=255) |
Draws a filled axis parallel rectangle. More... | |
virtual void | drawQuad (const Point &p1, const Point &p2, const Point &p3, const Point &p4, uint8_t r, uint8_t g, uint8_t b, uint8_t a=255) |
Draws quad between given points with given RGBA. More... | |
virtual void | drawVertex (const Point &p, const uint8_t size, uint8_t r, uint8_t g, uint8_t b, uint8_t a=255) |
Draws a quad that represents a vertex with given RGBA. More... | |
virtual void | drawCircle (const Point &p, uint32_t radius, uint8_t r, uint8_t g, uint8_t b, uint8_t a=255) |
Draws a circle. More... | |
virtual void | drawFillCircle (const Point &p, uint32_t radius, uint8_t r, uint8_t g, uint8_t b, uint8_t a=255) |
Draws a filled circle. More... | |
virtual void | drawCircleSegment (const Point &p, uint32_t radius, int32_t sangle, int32_t eangle, uint8_t r, uint8_t g, uint8_t b, uint8_t a=255) |
Draws a circle segment. More... | |
virtual void | drawFillCircleSegment (const Point &p, uint32_t radius, int32_t sangle, int32_t eangle, uint8_t r, uint8_t g, uint8_t b, uint8_t a=255) |
Draws a filled circle segment. More... | |
virtual void | drawLightPrimitive (const Point &p, uint8_t intensity, float radius, int32_t subdivisions, float xstretch, float ystretch, uint8_t red, uint8_t green, uint8_t blue) |
Draws a light primitive that based on a triangle fan. More... | |
virtual void | enableScissorTest () |
Enables scissor test on the render backend. More... | |
virtual void | disableScissorTest () |
Disables scissor test on the render backend. More... | |
virtual void | attachRenderTarget (ImagePtr &img, bool discard) |
Attaches given image as a new render surface. More... | |
virtual void | detachRenderTarget () |
Detaches current render surface. More... | |
virtual void | renderGuiGeometry (const std::vector< GuiVertex > &vertices, const std::vector< int > &indices, const DoublePoint &translation, ImagePtr texture) |
Renders geometry required by gui. More... | |
SDL_Renderer * | getRenderer () |
Public Member Functions inherited from FIFE::RenderBackend | |
RenderBackend (const SDL_Color &colorkey) | |
Constructor. More... | |
virtual | ~RenderBackend () |
Destructor. More... | |
void | deinit () |
Performs cleanup actions. More... | |
SDL_Window * | getWindow () |
const ScreenMode & | getCurrentScreenMode () const |
Get current screen mode. More... | |
uint32_t | getWidth () const |
uint32_t | getHeight () const |
uint32_t | getScreenWidth () const |
uint32_t | getScreenHeight () const |
const Rect & | getArea () const |
void | pushClipArea (const Rect &cliparea, bool clear=true) |
Pushes clip area to clip stack Clip areas define which area is drawn on screen. More... | |
void | popClipArea () |
Pops clip area from clip stack. More... | |
const Rect & | getClipArea () const |
Gets the current clip area. More... | |
void | setAlphaOptimizerEnabled (bool enabled) |
Enable or disable the alpha 'optimizing' code. More... | |
bool | isAlphaOptimizerEnabled () const |
void | setImageCompressingEnabled (bool enabled) |
Enables or disable compressing images by video driver. More... | |
bool | isImageCompressingEnabled () const |
void | setFramebufferEnabled (bool enabled) |
Enables or disable the usage of the framebuffer, if available. More... | |
bool | isFramebufferEnabled () const |
void | setNPOTEnabled (bool enabled) |
Enables or disable the usage of npot, if available. More... | |
bool | isNPOTEnabled () const |
void | setTextureFiltering (TextureFiltering filter) |
Sets the texture filtering method. More... | |
TextureFiltering | getTextureFiltering () const |
void | setMipmappingEnabled (bool enabled) |
Enables or disables the usage of mipmapping. More... | |
bool | isMipmappingEnabled () const |
int32_t | getMaxAnisotropy () const |
Gets max antisotropy for antisotropic filtering. More... | |
void | setMonochromeEnabled (bool enabled) |
Enables or disables monochrome rendering. More... | |
bool | isMonochromeEnabled () const |
void | setDepthBufferEnabled (bool enabled) |
Enables or disables depth buffer rendering. More... | |
bool | isDepthBufferEnabled () const |
void | setAlphaTestValue (float alpha) |
Sets the value for alpha test. More... | |
float | getAlphaTestValue () const |
void | setColorKeyEnabled (bool colorkeyenable) |
Sets whether to use the colorkey feature. More... | |
bool | isColorKeyEnabled () const |
Gets whether the colorkey feature is in use. More... | |
void | setColorKey (const SDL_Color &colorkey) |
Sets the global colorkey to use for images. More... | |
const SDL_Color & | getColorKey () const |
Gets the global colorkey setting. More... | |
void | setBackgroundColor (uint8_t r, uint8_t g, uint8_t b) |
Set the background color. More... | |
void | resetBackgroundColor () |
Reset the background color to black. More... | |
const SDL_PixelFormat & | getPixelFormat () const |
Gets the current screen rgba format. More... | |
void | setVSyncEnabled (bool vsync) |
Sets whether to use VSync. More... | |
bool | isVSyncEnabled () const |
Gets whether VSync is in use. More... | |
void | setFrameLimitEnabled (bool limited) |
Sets whether to use the frame limiter. More... | |
bool | isFrameLimitEnabled () const |
Gets whether the frame limiter is in use. More... | |
void | setFrameLimit (uint16_t framelimit) |
Sets the frame limit. More... | |
uint16_t | getFrameLimit () const |
Gets the frame limit. More... | |
SDL_Surface * | getScreenSurface () |
Returns screen render surface. More... | |
SDL_Surface * | getRenderTargetSurface () |
Returns currently attached render surface. More... | |
Point | getBezierPoint (const std::vector< Point > &points, int32_t elements, float t) |
Helper that returns an interpolated Point. More... | |
void | addControlPoints (const std::vector< Point > &points, std::vector< Point > &newPoints) |
Helper that adds the control points for bezier curves. More... | |
Public Member Functions inherited from FIFE::DynamicSingleton< RenderBackend > | |
DynamicSingleton () | |
virtual | ~DynamicSingleton () |
Protected Member Functions | |
virtual void | setClipArea (const Rect &cliparea, bool clear) |
Sets given clip area into image. More... | |
Protected Member Functions inherited from FIFE::RenderBackend | |
void | clearClipArea () |
Clears any possible clip areas. More... | |
Protected Attributes | |
SDL_Renderer * | m_renderer |
Protected Attributes inherited from FIFE::RenderBackend | |
SDL_Window * | m_window |
SDL_Surface * | m_screen |
SDL_Surface * | m_target |
bool | m_compressimages |
bool | m_useframebuffer |
bool | m_usenpot |
bool | m_isalphaoptimized |
bool | m_iscolorkeyenabled |
SDL_Color | m_colorkey |
ScreenMode | m_screenMode |
SDL_PixelFormat | m_rgba_format |
bool | m_isbackgroundcolor |
SDL_Color | m_backgroundcolor |
bool | m_isMipmapping |
TextureFiltering | m_textureFilter |
int32_t | m_maxAnisotropy |
bool | m_monochrome |
bool | m_isDepthBuffer |
float | m_alphaValue |
bool | m_vSync |
std::stack< ClipInfo > | m_clipstack |
ClipInfo | m_guiClip |
Additional Inherited Members | |
Static Public Member Functions inherited from FIFE::DynamicSingleton< RenderBackend > | |
static RenderBackend * | instance () |
The main class of the SDL-based renderer.
Definition at line 43 of file renderbackendsdl.h.
FIFE::RenderBackendSDL::RenderBackendSDL | ( | const SDL_Color & | colorkey | ) |
Definition at line 46 of file renderbackendsdl.cpp.
|
virtual |
Definition at line 51 of file renderbackendsdl.cpp.
References FIFE::RenderBackend::deinit(), m_renderer, and FIFE::RenderBackend::m_window.
|
virtual |
Add the Image data to the array.
Implements FIFE::RenderBackend.
Definition at line 230 of file renderbackendsdl.cpp.
|
virtual |
Attaches given image as a new render surface.
Implements FIFE::RenderBackend.
Definition at line 669 of file renderbackendsdl.cpp.
References FIFE::SharedPtr< T >::get(), FIFE::Image::getArea(), FIFE::Image::getSurface(), FIFE::SDLImage::getTexture(), m_renderer, FIFE::RenderBackend::m_rgba_format, FIFE::RenderBackend::m_target, setClipArea(), and FIFE::SDLImage::setTexture().
|
virtual |
Creates a Screenshot and saves it to a file.
Implements FIFE::RenderBackend.
Definition at line 536 of file renderbackendsdl.cpp.
References FIFE::BMASK, FIFE::RenderBackend::getHeight(), FIFE::RenderBackend::getWidth(), FIFE::GMASK, FIFE::RenderBackend::m_screen, FIFE::NULLMASK, FIFE::RMASK, and FIFE::Image::saveAsPng().
Referenced by captureScreen().
|
virtual |
Creates a Screenshot with the given size(w,h) and saves it to a file.
Implements FIFE::RenderBackend.
Definition at line 555 of file renderbackendsdl.cpp.
References FIFE::AMASK, FIFE::BMASK, captureScreen(), FIFE::RenderBackend::getHeight(), FIFE::RenderBackend::getWidth(), FIFE::GMASK, FIFE::RenderBackend::m_screen, FIFE::RMASK, and FIFE::Image::saveAsPng().
|
virtual |
Change the Blendingmodel.
Implements FIFE::RenderBackend.
Definition at line 224 of file renderbackendsdl.cpp.
|
virtual |
Dirty helper function to change the render infos.
Implements FIFE::RenderBackend.
Definition at line 233 of file renderbackendsdl.cpp.
|
virtual |
Forces a clear of the backbuffer.
Implements FIFE::RenderBackend.
Definition at line 73 of file renderbackendsdl.cpp.
References m_renderer.
|
virtual |
Implements FIFE::RenderBackend.
Definition at line 183 of file renderbackendsdl.cpp.
|
virtual |
Implements FIFE::RenderBackend.
Definition at line 187 of file renderbackendsdl.cpp.
|
virtual |
Creates an Image suitable for this renderbackend.
data | Pointer to the imagedata (needs to be in RGBA, 8 bits per channel). |
width | Width of the image. |
height | Height of the image. |
Implements FIFE::RenderBackend.
Definition at line 199 of file renderbackendsdl.cpp.
|
virtual |
Implements FIFE::RenderBackend.
Definition at line 203 of file renderbackendsdl.cpp.
|
virtual |
Helper function to create images from SDL_Surfaces.
Takes ownership over the surface.
surface | The surface to convert. |
Implements FIFE::RenderBackend.
Definition at line 191 of file renderbackendsdl.cpp.
|
virtual |
Implements FIFE::RenderBackend.
Definition at line 195 of file renderbackendsdl.cpp.
|
virtual |
Creates the mainscreen (the display window).
mode | The ScreenMode to use. |
title | The window title to use. |
icon | The window icon to use. |
Implements FIFE::RenderBackend.
Definition at line 78 of file renderbackendsdl.cpp.
References FIFE::RenderBackend::m_window, and setScreenMode().
|
virtual |
Detaches current render surface.
Implements FIFE::RenderBackend.
Definition at line 681 of file renderbackendsdl.cpp.
References m_renderer, FIFE::RenderBackend::m_screen, and FIFE::RenderBackend::m_target.
|
virtual |
Disables scissor test on the render backend.
Implements FIFE::RenderBackend.
Definition at line 533 of file renderbackendsdl.cpp.
|
virtual |
Draws bezier curve between given points with given RGBA and width.
Implements FIFE::RenderBackend.
Definition at line 337 of file renderbackendsdl.cpp.
References drawFillCircle(), drawLine(), drawThickLine(), FIFE::RenderBackend::getBezierPoint(), and utf8::next().
|
virtual |
Draws a circle.
Implements FIFE::RenderBackend.
Definition at line 413 of file renderbackendsdl.cpp.
References putPixel(), FIFE::PointType2D< T >::x, and FIFE::PointType2D< T >::y.
|
virtual |
Draws a circle segment.
Note: The start angle must be less than the end angle. 0 angle is right side.
Implements FIFE::RenderBackend.
Definition at line 450 of file renderbackendsdl.cpp.
References FIFE::Math< T >::Cos(), drawLine(), FIFE::Math< T >::Sin(), FIFE::Math< T >::twoPi(), FIFE::PointType2D< T >::x, and FIFE::PointType2D< T >::y.
|
virtual |
Draws a filled circle.
Implements FIFE::RenderBackend.
Definition at line 438 of file renderbackendsdl.cpp.
References FIFE::Math< T >::Floor(), putPixel(), FIFE::Math< T >::Sqrt(), FIFE::PointType2D< T >::x, and FIFE::PointType2D< T >::y.
Referenced by drawBezier(), and drawPolyLine().
|
virtual |
Draws a filled circle segment.
0 angle is right side. Note: The start angle must be less than the end angle.
Implements FIFE::RenderBackend.
Definition at line 470 of file renderbackendsdl.cpp.
References FIFE::Math< T >::Cos(), putPixel(), FIFE::Math< T >::Sin(), FIFE::Math< T >::twoPi(), FIFE::PointType2D< T >::x, and FIFE::PointType2D< T >::y.
|
virtual |
Draws a light primitive that based on a triangle fan.
Implements FIFE::RenderBackend.
Definition at line 527 of file renderbackendsdl.cpp.
|
virtual |
Draws line between given points with given RGBA.
Implements FIFE::RenderBackend.
Definition at line 244 of file renderbackendsdl.cpp.
References m_renderer, FIFE::PointType2D< T >::x, and FIFE::PointType2D< T >::y.
Referenced by drawBezier(), drawCircleSegment(), and drawPolyLine().
|
virtual |
Draws lines between given points with given RGBA and width.
Implements FIFE::RenderBackend.
Definition at line 314 of file renderbackendsdl.cpp.
References drawFillCircle(), drawLine(), and drawThickLine().
|
virtual |
Draws quad between given points with given RGBA.
Implements FIFE::RenderBackend.
Definition at line 396 of file renderbackendsdl.cpp.
References fillRectangle(), FIFE::PointType2D< T >::x, and FIFE::PointType2D< T >::y.
|
virtual |
Draws an axis parallel rectangle.
Implements FIFE::RenderBackend.
Definition at line 376 of file renderbackendsdl.cpp.
References m_renderer, FIFE::PointType2D< T >::x, and FIFE::PointType2D< T >::y.
|
virtual |
Draws line between given points with given RGBA and width.
Implements FIFE::RenderBackend.
Definition at line 249 of file renderbackendsdl.cpp.
References FIFE::Math< T >::ATan2(), FIFE::Math< T >::Cos(), FIFE::Math< T >::pi(), putPixel(), FIFE::Math< T >::Sin(), FIFE::PointType2D< T >::x, and FIFE::PointType2D< T >::y.
Referenced by drawBezier(), and drawPolyLine().
|
virtual |
Draws triangle between given points with given RGBA.
Implements FIFE::RenderBackend.
Definition at line 369 of file renderbackendsdl.cpp.
References m_renderer, FIFE::PointType2D< T >::x, and FIFE::PointType2D< T >::y.
|
virtual |
Draws a quad that represents a vertex with given RGBA.
Implements FIFE::RenderBackend.
Definition at line 400 of file renderbackendsdl.cpp.
References m_renderer, FIFE::PointType2D< T >::x, and FIFE::PointType2D< T >::y.
|
virtual |
Enables scissor test on the render backend.
Implements FIFE::RenderBackend.
Definition at line 530 of file renderbackendsdl.cpp.
|
virtual |
Called when a frame is finished and ready to be displayed.
Reimplemented from FIFE::RenderBackend.
Definition at line 178 of file renderbackendsdl.cpp.
References FIFE::RenderBackend::endFrame(), and m_renderer.
|
virtual |
Draws a filled axis parallel rectangle.
Implements FIFE::RenderBackend.
Definition at line 386 of file renderbackendsdl.cpp.
References m_renderer, FIFE::PointType2D< T >::x, and FIFE::PointType2D< T >::y.
Referenced by drawQuad().
|
virtual |
Gets the current light model.
Implements FIFE::RenderBackend.
Definition at line 211 of file renderbackendsdl.cpp.
|
virtual |
The name of the renderbackend.
Implements FIFE::RenderBackend.
Definition at line 57 of file renderbackendsdl.cpp.
|
inline |
Definition at line 99 of file renderbackendsdl.h.
References m_renderer, and setClipArea().
|
virtual |
Initializes the backend.
Implements FIFE::RenderBackend.
Definition at line 62 of file renderbackendsdl.cpp.
|
virtual |
Writes pixel to given position.
Returns true, if pixel was written (not out of bounds)
Implements FIFE::RenderBackend.
Definition at line 236 of file renderbackendsdl.cpp.
References m_renderer.
Referenced by drawCircle(), drawFillCircle(), drawFillCircleSegment(), and drawThickLine().
|
virtual |
Renders geometry required by gui.
Implements FIFE::RenderBackend.
Definition at line 687 of file renderbackendsdl.cpp.
|
virtual |
Render the Vertex Arrays, only for primitives (points, lines,...)
Implements FIFE::RenderBackend.
Definition at line 227 of file renderbackendsdl.cpp.
|
virtual |
Reset lighting with default values.
Implements FIFE::RenderBackend.
Definition at line 218 of file renderbackendsdl.cpp.
|
virtual |
Reset stencil buffer with given value.
Implements FIFE::RenderBackend.
Definition at line 221 of file renderbackendsdl.cpp.
|
protectedvirtual |
Sets given clip area into image.
Implements FIFE::RenderBackend.
Definition at line 652 of file renderbackendsdl.cpp.
References FIFE::RectType< T >::h, FIFE::RenderBackend::m_backgroundcolor, FIFE::RenderBackend::m_isbackgroundcolor, m_renderer, FIFE::RectType< T >::w, FIFE::RectType< T >::x, and FIFE::RectType< T >::y.
Referenced by attachRenderTarget(), and getRenderer().
|
virtual |
Set colors for lighting.
Implements FIFE::RenderBackend.
Definition at line 215 of file renderbackendsdl.cpp.
|
virtual |
Initializes the light.
Implements FIFE::RenderBackend.
Definition at line 207 of file renderbackendsdl.cpp.
|
virtual |
Sets the mainscreen display mode.
mode | The ScreenMode to change the display to. |
Implements FIFE::RenderBackend.
Definition at line 92 of file renderbackendsdl.cpp.
References FIFE::_log, FIFE::AMASK, FIFE::BMASK, FL_LOG, FIFE::ScreenMode::getBPP(), FIFE::ScreenMode::getDisplay(), FIFE::ScreenMode::getFormat(), FIFE::ScreenMode::getHeight(), FIFE::ScreenMode::getRefreshRate(), FIFE::ScreenMode::getRenderDriverIndex(), FIFE::ScreenMode::getSDLFlags(), FIFE::ScreenMode::getWidth(), FIFE::GMASK, FIFE::ScreenMode::isFullScreen(), m_renderer, FIFE::RenderBackend::m_rgba_format, FIFE::RenderBackend::m_screen, FIFE::RenderBackend::m_screenMode, FIFE::RenderBackend::m_target, FIFE::RenderBackend::m_textureFilter, FIFE::RenderBackend::m_vSync, FIFE::RenderBackend::m_window, FIFE::RMASK, FIFE::TEXTURE_FILTER_ANISOTROPIC, and FIFE::TEXTURE_FILTER_NONE.
Referenced by createMainScreen().
|
virtual |
Called when a new frame starts.
Reimplemented from FIFE::RenderBackend.
Definition at line 174 of file renderbackendsdl.cpp.
References FIFE::RenderBackend::startFrame().
|
protected |
Definition at line 104 of file renderbackendsdl.h.
Referenced by attachRenderTarget(), clearBackBuffer(), detachRenderTarget(), drawLine(), drawRectangle(), drawTriangle(), drawVertex(), endFrame(), fillRectangle(), getRenderer(), putPixel(), setClipArea(), setScreenMode(), and ~RenderBackendSDL().