+
+ struct CPURenderTarget
+ {
+ uint8_t * pixels;
+ int64_t w;
+ int64_t h;
+
+
+
+ };
+
+ static Colour GetColour(const CPURenderTarget & target, int64_t x, int64_t y)
+ {
+ int64_t index = 4*(x+y*target.w);
+ if (index < 0 || index >= 4*(target.w*target.h))
+ return Colour(0,0,0,0);
+ return Colour(target.pixels[index+0],target.pixels[index+1],target.pixels[index+2],target.pixels[index+3]);
+ }
+
+ static void SetColour(const CPURenderTarget & target, int64_t x, int64_t y, const Colour & c)
+ {
+ int64_t index = 4*(x+y*target.w);
+ if (index < 0 || index >= 4*(target.w*target.h))
+ return;
+
+ target.pixels[index+0] = c.r;
+ target.pixels[index+1] = c.g;
+ target.pixels[index+2] = c.b;
+ target.pixels[index+3] = c.a;
+ }
+
+ struct PixelBounds
+ {
+ int64_t x; int64_t y; int64_t w; int64_t h;
+ PixelBounds(const Rect & bounds) : x(Double(bounds.x)), y(Double(bounds.y)), w(Double(bounds.w)), h(Double(bounds.h)) {}
+ };
+
+ typedef std::pair<int64_t, int64_t> PixelPoint;
+
+ static Rect CPURenderBounds(const Rect & bounds, const View & view, const CPURenderTarget & target);
+ static PixelPoint CPUPointLocation(const Vec2 & point, const View & view, const CPURenderTarget & target);
+
+ static void SaveBMP(const CPURenderTarget & target, const char * filename);
+
+
+ virtual void RenderUsingCPU(Objects & objects, const View & view, const CPURenderTarget & target, unsigned first_obj_id, unsigned last_obj_id) = 0;