Bare Metal Programming Tool Kit
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
Public Member Functions | List of all members
bmptk::graphics::frame_buffer Class Reference

in-memory frame buffer that can be written in one go More...

#include <graphics.h>

Inheritance diagram for bmptk::graphics::frame_buffer:
bmptk::graphics::frame

Public Member Functions

 frame_buffer (frame &fr)
 construct a frame_buffer from an underlying frame
 
virtual ~frame_buffer ()
 destruct a frame_buffer, freeing the allocated pixel buffer
 
void checked_write (const vector p, const color c)
 write to the pixel buffer
 
void flush ()
 write the pixel buffer to the underlying frame
 
void clear (const color c=color::white())
 clear the buffer, and rember the color used
 
- Public Member Functions inherited from bmptk::graphics::frame
 frame (const vector size)
 create a frame of specified size
 
vector size_get () const
 get the size of the frame
 
virtual vector translate_outfrom (const vector p) const
 translate a subframe coordinate to a master frame coordinate
 
virtual vector translate_into (const vector p) const
 translate a master frame coordinate to a subframe coordinate
 
bool is_valid (vector p)
 whether p is within the frame
 
color bg_get ()
 get the backround color
 
void write (const vector p, const color c)
 write one pixel, address specified by vector
 

Additional Inherited Members

- Protected Attributes inherited from bmptk::graphics::frame
const vector size
 frame size
 
color bg
 most recently applied background color (as used in clear())
 

Detailed Description

in-memory frame buffer that can be written in one go

A frame_buffer catches and buffers the writes to the underlying frame in an in-memmory buffer. The flush() call writes the buffer to the underlying frame.

A frame_buffer can be used to prevent flickering while a frame is updated. The downside is the memory use and the extra CPU time for writing the changed pixels to the underlying frame. To do this all buffered pixels must be checked.

Note that buffering the writing to a screen that itself does fancy things (for instance shadowing) can change what appears on a screen because the order in which pixels are written is changed. The safest is to buffer directly above the target screen.

The buffer is allocated on the heap.

Definition at line 827 of file graphics.h.

Constructor & Destructor Documentation

bmptk::graphics::frame_buffer::frame_buffer ( frame fr)
inline

construct a frame_buffer from an underlying frame

This constructor allocates the pixel buffer on the heap. The size is the number of pixels in the underlying frame * 4 bytes for each pixel.

Definition at line 860 of file graphics.h.

Member Function Documentation

void bmptk::graphics::frame_buffer::flush ( )
inlinevirtual

write the pixel buffer to the underlying frame

This method writes all changed pixels in the buffer to the underlying frame, and flushes that frame.

Reimplemented from bmptk::graphics::frame.

Definition at line 886 of file graphics.h.


The documentation for this class was generated from the following file: