Aufgabe 7: Anwendung
Driver managing the video mode and synchronizing its buffer with the graphics printer. More...
#include <device/graphics.h>
Public Member Functions | |
Graphics (unsigned size, void *frontbuffer, void *backbuffer) | |
Constructor. More... | |
bool | init (bool force=false) |
Initialize GraphicsPrinter according to the current video mode. More... | |
bool | switchBuffers () |
Switch front and back buffer (only if front buffer was already copied to video memory) More... | |
void | scanoutFrontbuffer () |
Copy current front buffer to the video memory. | |
void | clear () |
Clear all pixel of the current back buffer (set full screen to black) | |
bool | valid (const Point &p) |
Check if a Point can be displayed at the current resolution. More... | |
unsigned | height () |
Number of vertical pixels in current resolution. More... | |
unsigned | width () |
Number of horizontal pixels in current resolution. More... | |
void | pixel (const Point &p, const Color &color) |
Draw a pixel on the current back buffer. More... | |
void | pixel (const Point &p, const ColorAlpha &color) |
Draw a pixel on the current back buffer. More... | |
void | line (const Point &start, const Point &end, const Color &color) |
Draw a line on the current back buffer. More... | |
void | line (const Point &start, const Point &end, const ColorAlpha &color) |
Draw a line on the current back buffer. More... | |
void | rectangle (const Point &start, const Point &end, const Color &color, bool filled=true) |
Draw a rectangle on the current back buffer. More... | |
void | rectangle (const Point &start, const Point &end, const ColorAlpha &color, bool filled=true) |
Draw a rectangle on the current back buffer. More... | |
void | font (const Font &new_font) |
Change the current font for text output in video mode. More... | |
void | text (const Point &p, const char *string, unsigned len, const Color &color, const Font *font=nullptr) |
Print text (without automatic word wrap) on the current back buffer. More... | |
void | text (const Point &p, const char *string, unsigned len, const ColorAlpha &color, const Font *font=nullptr) |
Print text (without automatic word wrap) on the current back buffer. More... | |
void | image (const Point &p, PNG &image, unsigned width=0, unsigned height=0, unsigned offset_x=0, unsigned offset_y=0) |
Draw a PNG image [detail] on the current back buffer. More... | |
void | image (const Point &p, const GIMP &image, unsigned width=0, unsigned height=0, unsigned offset_x=0, unsigned offset_y=0) |
Draw a GIMP image [detail] on the current back buffer. More... | |
void | image (const Point &p, const Color *image, unsigned width, unsigned height, unsigned offset_x=0, unsigned offset_y=0) |
Draw a sprite on the current back buffer. More... | |
void | image (const Point &p, const ColorAlpha *image, unsigned width, unsigned height, unsigned offset_x=0, unsigned offset_y=0) |
Draw a sprite with alpha blending (transparency) on the current back buffer. More... | |
Detailed Description
Driver managing the video mode and synchronizing its buffer with the graphics printer.
This device detects the current video mode set by the Multiboot compliant boot loader and initializes a suitable GraphicsPrinter.
With the methods Graphics::switchBuffers() (to exchange front- and backbuffer) and Graphics::scanoutFrontbuffer() (copying the contents of the frontbuffer into the video memory) it provides some kind of manually triple buffering.
A typical usage is to fully prepare the back buffer before switching it with the front buffer
The method Graphics::scanoutFrontbuffer() has to be executed either inside the loop (right after Graphics::switchBuffers() in the example above) or at a predefined interval by employing the Watch.
- Note
- The driver requires Multiboot to initialize a video mode, which can be configured using the flags in
boot/multiboot/config.inc
.
Constructor & Destructor Documentation
Graphics::Graphics | ( | unsigned | size, |
void * | frontbuffer, | ||
void * | backbuffer | ||
) |
Constructor.
- Parameters
-
size Size of each buffer frontbuffer Pointer to a reserved memory area with a sufficient size to transmit a full screen picture to the video memory at the current video mode / resolution. backbuffer Pointer to a reserved memory area with the same size as the front buffer to prepare the picture.
Member Function Documentation
bool Graphics::init | ( | bool | force = false | ) |
Initialize GraphicsPrinter according to the current video mode.
- Parameters
-
force Do not check video attributes for the linear frame buffer (required on our test systems due to some strange VBE behaviour)
- Returns
- 'true' if a suitable GraphicsPrinter was found for the video mode
bool Graphics::switchBuffers | ( | ) |
Switch front and back buffer (only if front buffer was already copied to video memory)
- Returns
true
if buffers have been switched,false
if previous front buffer wasn't yet fully copied to video memory.
|
inline |
Check if a Point can be displayed at the current resolution.
- Parameters
-
p Coordinates to check
- Returns
- 'true' if can be displayed
|
inline |
Number of vertical pixels in current resolution.
- Returns
- Height of the screen in current video mode
|
inline |
Number of horizontal pixels in current resolution.
- Returns
- Width of the screen in current video mode
Draw a pixel on the current back buffer.
- Parameters
-
p Coordinates of the pixel color Color of the pixel
|
inline |
Draw a pixel on the current back buffer.
- Parameters
-
p Coordinates of the pixel color Color of the pixel
Draw a line on the current back buffer.
- Parameters
-
start Coordinates of the begin of the line end Coordinates of the end of the line color Color of the line
|
inline |
Draw a line on the current back buffer.
- Parameters
-
start Coordinates of the begin of the line end Coordinates of the end of the line color Color of the line
|
inline |
Draw a rectangle on the current back buffer.
- Parameters
-
start Coordinate of the rectangles upper left corner end Coordinate of the rectangles lower right corner color Color of the rectangle filled If set, the rectangle will be filled with the same color. (otherwise only borders will be drawn)
|
inline |
Draw a rectangle on the current back buffer.
- Parameters
-
start Coordinate of the rectangles upper left corner end Coordinate of the rectangles lower right corner color Color of the rectangle filled If set, the rectangle will be filled with the same color. (otherwise only borders will be drawn)
|
inline |
Change the current font for text output in video mode.
- Parameters
-
new_font Font to be used on subsequent calls to text (without explicit font parameter)
|
inline |
Print text (without automatic word wrap) on the current back buffer.
- Parameters
-
p Upper left start position of the text string Pointer to char array containing the text to be displayed len Number of characters to be displayed color Color for the text characters font Explicit font – or nullptr
to use default font (set by font method)
|
inline |
Print text (without automatic word wrap) on the current back buffer.
- Parameters
-
p Upper left start position of the text string Pointer to char array containing the text to be displayed len Number of characters to be displayed color Color for the text characters font Explicit font – or nullptr
to use default font (set by font method)
|
inline |
Draw a PNG image [detail] on the current back buffer.
The image can has to be in a supported PNG format. Alpha blending (transparency) is supported.
- Parameters
-
p Coordinate of the images upper left corner image Source image to display width Width of the image detail (full image width of the source image if zero/default value) height Height of the image detail (full image height of the source if zero/default value) offset_x Right offset of the source image offset_y Top offset of the source image
|
inline |
Draw a GIMP image [detail] on the current back buffer.
The image has to be exported as C-source (without Glib
types!) in GIMP, alpha blending (transparency) is supported.
- Parameters
-
p Coordinate of the images upper left corner image Source image to display width Width of the image detail (full image width of the source image if zero/default value) height Height of the image detail (full image height of the source if zero/default value) offset_x Right offset of the source image offset_y Top offset of the source image
|
inline |
Draw a sprite on the current back buffer.
Each element in the source array will be displayed as a single pixel.
- Parameters
-
p Coordinate of the sprites upper left corner image Source sprite to display width Width of the sprite detail height Height of the sprite detail offset_x Right offset of the source sprite offset_y Top offset of the source sprite
|
inline |
Draw a sprite with alpha blending (transparency) on the current back buffer.
Each element in the source array will be displayed as a single pixel.
- Parameters
-
p Coordinate of the sprites upper left corner image Source sprite to display width Width of the sprite detail height Height of the sprite detail offset_x Right offset of the source sprite offset_y Top offset of the source sprite
The documentation for this class was generated from the following files:
- device/graphics.h
- device/graphics.cc