Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <tile.hpp>
- using namespace kit;
- void Scene::drawBg(){
- if(bmp_bg == nullptr) return;
- shape::point sizeBmp = bmp_bg->getSize();
- if(sizeBmp.x<1 || sizeBmp.y<1) return;
- if(stretch_bg){ //stretch entire background to entire canvas
- bmp_bg->blitRect();
- } else { //otherwise, repeat background bitmap in a tile pattern
- shape::rect dst; //destination rectangle
- dst.w = sizeBmp.x;
- dst.h = sizeBmp.y;
- shape::point sizeCanvas = gl_win->getCanvasSize();
- //increase x, then y until the entire canvas is drawn to
- for(dst.y = 0; dst.y < sizeCanvas.y; dst.y += dst.h)
- for(dst.x = 0; dst.x < sizeCanvas.x; dst.x += dst.w)
- {
- bmp_bg->blitRect(&dst, nullptr); //whole bitmap is used when src = nullptr
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement