Max OS 0.3
Loading...
Searching...
No Matches
graphicsContext.cpp
Go to the documentation of this file.
1
10
11using namespace MaxOS::common;
12
13
18
19
20 // VirtualBox VGA palette
21 m_colour_pallet[0x00] = Colour(0x00, 0x00, 0x00); // Black
22 m_colour_pallet[0x01] = Colour(0x00, 0x00, 0xA8); // Duke Blue
23 m_colour_pallet[0x02] = Colour(0x00, 0xA8, 0x00); // Islamic Green
24 m_colour_pallet[0x03] = Colour(0x00, 0xA8, 0xA8); // Persian Green
25 m_colour_pallet[0x04] = Colour(0xA8, 0x00, 0x00); // Dark Candy Apple Red
26 m_colour_pallet[0x05] = Colour(0xA8, 0x00, 0xA8); // Heliotrope Magenta
27
28 m_colour_pallet[0x06] = Colour(0xA8, 0xA8, 0x00); // Light Gold
29 m_colour_pallet[0x07] = Colour(0xA8, 0xA8, 0xA8); // Dark Gray (X11)
30 m_colour_pallet[0x08] = Colour(0x00, 0x00, 0x57); // Cetacean Blue
31 m_colour_pallet[0x09] = Colour(0x00, 0x00, 0xFF); // Blue
32 m_colour_pallet[0x0A] = Colour(0x00, 0xA8, 0x57); // Green (Pigment)
33 m_colour_pallet[0x0B] = Colour(0x00, 0xA8, 0xFF); // Vivid Cerulean
34 m_colour_pallet[0x0C] = Colour(0xA8, 0x00, 0x57); // Jazz berry Jam
35 m_colour_pallet[0x0D] = Colour(0xA8, 0x00, 0x57); // Jazz berry Jam
36 m_colour_pallet[0x0E] = Colour(0xA8, 0xA8, 0x57); // Olive Green
37 m_colour_pallet[0x0F] = Colour(0xA8, 0xA8, 0xFF); // Maximum Blue Purple
38
39 m_colour_pallet[0x10] = Colour(0x00, 0x57, 0x00); // Dark Green (X11)
40 m_colour_pallet[0x11] = Colour(0x00, 0x57, 0xA8); // Cobalt Blue
41 m_colour_pallet[0x12] = Colour(0x00, 0xFF, 0x00); // Electric Green
42 m_colour_pallet[0x13] = Colour(0x00, 0xFF, 0xA8); // Medium Spring Green
43 m_colour_pallet[0x14] = Colour(0xA8, 0x57, 0x00); // Windsor Tan
44 m_colour_pallet[0x15] = Colour(0xA8, 0x57, 0xA8); // Purpureus
45 m_colour_pallet[0x16] = Colour(0xA8, 0xFF, 0x00); // Spring Bud
46 m_colour_pallet[0x17] = Colour(0xA8, 0xFF, 0xA8); // Mint Green
47 m_colour_pallet[0x18] = Colour(0x00, 0x57, 0x57); // Midnight Green (Eagle Green)
48 m_colour_pallet[0x19] = Colour(0x00, 0x57, 0xFF); // Blue (RYB)
49 m_colour_pallet[0x1A] = Colour(0x00, 0xFF, 0x57); // Malachite
50 m_colour_pallet[0x1B] = Colour(0x00, 0xFF, 0xFF); // Aqua
51 m_colour_pallet[0x1C] = Colour(0xA8, 0x57, 0x57); // Middle Red Purple
52 m_colour_pallet[0x1D] = Colour(0xA8, 0x57, 0xFF); // Lavender Indigo
53 m_colour_pallet[0x1E] = Colour(0xA8, 0xFF, 0x57); // Olive Green
54 m_colour_pallet[0x1F] = Colour(0xA8, 0xFF, 0xFF); // Celeste
55
56 m_colour_pallet[0x20] = Colour(0x57, 0x00, 0x00); // Blood Red
57 m_colour_pallet[0x21] = Colour(0x57, 0x00, 0xA8); // Metallic Violet
58 m_colour_pallet[0x22] = Colour(0x57, 0xA8, 0x00); // Kelly Green
59 m_colour_pallet[0x23] = Colour(0x57, 0xA8, 0xA8); // Cadet Blue
60 m_colour_pallet[0x24] = Colour(0xFF, 0x00, 0x00); // Red
61 m_colour_pallet[0x25] = Colour(0xFF, 0x00, 0xA8); // Fashion Fuchsia
62 m_colour_pallet[0x26] = Colour(0xFF, 0xA8, 0x00); // Chrome Yellow
63 m_colour_pallet[0x27] = Colour(0xFF, 0xA8, 0xA8); // Light Salmon Pink
64 m_colour_pallet[0x28] = Colour(0x57, 0x00, 0x57); // Imperial Purple
65 m_colour_pallet[0x29] = Colour(0x57, 0x00, 0xFF); // Electric Indigo
66 m_colour_pallet[0x2A] = Colour(0x57, 0xA8, 0x57); // Apple
67 m_colour_pallet[0x2B] = Colour(0x57, 0xA8, 0xFF); // Blue Jeans
68 m_colour_pallet[0x2C] = Colour(0xFF, 0x00, 0x57); // Folly
69 m_colour_pallet[0x2D] = Colour(0xFF, 0x00, 0xFF); // Fuchsia
70 m_colour_pallet[0x2E] = Colour(0xFF, 0xA8, 0x57); // Rajah
71 m_colour_pallet[0x2F] = Colour(0xFF, 0xA8, 0xFF); // Rich Brilliant Lavender
72
73 m_colour_pallet[0x30] = Colour(0x57, 0x57, 0x00); // Dark Bronze (Coin)
74 m_colour_pallet[0x31] = Colour(0x57, 0x57, 0xA8); // Liberty
75 m_colour_pallet[0x32] = Colour(0x57, 0xFF, 0x00); // Chlorophyll Green
76 m_colour_pallet[0x33] = Colour(0x57, 0xFF, 0xA8); // Medium Aquamarine
77 m_colour_pallet[0x34] = Colour(0xFF, 0x57, 0x00); // Orange (Pantone)
78 m_colour_pallet[0x35] = Colour(0xFF, 0x57, 0xA8); // Brilliant Rose
79 m_colour_pallet[0x36] = Colour(0xFF, 0xFF, 0x00); // Yellow
80 m_colour_pallet[0x37] = Colour(0xFF, 0xFF, 0xA8); // Calamansi
81 m_colour_pallet[0x38] = Colour(0x57, 0x57, 0x57); // Davy's Grey
82 m_colour_pallet[0x39] = Colour(0x57, 0x57, 0xFF); // Very Light Blue
83 m_colour_pallet[0x3A] = Colour(0x57, 0xFF, 0x57); // Screamin' Green
84 m_colour_pallet[0x3B] = Colour(0x57, 0xFF, 0xFF); // Electric Blue
85 m_colour_pallet[0x3C] = Colour(0xFF, 0x57, 0x57); // Sunset Orange
86 m_colour_pallet[0x3D] = Colour(0xFF, 0x57, 0xFF); // Shocking Pink (Crayola)
87 m_colour_pallet[0x3E] = Colour(0xFF, 0xFF, 0x57); // Shocking Pink (Crayola)
88 m_colour_pallet[0x3F] = Colour(0xFF, 0xFF, 0xFF); // White
89
90
91 // Set the rest of the palette to black
92 for(uint8_t color_code = 255; color_code >= 0x40; --color_code)
93 m_colour_pallet[color_code] = Colour(0, 0, 0);
94
95
96}
97
98GraphicsContext::~GraphicsContext() = default;
99
107void GraphicsContext::render_pixel(uint32_t x, uint32_t y, uint32_t colour) {
108
109 // Call the correct put_pixel function based on the color depth
110 switch(m_color_depth) {
111 case 8:
112 render_pixel_8_bit(x, y, colour);
113 break;
114 case 16:
115 render_pixel_16_bit(x, y, colour);
116 break;
117 case 24:
118 render_pixel_24_bit(x, y, colour);
119 break;
120 case 32:
121 render_pixel_32_bit(x, y, colour);
122 break;
123 }
124
125
126}
127
135void GraphicsContext::render_pixel_8_bit(uint32_t, uint32_t, uint8_t) {
136
137}
138
146void GraphicsContext::render_pixel_16_bit(uint32_t, uint32_t, uint16_t) {
147
148}
149
157void GraphicsContext::render_pixel_24_bit(uint32_t, uint32_t, uint32_t) {
158
159}
160
168void GraphicsContext::render_pixel_32_bit(uint32_t, uint32_t, uint32_t) {
169
170}
171
179uint32_t GraphicsContext::get_rendered_pixel(uint32_t x, uint32_t y) {
180 // Call the correct get_pixel function based on the color depth
181 switch(m_color_depth) {
182 case 8:
183 return get_rendered_pixel_8_bit(x, y);
184 case 16:
185 return get_rendered_pixel_16_bit(x, y);
186 case 24:
187 return get_rendered_pixel_24_bit(x, y);
188 case 32:
189 return get_rendered_pixel_32_bit(x, y);
190 }
191
192 return colour_to_int(Colour(0xFF, 0xFF, 0xFF));
193}
194
202uint8_t GraphicsContext::get_rendered_pixel_8_bit(uint32_t, uint32_t) {
203 return 0;
204}
205
213uint16_t GraphicsContext::get_rendered_pixel_16_bit(uint32_t, uint32_t) {
214 return 0;
215}
216
224uint32_t GraphicsContext::get_rendered_pixel_24_bit(uint32_t, uint32_t) {
225 return 0;
226}
227
235uint32_t GraphicsContext::get_rendered_pixel_32_bit(uint32_t x, uint32_t y) {
236 return 0;
237}
238
245uint32_t GraphicsContext::colour_to_int(const Colour& colour) {
246 return colour_to_int(colour, m_color_depth);
247}
248
256uint32_t GraphicsContext::colour_to_int(const Colour& colour, uint32_t color_depth) {
257
258 switch(color_depth) {
259 case 8: {
260 uint32_t result = 0;
261 int mindistance = 0xfffffff;
262 for(uint32_t i = 0; i <= 255; ++i) {
263// Colour* c = &m_colour_pallet[i];
264 Colour* c = nullptr; //@todo fix this
265 int distance =
266 ((int) colour.red - (int) c->red) * ((int) colour.red - (int) c->red)
267 + ((int) colour.green - (int) c->green) * ((int) colour.green - (int) c->green)
268 + ((int) colour.blue - (int) c->blue) * ((int) colour.blue - (int) c->blue);
269 if(distance < mindistance) {
270 mindistance = distance;
271 result = i;
272 }
273 }
274 return result;
275 }
276 case 16: {
277 // 16-Bit colours RRRRRGGGGGGBBBBB
278 return ((uint16_t) (colour.red & 0xF8)) << 8
279 | ((uint16_t) (colour.green & 0xFC)) << 3
280 | ((uint16_t) (colour.blue & 0xF8) >> 3);
281 }
282 case 24: {
283 return (uint32_t) colour.red << 16
284 | (uint32_t) colour.green << 8
285 | (uint32_t) colour.blue;
286 }
287 default:
288 case 32: {
289 uint32_t red_hex = ((uint32_t) colour.red & 0xFF) << 16;
290 uint32_t green_hex = ((uint32_t) colour.green & 0xFF) << 8;
291 uint32_t blue_hex = (uint32_t) colour.blue & 0xFF;
292 uint32_t alpha_hex = ((uint32_t) colour.alpha & 0xFF) << 24;
293
294 uint32_t hex_value = red_hex | green_hex | blue_hex | alpha_hex;
295
296
297 return hex_value;
298 }
299 }
300}
301
308Colour GraphicsContext::int_to_colour(uint32_t colour) {
309 switch(m_color_depth) {
310
311 case 8: {
312 // Return the colour from the palette
313 return m_colour_pallet[colour & 0xFF];
314 }
315
316 case 16: {
317 // 16-Bit Colour: 5 bits for red, 6 bits for green, 5 bits for blue (RRRRR,GGGGGG,BBBBB)
318 Colour result;
319
320 result.red = (colour & 0xF800) >> 8;
321 result.green = (colour & 0x07E0) >> 3;
322 result.blue = (colour & 0x001F) << 3;
323
324 return result;
325 }
326
327 case 24: {
328 // 24-Bit Colour: 8 bits for red, 8 bits for green, 8 bits for blue (RRRRRRRR,GGGGGGGG,BBBBBBBB)
329 Colour result;
330
331 result.red = (colour & 0xFF0000) >> 16;
332 result.green = (colour & 0x00FF00) >> 8;
333 result.blue = (colour & 0x0000FF);
334
335 return result;
336 }
337
338 default:
339 case 32: {
340 Colour result;
341
342 uint32_t hex_value = colour;
343 result.red = (hex_value >> 16) & 0xFF;
344 result.green = (hex_value >> 8) & 0xFF;
345 result.blue = hex_value & 0xFF;
346 result.alpha = (hex_value >> 24) & 0xFF;
347
348 return result;
349
350 }
351 }
352}
353
359uint32_t GraphicsContext::width() const {
360 return m_width;
361}
362
368uint32_t GraphicsContext::height() const {
369 return m_height;
370}
371
377 return m_color_depth;
378}
379
387void GraphicsContext::put_pixel(uint32_t x, uint32_t y, const Colour& colour) {
388
389 // Convert the colour to an integer and then print it
390 put_pixel(x, y, colour_to_int(colour));
391}
392
402void GraphicsContext::put_pixel(uint32_t x, uint32_t y, uint32_t colour) {
403
404 // Check bounds
405 if(x >= m_width || y >= m_height)
406 return;
407
408 // Render the pixel
409 render_pixel(x, mirror_y_axis ? m_height - y - 1 : y, colour);
410
411}
412
420Colour GraphicsContext::get_pixel(uint32_t x, uint32_t y) {
421
422 // Check bounds
423 if(x >= m_width || y >= m_height)
424 return { 0, 0, 0 };
425
426 // Get the pixel and convert it to a colour
427 uint32_t translated_color = get_rendered_pixel(x, mirror_y_axis ? m_height - y - 1 : y);
428 return int_to_colour(translated_color);
429}
430
437void GraphicsContext::invert_pixel(uint32_t x, uint32_t y) {
438
439 // Get the pixel
440 Colour colour = get_pixel(x, y);
441
442 // Invert the pixel
443 colour.red = 255 - colour.red;
444 colour.green = 255 - colour.green;
445 colour.blue = 255 - colour.blue;
446
447 // Render the pixel
448 put_pixel(x, y, colour);
449}
450
451
461void GraphicsContext::draw_line(uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1, const Colour& colour) {
462 draw_line(x0, y0, x1, y1, colour_to_int(colour));
463}
464
474void GraphicsContext::draw_line(uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1, uint32_t colour) {
475
476 // Store the minimum and maximum y values
477 bool y_0_is_smaller = y0 < y1;
478 int32_t y_min = y_0_is_smaller ? y0 : y1;
479 int32_t y_max = y_0_is_smaller ? y1 : y0;
480
481 //Reverse the points to draw from left to right
482 if(x1 < x0) {
483 draw_line(x1, y1, x0, y0, colour);
484 return;
485 }
486
487 // Vertical line
488 if(x1 == x0) {
489 // Force the line to be within the screen
490 if(y_min < 0) y_min = 0;
491 if(y_max >= m_height)
492 y_max = m_height - 1;
493
494 // Mirror the Y axis as directly calling put_pixel will not do this
495 if(mirror_y_axis) {
496 int32_t temp = y_max;
497 y_max = m_height - y_min - 1;
498 y_min = m_height - temp - 1;
499 }
500
501 // Check that the line is within the screen
502 if(0 > x0 || x0 >= m_width) {
503 return;
504 }
505
506 // Draw the line
507 for(int32_t y = y_min; y <= y_max; ++y)
508 put_pixel(x0, y, colour);
509
510 return;
511 }
512
513 // Horizontal line
514 if(y1 == y0) {
515 // Ensure the line is within the screen
516 if(x0 < 0) x0 = 0;
517 if(x1 >= m_width) x1 = m_width - 1;
518
519 // Mirror the Y axis as directly calling put_pixel will not do this
520 if(mirror_y_axis)
521 y0 = m_height - y0 - 1;
522
523 // Check that the line is within the screen
524 if(0 > y0 || y0 >= m_height)
525 return;
526
527 // Draw the line
528 for(int32_t x = x0; x <= x1; ++x)
529 put_pixel(x, y0, colour);
530 }
531
532 // If the line is not horizontal or vertical then it must be a diagonal line
533 // Find the slope of the line
534// float slope = ((float) (y1 - y0)) / (x1 - x0);
535 int slope = 1; // replace when in userland
536
537 // A slope that is more horizontal should be drawn by incrementing x
538 if(-1 <= slope && slope <= 1) {
539 int y = y0;
540 for(int32_t x = x0; x <= x1; x++, y += slope)
541 put_pixel(x, (int32_t) y, colour);
542 }
543
544 // A slope that is more vertical should be drawn by incrementing y
545 else {
546 // Invert the slope
547 slope = 1 / slope;
548
549 int x = x0;
550 for(int32_t y = y_min; y <= y_max; x += slope, y++)
551 put_pixel((int32_t) x, y, colour);
552 }
553}
554
564void GraphicsContext::draw_rectangle(uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1, const Colour& colour) {
565 draw_rectangle(x0, y0, x1, y1, colour_to_int(colour));
566
567}
568
578void GraphicsContext::draw_rectangle(uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1, uint32_t colour) {
579
580 // Ensure x and y 0 is smaller than x and y 1
581 --y0;
582 --x0;
583
584 // Draw the rectangle
585 draw_line(x0, y0, x1, y0, colour); // Top
586 draw_line(x0, y1, x1, y1, colour); // Bottom
587 draw_line(x0, y0, x0, y1, colour); // Left
588 draw_line(x1, y0, x1, y1, colour); // Right
589
590}
591
601void GraphicsContext::fill_rectangle(uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1, const Colour& colour) {
602 fill_rectangle(x0, y0, x1, y1, colour_to_int(colour));
603}
604
614void GraphicsContext::fill_rectangle(uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1, uint32_t colour) {
615
616 // Draw from left to right
617 if(y1 < y0) {
618 fill_rectangle(x1, y1, x0, y0, colour);
619 return;
620 }
621
622 // Make sure the rectangle is within the height of the screen
623 if(y0 < 0) y0 = 0;
624 if(y1 > m_height) y1 = m_height;
625
626 // Make sure the rectangle is within the width of the screen
627 bool x_0_is_smaller = x0 < x1;
628 int32_t x_min = x_0_is_smaller ? x0 : x1;
629 int32_t x_max = x_0_is_smaller ? x1 : x0;
630
631 if(x_min < 0) x_min = 0;
632 if(x_max > m_width)
633 x_max = m_width;
634
635 // Mirror the Y axis as directly calling put_pixel will not do this
636 if(mirror_y_axis) {
637 int32_t temp = y1;
638 y1 = m_height - y0 - 1;
639 y0 = m_height - temp - 1;
640 }
641
642 // Draw the rectangle
643 for(int32_t y = y0; y < y1; ++y) {
644 for(int32_t x = x_min; x < x_max; ++x) {
645 put_pixel(x, y, colour);
646 }
647 }
648
649}
650
659void GraphicsContext::draw_circle(uint32_t x0, uint32_t y0, uint32_t radius, const Colour& colour) {
660 draw_circle(x0, y0, radius, colour_to_int(colour));
661}
662
671void GraphicsContext::draw_circle(uint32_t x0, uint32_t y0, uint32_t radius, uint32_t colour) {
672
673 // Make sure the circle is with in the width and height of the screen
674 if(x0 < 0) x0 = 0;
675 if(x0 > m_width) x0 = m_width;
676 if(y0 < 0) y0 = 0;
677 if(y0 > m_height) y0 = m_height;
678
679 // Mirror the Y axis as directly calling put_pixel will not do this
680 if(mirror_y_axis)
681 y0 = m_height - y0 - 1;
682
683
684 // Begin drawing at the left most point of the circle and draw a line to the right most point of the circle
685 for(int32_t x = -radius; x <= radius; ++x) {
686
687 // Draw a line from the top most point of the circle to the bottom most point of the circle
688 for(int32_t y = -radius; y <= radius; ++y) {
689
690 // If the point is within the circle, draw it but make sure it is only part of the outline
691 if(x * x + y * y <= radius * radius && x * x + y * y >= (radius - 1) * (radius - 1))
692 put_pixel(x0 + x, y0 + y, colour);
693 }
694 }
695
696
697}
698
707void GraphicsContext::fill_circle(uint32_t x0, uint32_t y0, uint32_t radius, const Colour& colour) {
708 fill_circle(x0, y0, radius, colour_to_int(colour));
709
710}
711
720void GraphicsContext::fill_circle(uint32_t x0, uint32_t y0, uint32_t radius, uint32_t colour) {
721
722 // Make sure the circle is with in the width and height of the screen
723 if(x0 < 0) x0 = 0;
724 if(x0 > m_width) x0 = m_width;
725 if(y0 < 0) y0 = 0;
726 if(y0 > m_height) y0 = m_height;
727
728 // Mirror the Y axis as directly calling put_pixel will not do this
729 if(mirror_y_axis)
730 y0 = m_height - y0 - 1;
731
732 // Draw the circle
733
734 // Begin drawing at the left most point of the circle and draw a line to the right most point of the circle
735 for(int32_t x = -radius; x <= radius; ++x) {
736
737 // Draw a line from the top most point of the circle to the bottom most point of the circle
738 for(int32_t y = -radius; y <= radius; ++y) {
739
740 // Only draw the pixel if it is within the circle
741 if(x * x + y * y <= radius * radius)
742 put_pixel(x0 + x, y0 + y, colour);
743 }
744 }
745}
746
void fill_circle(uint32_t x0, uint32_t y0, uint32_t radius, const Colour &colour)
Draws a circle on the screen, filled with a colour.
void put_pixel(uint32_t x, uint32_t y, const Colour &colour)
Renders a pixel to the screen (automatically converts the colour to an integer)
void draw_rectangle(uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1, const Colour &colour)
Draws a rectangle on the screen.
virtual uint8_t get_rendered_pixel_8_bit(uint32_t x, uint32_t y)
Gets the colour of a pixel on the screen using the 8 bit color depth.
virtual void render_pixel_8_bit(uint32_t x, uint32_t y, uint8_t colour)
Renders a pixel to the screen using the 8 bit color depth.
void invert_pixel(uint32_t x, uint32_t y)
Inverts a pixel.
uint64_t * framebuffer_address()
Gets the address of the context's framebuffer to draw on.
uint32_t m_color_depth
The color depth of the screen in bits per pixel.
Colour get_pixel(uint32_t x, uint32_t y)
Gets the colour of a pixel, or returns black if the pixel is outside the screen.
static uint32_t colour_to_int(const Colour &colour, uint32_t color_depth)
Converts a colour to an integer value based on the current color depth.
virtual void render_pixel_24_bit(uint32_t x, uint32_t y, uint32_t colour)
Renders a pixel to the screen using the 24 bit color depth.
Colour int_to_colour(uint32_t)
Converts an integer value to a colour based on the current color depth.
Colour m_colour_pallet[256]
The colour pallet for 8 bit color depth.
virtual uint32_t get_rendered_pixel_24_bit(uint32_t x, uint32_t y)
Gets the colour of a pixel on the screen using the 24 bit color depth.
virtual uint16_t get_rendered_pixel_16_bit(uint32_t x, uint32_t y)
Gets the colour of a pixel on the screen using the 16 bit color depth.
virtual uint32_t get_rendered_pixel(uint32_t x, uint32_t y)
Gets the colour of a pixel on the screen, automatically uses the correct color depth.
uint32_t width() const
Gets the width of the screen.
uint64_t * m_framebuffer_address
The address of the framebuffer.
virtual void render_pixel(uint32_t x, uint32_t y, uint32_t colour)
Renders a pixel to the screen based on the current color depth.
bool mirror_y_axis
Should the y axis be mirrored (0,0 is top left if false, bottom left if true)
uint32_t height() const
Gets the height of the screen.
uint32_t m_width
The width of the screen in pixels.
virtual void render_pixel_32_bit(uint32_t x, uint32_t y, uint32_t colour)
Renders a pixel to the screen using the 32 bit color depth.
GraphicsContext()
Constructs a GraphicsContext object and initializes the color palette.
void fill_rectangle(uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1, const Colour &colour)
Draws a rectangle on the screen, filled with a colour.
void draw_line(uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1, const Colour &colour)
Draws a line on the screen.
virtual void render_pixel_16_bit(uint32_t x, uint32_t y, uint16_t colour)
Renders a pixel to the screen using the 16 bit color depth.
virtual uint32_t get_rendered_pixel_32_bit(uint32_t x, uint32_t y)
Gets the colour of a pixel on the screen using the 32 bit color depth.
uint32_t color_depth() const
Gets the current color depth (bits per pixel)
void draw_circle(uint32_t x0, uint32_t y0, uint32_t radius, const Colour &colour)
Draws a circle on the screen.
uint32_t m_height
The height of the screen in pixels.
Defines a GraphicsContext class for drawing pixels, lines, rectangles and circles to the screen.