22 #ifndef FIFE_VIDEO_RENDERBACKEND_H
23 #define FIFE_VIDEO_RENDERBACKEND_H
34 #include <SDL_video.h>
135 virtual const std::string&
getName()
const = 0;
147 virtual void init(
const std::string& driver) = 0;
163 virtual void setLighting(
float red,
float green,
float blue) = 0;
211 virtual Image*
createImage(
const std::string& name, SDL_Surface* surface) = 0;
virtual void addImageToArray(uint32_t id, const Rect &rec, float const *st, uint8_t alpha, uint8_t const *rgba)=0
Add the Image data to the array.
Abstract interface for all the renderbackends.
virtual void setLighting(float red, float green, float blue)=0
Set colors for lighting.
virtual void setClipArea(const Rect &cliparea, bool clear)=0
Sets given clip area into image.
RenderBackend(const SDL_Color &colorkey)
Constructor.
void setColorKey(const SDL_Color &colorkey)
Sets the global colorkey to use for images.
uint32_t getScreenHeight() const
virtual void disableScissorTest()=0
Disables scissor test on the render backend.
virtual void renderGuiGeometry(const std::vector< GuiVertex > &vertices, const std::vector< int > &indices, const DoublePoint &translation, ImagePtr texture)=0
Renders geometry required by gui.
void setMonochromeEnabled(bool enabled)
Enables or disables monochrome rendering.
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)=0
Draws an axis parallel rectangle.
TextureFiltering getTextureFiltering() const
SDL_PixelFormat m_rgba_format
void setBackgroundColor(uint8_t r, uint8_t g, uint8_t b)
Set the background color.
virtual const std::string & getName() const =0
The name of the renderbackend.
uint32_t getHeight() const
virtual void createMainScreen(const ScreenMode &mode, const std::string &title, const std::string &icon)=0
Creates the mainscreen (the display window).
virtual void detachRenderTarget()=0
Detaches current render surface.
bool isFrameLimitEnabled() const
Gets whether the frame limiter is in use.
bool isFramebufferEnabled() const
int32_t getMaxAnisotropy() const
Gets max antisotropy for antisotropic filtering.
void setColorKeyEnabled(bool colorkeyenable)
Sets whether to use the colorkey feature.
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.
uint16_t getFrameLimit() const
Gets the frame limit.
virtual void clearBackBuffer()=0
Forces a clear of the backbuffer.
virtual void drawVertex(const Point &p, const uint8_t size, uint8_t r, uint8_t g, uint8_t b, uint8_t a=255)=0
Draws a quad that represents a vertex with given RGBA.
virtual uint32_t getLightingModel() const =0
Gets the current light model.
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)=0
Draws triangle between given points with given RGBA.
bool isMipmappingEnabled() const
void resetBackgroundColor()
Reset the background color to black.
bool isColorKeyEnabled() const
Gets whether the colorkey feature is in use.
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)=0
Dirty helper function to change the render infos.
void pushClipArea(const Rect &cliparea, bool clear=true)
Pushes clip area to clip stack Clip areas define which area is drawn on screen.
const SDL_Color & getColorKey() const
Gets the global colorkey setting.
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.
uint32_t getScreenWidth() const
virtual bool putPixel(int32_t x, int32_t y, uint8_t r, uint8_t g, uint8_t b, uint8_t a=255)=0
Writes pixel to given position.
virtual ~RenderBackend()
Destructor.
void setTextureFiltering(TextureFiltering filter)
Sets the texture filtering method.
void popClipArea()
Pops clip area from clip stack.
virtual void drawLine(const Point &p1, const Point &p2, uint8_t r, uint8_t g, uint8_t b, uint8_t a=255)=0
Draws line between given points with given RGBA.
void setAlphaOptimizerEnabled(bool enabled)
Enable or disable the alpha 'optimizing' code.
void setDepthBufferEnabled(bool enabled)
Enables or disables depth buffer rendering.
SDL_Color m_backgroundcolor
bool isMonochromeEnabled() const
virtual void enableScissorTest()=0
Enables scissor test on the render backend.
uint32_t getWidth() const
virtual void endFrame()
Called when a frame is finished and ready to be displayed.
shared pointer implementation to provide automatic reference counting and deletion when last referenc...
void clearClipArea()
Clears any possible clip areas.
virtual void changeBlending(int32_t scr, int32_t dst)=0
Change the Blendingmodel.
void setFrameLimitEnabled(bool limited)
Sets whether to use the frame limiter.
virtual void captureScreen(const std::string &filename)=0
Creates a Screenshot and saves it to a file.
SDL_Surface * getRenderTargetSurface()
Returns currently attached render surface.
TextureFiltering m_textureFilter
virtual Image * createImage(IResourceLoader *loader=0)=0
virtual void attachRenderTarget(ImagePtr &img, bool discard)=0
Attaches given image as a new render surface.
bool isImageCompressingEnabled() const
virtual void renderVertexArrays()=0
Render the Vertex Arrays, only for primitives (points, lines,...)
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)=0
Draws a filled axis parallel rectangle.
const SDL_PixelFormat & getPixelFormat() const
Gets the current screen rgba format.
const Rect & getClipArea() const
Gets the current clip area.
void deinit()
Performs cleanup actions.
std::stack< ClipInfo > m_clipstack
float getAlphaTestValue() const
bool isDepthBufferEnabled() const
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)=0
Draws a light primitive that based on a triangle fan.
virtual void resetLighting()=0
Reset lighting with default values.
virtual void resetStencilBuffer(uint8_t buffer)=0
Reset stencil buffer with given value.
void setImageCompressingEnabled(bool enabled)
Enables or disable compressing images by video driver.
bool isNPOTEnabled() const
virtual void setScreenMode(const ScreenMode &mode)=0
Sets the mainscreen display mode.
const ScreenMode & getCurrentScreenMode() const
Get current screen mode.
virtual void setLightingModel(uint32_t lighting)=0
Initializes the light.
bool isAlphaOptimizerEnabled() const
const Rect & getArea() const
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)=0
Draws quad between given points with given RGBA.