TrustedUser
2,147
edits
m (→Example) |
m (Text replacement - "</source>" to "</syntaxhighlight>") |
||
(5 intermediate revisions by 3 users not shown) | |||
Line 20: | Line 20: | ||
*Backends '''''must''''' place the highest color mode that is supported by the backend and the hardware at the beginning of the list returned by getSupportedFormats. | *Backends '''''must''''' place the highest color mode that is supported by the backend and the hardware at the beginning of the list returned by getSupportedFormats. | ||
*Backends ''should'' support graphics in RGB(A) color order, even if their hardware uses a different color order, but are not required to. | *Backends ''should'' support graphics in RGB(A) color order, even if their hardware uses a different color order, but are not required to. | ||
*Backends supporting color order conversion | *Backends supporting color order conversion with limited hardware may use Graphics::crossBlit, but are '''strongly recommended''' to use platform-optimized code. | ||
== Truecolor API initialization protocol == | == Truecolor API initialization protocol == | ||
Line 40: | Line 39: | ||
==== Example ==== | ==== Example ==== | ||
Here is an example of a simple engine that uses the best color depth available to display and color-cycle this gradient: [[Image:QuuxGradientRGB565.png]] | Here is an example of a simple engine that uses the best color depth available to display and color-cycle this gradient: [[Image:QuuxGradientRGB565.png]] | ||
< | <syntaxhighlight lang="cpp"> | ||
Common::Error QuuxEngine::run() { | Common::Error QuuxEngine::run() { | ||
Graphics::PixelFormat ourFormat; | Graphics::PixelFormat ourFormat; | ||
Line 157: | Line 156: | ||
return Common::kNoError; | return Common::kNoError; | ||
} | } | ||
</ | </syntaxhighlight> | ||
=== Backend initialization protocol === | === Backend initialization protocol === | ||
Line 181: | Line 180: | ||
**Backends which do not support fast conversion '''''must''''' put all modes directly supported in hardware, (and CLUT8), before modes that will require conversion during copyRectToScreen. | **Backends which do not support fast conversion '''''must''''' put all modes directly supported in hardware, (and CLUT8), before modes that will require conversion during copyRectToScreen. | ||
**Backends which support fast conversion ''should'' put larger colorspaces before smaller color spaces, but are not required to. | **Backends which support fast conversion ''should'' put larger colorspaces before smaller color spaces, but are not required to. | ||
==== Graphics::PixelFormat ==== | ==== Graphics::PixelFormat ==== | ||
*inline Graphics::PixelFormat Graphics::findCompatibleFormat(Common::List<Graphics::PixelFormat> backend, Common::List<Graphics::PixelFormat> frontend) | *inline Graphics::PixelFormat Graphics::findCompatibleFormat(Common::List<Graphics::PixelFormat> backend, Common::List<Graphics::PixelFormat> frontend) | ||
**Returns the first entry on the backend list that also occurs in the frontend list, or CLUT8 if there is no matching format. | **Returns the first entry on the backend list that also occurs in the frontend list, or CLUT8 if there is no matching format. | ||
*inline Graphics::PixelFormat (void) | |||
**creates an uninitialized PixelFormat. | |||
*inline Graphics::PixelFormat(byte BytesPerPixel, byte RBits, byte GBits, byte BBits, byte ABits, byte RShift, byte GShift, byte BShift, byte AShift) | |||
**creates an initialized PixelFormat. | |||
**[_]Bits is the width in bits of the relevant channel | |||
***RBits = red bits, GBits = green bits, BBits = blue bits, ABits = alpha bits. | |||
**[_]Shift is the number (starting from 0) of the least significant bit in the relevant channel, which is equal to the bitshift required to make a channel. | |||
***In RGB565, RShift is 11, GShift is 5, and BShift is 0. | |||
***In RGBA4444, RShift is 12, GShift is 8, BShift is 4, and AShift is 0. | |||
*static inline Graphics::PixelFormat Graphics::PixelFormat::createFormatCLUT8(void) | *static inline Graphics::PixelFormat Graphics::PixelFormat::createFormatCLUT8(void) | ||
**creates a PixelFormat set to indicate 256 color paletted mode | **creates a PixelFormat set to indicate 256 color paletted mode | ||
Line 198: | Line 201: | ||
==== Miscellaneous ==== | ==== Miscellaneous ==== | ||
*bool crossBlit(byte *dst, const byte *src, int dstpitch, int srcpitch, int w, int h, Graphics::PixelFormat dstFmt, Graphics::PixelFormat srcFmt) | *bool Graphics::crossBlit(byte *dst, const byte *src, int dstpitch, int srcpitch, int w, int h, Graphics::PixelFormat dstFmt, Graphics::PixelFormat srcFmt) | ||
**blits a rectangle from a "surface" in srcFmt to a "surface" in dstFmt | **blits a rectangle from a "surface" in srcFmt to a "surface" in dstFmt | ||
**returns false if the blit fails (due to unsupported format conversion) | **returns false if the blit fails (due to unsupported format conversion) |