Base graphics renderer class. More...
Public Member Functions | |
Renderer (void) | |
Default constructor. | |
virtual | ~Renderer () |
Default destructor. | |
virtual uint_t | Init (uint_t uWidth, uint_t uHeight, uint_t uDepth, uint_t uFlags) |
Initialize a renderer. | |
virtual void | Shutdown (void) |
Shut down a renderer. | |
virtual void | BeginScene (void) |
Start up a renderer for a frame. | |
virtual void | EndScene (void) |
Wrap up frame rendering. | |
virtual void | Draw8BitPixels (int iX, int iY, uint_t uWidth, uint_t uHeight, uintptr_t uStride, const uint8_t *pPixels) |
Draw 8 bit data onto the software buffer. | |
virtual void | Draw8BitPixelsMasked (int iX, int iY, uint_t uWidth, uint_t uHeight, uintptr_t uStride, const uint8_t *pPixels) |
Draw 8 bit data onto the software buffer. | |
virtual void | DrawPixel (int iX, int iY, uint_t uColorIndex) |
Draw an 8 bit pixel onto the software buffer. | |
virtual void | DrawRect (int iX, int iY, uint_t uWidth, uint_t uHeight, uint_t uColorIndex) |
Draw 8 bit color rectangle. | |
virtual void | Clear (uint_t uColorIndex) |
Clear the entire screen to a solid color. | |
Display * | GetDisplay (void) const noexcept |
Get the pointer to the attached video display. | |
void | SetDisplay (Display *pDisplay) noexcept |
Set the pointer to the attached display. | |
void * | GetFrameBuffer (void) const noexcept |
Get the base pointer to the frame buffer. | |
void | SetFrameBuffer (void *pFrameBuffer) noexcept |
Set the base pointer to the frame buffer. | |
uintptr_t | GetStride (void) const noexcept |
Get the width in bytes of the display buffer scan line. | |
void | SetStride (uintptr_t uStride) noexcept |
Set the width in bytes of the display buffer scan line. | |
uint_t | GetWidth (void) const noexcept |
Get the width in pixels for the rendering context. | |
uint_t | GetHeight (void) const noexcept |
Get the height in pixels for the rendering context. | |
uint_t | GetDepth (void) const noexcept |
Get the depth in bits for this renderer. | |
uint_t | GetFlags (void) const noexcept |
Get the state flags for the renderer. | |
const Rect_t * | GetClip (void) const noexcept |
Return the current clip rectangle. | |
void | GetClip (Rect_t *pOutput) const |
Return the current clip rectangle. | |
void | SetClip (const Rect_t *pInput) |
Set the current clip rectangle. | |
void | SetClip (int iLeft, int iTop, int iRight, int iBottom) |
Set the current clip rectangle. | |
void | DrawShape8Bit (int iX, int iY, RezFile *pRezFile, uint_t uRezNum) |
Draw a Shape8Bit_t image from a resource file. | |
void | DrawShape8BitCentered (RezFile *pRezFile, uint_t uRezNum) |
Draw a Shape8Bit_t image from a resource file centered on the screen. | |
void | DrawShape8BitMasked (int iX, int iY, RezFile *pRezFile, uint_t uRezNum) |
Draw a masked Shape8Bit_t image from a resource file. | |
void | DrawShape8BitMaskedCentered (RezFile *pRezFile, uint_t uRezNum) |
Draw a masked Shape8Bit_t image from a resource file centered on the screen. | |
Static Public Attributes | |
static const uint_t | ByteSquareTable [255+256] |
Table of squares from -255 to 255. | |
static const uint8_t | RGB2ToRGB3Table [4] = {0x00, 0x02, 0x05, 0x07} |
Table to convert 2 bit color to 3 bit color. | |
static const uint8_t | RGB2ToRGB4Table [4] = {0x00,0x05,0x0A,0x0F} |
Table to convert 2 bit color to 4 bit color. | |
static const uint8_t | RGB2ToRGB5Table [4] = {0x00,0x0A,0x15,0x1F} |
Table to convert 2 bit color to 5 bit color. | |
static const uint8_t | RGB2ToRGB6Table [4] = {0x00,0x15,0x2A,0x3F} |
Table to convert 2 bit color to 6 bit color. | |
static const uint8_t | RGB2ToRGB8Table [4] = {0x00,0x55,0xAA,0xFF} |
Table to convert 2 bit color to 8 bit color. | |
static const uint8_t | RGB3ToRGB4Table [8] = {0x00,0x02,0x04,0x06,0x09,0x0B,0x0D,0x0F} |
Table to convert 3 bit color to 4 bit color. | |
static const uint8_t | RGB3ToRGB5Table [8] = {0x00,0x04,0x09,0x0D,0x12,0x16,0x1B,0x1F} |
Table to convert 3 bit color to 5 bit color. | |
static const uint8_t | RGB3ToRGB6Table [8] = {0x00,0x09,0x12,0x1B,0x24,0x2D,0x36,0x3F} |
Table to convert 3 bit color to 6 bit color. | |
static const uint8_t | RGB3ToRGB8Table [8] = {0x00,0x24,0x49,0x6D,0x92,0xB6,0xDB,0xFF} |
Table to convert 3 bit color to 8 bit color. | |
static const uint8_t | RGB4ToRGB5Table [16] |
Table to convert 4 bit color to 5 bit color. | |
static const uint8_t | RGB4ToRGB6Table [16] |
Table to convert 4 bit color to 6 bit color. | |
static const uint8_t | RGB4ToRGB8Table [16] |
Table to convert 4 bit color to 8 bit color. | |
static const uint8_t | RGB5ToRGB6Table [32] |
Table to convert 5 bit color to 6 bit color. | |
static const uint8_t | RGB5ToRGB8Table [32] |
Table to convert 5 bit color to 8 bit color. | |
static const uint8_t | RGB6ToRGB8Table [64] |
Table to convert 6 bit color to 8 bit color. | |
Protected Member Functions | |
virtual void | UpdateClip (void) |
Update the clip rect to the operating system API. | |
Protected Attributes | |
Rect_t | m_Clip |
Bounds rectangle for clipping. | |
Display * | m_pDisplay |
Attached display. | |
void * | m_pFrameBuffer |
Pointer to the software frame buffer (If supported) | |
uintptr_t | m_uStride |
Width in BYTES of the display buffer (For software rendering) | |
uint_t | m_uWidth |
Width in pixels of the display buffer. | |
uint_t | m_uHeight |
Height in pixels of the display buffer. | |
uint_t | m_uDepth |
Depth in bits of the display buffer. | |
uint_t | m_uFlags |
Flags for describing available features. | |
Base graphics renderer class.
The Display class manages a video display, however, the actual method of rendering graphics is handled by the Renderer class. This disconnect was needed since Display classes are tied to the underlying API and software rendering is not.
Renderer classes are directly tied to the API they use to inform the operating system (if any) on how to draw the requested graphics. Some examples are DirectX 9, DirectX 10, OpenGL and software rendering. APIs can be chained where a software rendering context sits on top of an OpenGL context so the final result is drawn using OpenGL while the application renders exclusively in software.
Burger::Renderer::Renderer | ( | void | ) |
Default constructor.
Initializes all of the shared variables
|
virtual |
Default destructor.
Clears out the shared variables and calls the chained function Renderer::Shutdown() to release all resources.
|
virtual |
Start up a renderer for a frame.
Before a frame is started, the renderer may need to initialize internal states for the underlying API or hardware. This function will perform these actions
|
virtual |
Clear the entire screen to a solid color.
Using a color lookup index, get the color from the current palette and fill the screen with this color.
uColorIndex | Color to draw (Assumed to be an index to the active palette) |
|
virtual |
Draw 8 bit data onto the software buffer.
Draw an 8 bit per pixel image to the screen clipped to the current clip rect.
iX | X coordinate to draw the image |
iY | Y coordinate to draw the image |
uWidth | Width of the image in bytes |
uHeight | Height of the image in bytes |
uStride | Bytes per scan line of the image |
pPixels | Base pointer to the bit map to draw |
Reimplemented in Burger::RendererSoftware8.
|
virtual |
Draw 8 bit data onto the software buffer.
Draw an 8 bit per pixel image to the screen without drawing any pixels whose value are zero. The image is clipped to the current clip rect.
iX | X coordinate to draw the image |
iY | Y coordinate to draw the image |
uWidth | Width of the image in bytes |
uHeight | Height of the image in bytes |
uStride | Bytes per scan line of the image |
pPixels | Base pointer to the bit map to draw |
Reimplemented in Burger::RendererSoftware8.
|
virtual |
Draw an 8 bit pixel onto the software buffer.
Draw an 8 bit pixel to the screen by taking the 8 bit index and looking it up in the current palette.
The pixel is clipped to the current clip rect.
iX | X coordinate to draw the pixel |
iY | Y coordinate to draw the pixel |
uColorIndex | Color to draw (Assumed to be an index to the active palette) |
Reimplemented in Burger::RendererSoftware8.
|
virtual |
Draw 8 bit color rectangle.
Draw a solid 8 bit colored rectangle to the screen. The pixel is clipped to the current clip rect.
iX | X coordinate of the leftmost line |
iY | Y coordinate of the topmost line |
uWidth | Width of the rectangle in pixels |
uHeight | Height of the rectangle in pixels |
uColorIndex | Color to draw (Assumed to be an index to the active palette) |
Reimplemented in Burger::RendererSoftware8.
Draw a Shape8Bit_t image from a resource file.
Given a Shape8Bit_t data image stored in a resource file, draw it to the screen
iX | X coordinate of the leftmost line |
iY | Y coordinate of the topmost line |
pRezFile | Pointer to a valid rez file |
uRezNum | Resource number to the data chunk in the rez file |
Draw a Shape8Bit_t image from a resource file centered on the screen.
Given a Shape8Bit_t data image stored in a resource file, draw it to the center of the screen
pRezFile | Pointer to a valid rez file |
uRezNum | Resource number to the data chunk in the rez file |
Draw a masked Shape8Bit_t image from a resource file.
Given a masked Shape8Bit_t data image stored in a resource file, draw it to the screen
iX | X coordinate of the leftmost line |
iY | Y coordinate of the topmost line |
pRezFile | Pointer to a valid rez file |
uRezNum | Resource number to the data chunk in the rez file |
Draw a masked Shape8Bit_t image from a resource file centered on the screen.
Given a masked Shape8Bit_t data image stored in a resource file, draw it to the center of the screen
pRezFile | Pointer to a valid rez file |
uRezNum | Resource number to the data chunk in the rez file |
|
virtual |
Wrap up frame rendering.
After a frame is started, the renderer may need to wrap up some internal states and present cache or queued render events to the hardware. This function will perform these actions.
void Burger::Renderer::GetClip | ( | Rect_t * | pOutput | ) | const |
Return the current clip rectangle.
Drawing is clipped to this bounds rectangle. On screen initialization, it's set to the bounds of the entire screen. At runtime, the bounds rectangle can be changed to all draw functions that allow clipping will draw to whatever rectangle is used at the time.
Do not modify the rectangle directly. Call SetClip() so that internal variables can be updated if needed when changing the clip rectangle.
pOutput | Pointer to the Rect_t to store a copy of the current clip rectangle. |
|
inlinenoexcept |
Return the current clip rectangle.
Drawing is clipped to this bounds rectangle. On screen initialization, it's set to the bounds of the entire screen. At runtime, the bounds rectangle can be changed to all draw functions that allow clipping will draw to whatever rectangle is used at the time.
Do not modify the rectangle directly. Call SetClip() so that internal variables can be updated if needed when changing the clip rectangle.
|
inlinenoexcept |
Get the depth in bits for this renderer.
|
inlinenoexcept |
Get the pointer to the attached video display.
A renderer needs a connection to a video display to obtain context information of the display for some graphics APIs.
|
inlinenoexcept |
Get the state flags for the renderer.
|
inlinenoexcept |
Get the base pointer to the frame buffer.
When software rendering is requested, a frame buffer is allocated/created and a pointer and stride are created to allow software rendering functions to manipulate the buffer to update the game screen.
|
inlinenoexcept |
Get the height in pixels for the rendering context.
|
inlinenoexcept |
Get the width in bytes of the display buffer scan line.
|
inlinenoexcept |
Get the width in pixels for the rendering context.
|
virtual |
Initialize a renderer.
This is called when a Display is given a Renderer class to set up internal variables describing the parameters of the current display
uWidth | Width in pixels of the display to render to |
uHeight | Height in pixels of the display to render to |
uDepth | Depth in bits of the display to render to |
uFlags | Bit flags to describe specific display features |
void Burger::Renderer::SetClip | ( | const Rect_t * | pInput | ) |
Set the current clip rectangle.
Drawing is clipped to this bounds rectangle. On screen initialization, it's set to the bounds of the entire screen. At runtime, the bounds rectangle can be changed to all draw functions that allow clipping will draw to whatever rectangle is used at the time.
pInput | Pointer to the new clip rectangle |
void Burger::Renderer::SetClip | ( | int | iLeft, |
int | iTop, | ||
int | iRight, | ||
int | iBottom ) |
Set the current clip rectangle.
Drawing is clipped to this bounds rectangle. On screen initialization, it's set to the bounds of the entire screen. At runtime, the bounds rectangle can be changed to all draw functions that allow clipping will draw to whatever rectangle is used at the time.
iLeft | Left most point of the clip rectangle |
iTop | Top most point of the clip rectangle |
iRight | Right most point of the clip rectangle |
iBottom | Bottom most point of the clip rectangle |
|
inlinenoexcept |
Set the pointer to the attached display.
A renderer needs a connection to a video display to obtain context information of the display for some graphics APIs.
|
inlinenoexcept |
Set the base pointer to the frame buffer.
When software rendering is requested, a frame buffer is allocated/created and a pointer and stride are created to allow software rendering functions to manipulate the buffer to update the game screen.
pFrameBuffer | Base pointer to a buffer that is Renderer::m_uStride * Renderer::m_uHeight in bytes |
|
inlinenoexcept |
Set the width in bytes of the display buffer scan line.
uStride | Width in bytes of a single display buffer scan line |
|
virtual |
Shut down a renderer.
Release all resources allocated by the renderer
|
protectedvirtual |
Update the clip rect to the operating system API.
Some render targets need to have the local clip rect passed to the operating system API, this function will perform this update.
|
static |
Table of squares from -255 to 255.
Used for some routines to create a square to quickly generate a color match. Can be used by other routines for their own purposes. Only used for CPUs where integer multiplies are slow such as the PowerPC.
|
protected |
Bounds rectangle for clipping.
|
protected |
Attached display.
|
protected |
Pointer to the software frame buffer (If supported)
|
protected |
Depth in bits of the display buffer.
|
protected |
Flags for describing available features.
|
protected |
Height in pixels of the display buffer.
|
protected |
Width in BYTES of the display buffer (For software rendering)
|
protected |
Width in pixels of the display buffer.
|
static |
Table to convert 2 bit color to 3 bit color.
|
static |
Table to convert 2 bit color to 4 bit color.
|
static |
Table to convert 2 bit color to 5 bit color.
|
static |
Table to convert 2 bit color to 6 bit color.
|
static |
Table to convert 2 bit color to 8 bit color.
|
static |
Table to convert 3 bit color to 4 bit color.
|
static |
Table to convert 3 bit color to 5 bit color.
|
static |
Table to convert 3 bit color to 6 bit color.
|
static |
Table to convert 3 bit color to 8 bit color.
|
static |
Table to convert 4 bit color to 5 bit color.
|
static |
Table to convert 4 bit color to 6 bit color.
|
static |
Table to convert 4 bit color to 8 bit color.
|
static |
Table to convert 5 bit color to 6 bit color.
|
static |
Table to convert 5 bit color to 8 bit color.
Scale 0-31 into 0-255 in a linear fashion. The formula is Result = ((i*0xFFFF)/31)>>8
|
static |
Table to convert 6 bit color to 8 bit color.
Scale 0-63 into 0-255 in a linear fashion. The formula is Result = ((i*0xFFFF)/63)>>8