38 m_compressimages(false),
39 m_useframebuffer(false),
41 m_isalphaoptimized(false),
42 m_iscolorkeyenabled(false),
44 m_isMipmapping(false),
48 m_isDepthBuffer(false),
51 m_isframelimit(false),
65 SDL_QuitSubSystem(SDL_INIT_VIDEO);
79 if (frame_time < frame_limit) {
80 SDL_Delay(static_cast<Uint32>(frame_limit) - frame_time);
247 }
else if (t >= static_cast<double>(elements)) {
248 return points.back();
254 int32_t n = elements - 1;
256 double mu =
static_cast<double>(t) / static_cast<double>(elements);
257 double munk =
Mathd::Pow(1.0 - mu, static_cast<double>(n));
258 for (int32_t i = 0; i <= n; ++i) {
261 int32_t diffn = n - i;
262 double blend = muk * munk;
266 blend *=
static_cast<double>(tmpn);
269 blend /=
static_cast<double>(tmpi);
273 blend /=
static_cast<double>(diffn);
277 px +=
static_cast<double>(points[i].x) * blend;
278 py +=
static_cast<double>(points[i].y) * blend;
281 return Point(static_cast<int32_t>(px), static_cast<int32_t>(py));
285 if (points.empty()) {
289 int32_t n = points.size() - 1;
298 newPoints.push_back(points[0]);
299 p.
x = (2 * points[0].x + points[1].x) / 3;
300 p.
y = (2 * points[0].y + points[1].y) / 3;
301 newPoints.push_back(p);
302 p.
x = 2 * p.
x - points[0].x;
303 p.
y = 2 * p.
y - points[0].y;
304 newPoints.push_back(p);
305 newPoints.push_back(points[1]);
310 float* xrhs =
new float[n];
311 float* yrhs =
new float[n];
313 xrhs[0] = points[0].x + 2 * points[1].x;
314 yrhs[0] = points[0].y + 2 * points[1].y;
316 xrhs[n - 1] = (8 * points[n - 1].x + points[n].x) / 2.0;
317 yrhs[n - 1] = (8 * points[n - 1].y + points[n].y) / 2.0;
319 for (int32_t i = 1; i < n - 1; ++i) {
320 xrhs[i] = 4 * points[i].x + 2 * points[i + 1].x;
321 yrhs[i] = 4 * points[i].y + 2 * points[i + 1].y;
324 float* x =
new float[n];
325 float* y =
new float[n];
326 float* xtmp =
new float[n];
327 float* ytmp =
new float[n];
333 for (int32_t i = 1; i < n; i++) {
336 xb = (i < n - 1 ? 4.0 : 3.5) - xtmp[i];
337 yb = (i < n - 1 ? 4.0 : 3.5) - ytmp[i];
338 x[i] = (xrhs[i] - x[i - 1]) / xb;
339 y[i] = (yrhs[i] - y[i - 1]) / yb;
342 for (int32_t i = 1; i < n; i++) {
343 x[n - i - 1] -= xtmp[n - i] * x[n - i];
344 y[n - i - 1] -= ytmp[n - i] * y[n - i];
348 newPoints.push_back(points[0]);
349 for (int32_t i = 0; i < n - 1; ++i) {
352 newPoints.push_back(p);
353 p.
x = 2 * points[i + 1].x - x[i + 1];
354 p.
y = 2 * points[i + 1].y - y[i + 1];
355 newPoints.push_back(p);
357 newPoints.push_back(points[i+1]);
361 newPoints.push_back(p);
362 p.
x = (points[n].x + x[n - 1]) / 2;
363 p.
y = (points[n].y + y[n - 1]) / 2;
364 newPoints.push_back(p);
366 newPoints.push_back(points[n]);
virtual void setClipArea(const Rect &cliparea, bool clear)=0
Sets given clip area into image.
uint32_t getHeight() const
RenderBackend(const SDL_Color &colorkey)
Constructor.
void setColorKey(const SDL_Color &colorkey)
Sets the global colorkey to use for images.
void setMonochromeEnabled(bool enabled)
Enables or disables monochrome rendering.
const SDL_Color & getColorKey() const
Gets the global colorkey setting.
bool isColorKeyEnabled() const
Gets whether the colorkey feature is in use.
const ScreenMode & getCurrentScreenMode() const
Get current screen mode.
SDL_PixelFormat m_rgba_format
void setBackgroundColor(uint8_t r, uint8_t g, uint8_t b)
Set the background color.
void addControlPoints(const std::vector< Point > &points, std::vector< Point > &newPoints)
Helper that adds the control points for bezier curves.
bool isMonochromeEnabled() const
void setColorKeyEnabled(bool colorkeyenable)
Sets whether to use the colorkey feature.
bool isFrameLimitEnabled() const
Gets whether the frame limiter is in use.
void resetBackgroundColor()
Reset the background color to black.
float getAlphaTestValue() const
PointType2D< int32_t > Point
static T Pow(T _base, T _exponent)
const SDL_PixelFormat & getPixelFormat() const
Gets the current screen rgba format.
void pushClipArea(const Rect &cliparea, bool clear=true)
Pushes clip area to clip stack Clip areas define which area is drawn on screen.
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.
int32_t getMaxAnisotropy() const
Gets max antisotropy for antisotropic filtering.
SDL_Surface * getScreenSurface()
Returns screen render surface.
virtual ~RenderBackend()
Destructor.
void setTextureFiltering(TextureFiltering filter)
Sets the texture filtering method.
void popClipArea()
Pops clip area from clip stack.
void setDepthBufferEnabled(bool enabled)
Enables or disables depth buffer rendering.
const Rect & getClipArea() const
Gets the current clip area.
SDL_Color m_backgroundcolor
virtual void endFrame()
Called when a frame is finished and ready to be displayed.
bool isVSyncEnabled() const
Gets whether VSync is in use.
void clearClipArea()
Clears any possible clip areas.
void setFrameLimitEnabled(bool limited)
Sets whether to use the frame limiter.
const Rect & getArea() const
SDL_Surface * getRenderTargetSurface()
Returns currently attached render surface.
TextureFiltering m_textureFilter
Point getBezierPoint(const std::vector< Point > &points, int32_t elements, float t)
Helper that returns an interpolated Point.
uint32_t getWidth() const
void deinit()
Performs cleanup actions.
bool isDepthBufferEnabled() const
std::stack< ClipInfo > m_clipstack
void setVSyncEnabled(bool vsync)
Sets whether to use VSync.
bool isMipmappingEnabled() const
uint16_t getFrameLimit() const
Gets the frame limit.
TextureFiltering getTextureFiltering() const