void destroy_gfx()
{
- close(dev_fd);
+ clear_screen(0, 0, 0);
+
+ if(dev_fd != -1) {
+ close(dev_fd);
+ }
+
dev_fd = -1;
munmap(framebuffer, FRAMEBUFFER_SIZE(screen_rect.width, screen_rect.height, color_depth));
void fill_rect(const Rect &rect, int r, int g, int b)
{
- unsigned char *fb = framebuffer + rect.x + screen_rect.width * rect.y;
+ unsigned char *fb = framebuffer + (rect.x + screen_rect.width * rect.y) * 4;
for(int i=0; i<rect.height; i++) {
for(int j=0; j<rect.width; j++) {
- fb[j * 4] = r;
+ fb[j * 4] = b;
fb[j * 4 + 1] = g;
- fb[j * 4 + 2] = b;
+ fb[j * 4 + 2] = r;
}
fb += screen_rect.width * 4;
}
fprintf(stderr, "Cannot toggle cursor visibility : %s\n", strerror(errno));
}
}
+
+void blit(unsigned char *src_img, const Rect &src_rect, unsigned char* dest_img, int dest_x, int dest_y)
+{
+ Rect dest_rect;
+
+ if(dest_x < screen_rect.x) {
+ dest_rect.x = screen_rect.x;
+ }
+
+ if(dest_y < screen_rect.y) {
+ dest_rect.y = screen_rect.y;
+ }
+
+ //TODO :p zzz
+}