experiment #1: writing some pixels in the framebuffer device and cls
[winnie] / src / main.cc
1 #include <stdio.h>
2
3 #include "gfx.h"
4
5 int main()
6 {
7         if(!init_gfx()) {
8                 return 1;
9         }
10
11         set_cursor_visibility(false);
12
13         unsigned char* fb = get_framebuffer();
14         Rect scrn_sz = get_screen_size();
15
16         for(int i=0; i<scrn_sz.height; i++) {
17                 for(int j=0; j<scrn_sz.width; j++) {
18                         unsigned char color0[3] = {255, 0, 0};
19                         unsigned char color1[3] = {0, 0, 255};
20                         unsigned char* color;
21
22                         //red blue chessboard 16 pxls size
23                         if(((j >> 4) & 1) == ((i >> 4) & 1)) {
24                                 color = color0;
25                         }
26                         else {
27                                 color = color1;
28                         }
29
30                         *fb++ = color[0];
31                         *fb++ = color[1];
32                         *fb++ = color[2];
33                         fb++;
34                 }
35         }
36
37         getchar();
38         clear_screen(0, 0, 0);
39
40         destroy_gfx();
41 }