Drawbuffers is an advanced and powerful capability of OSLib images, it allows you to draw directly on an image exactly as if you were drawing on the screen! See oslSetDrawBuffer for basic a code sample.
#define oslGetDrawBuffer |
( |
| ) |
osl_curBuf |
Returns the current drawbuffer as an OSL_IMAGE. You can save it to restore it later.
#define OSL_DEFAULT_BUFFER (&osl_defaultBufferImage) |
An image representing the primary buffer image, which is the buffer to which you are currently writing (see oslSwapBuffers for more information).
#define OSL_SECONDARY_BUFFER (&osl_secondaryBufferImage) |
An image representing the secondary buffer image, which is the buffer currently displayed to the user (see oslSwapBuffers for more information). In single buffering mode, OSL_DEFAULT_BUFFER is identical to OSL_SECONDARY_BUFFER.
#define OSL_SCREEN_WIDTH (osl_curBuf->sizeX) |
Returns the width of the current drawbuffer. On the default drawbuffer (i.e. the screen) it will be the resolution of the PSP LCD, that is 480 pixels. By taking these values in account you can make game that automatically adapt to another resolution.
#define OSL_SCREEN_HEIGHT (osl_curBuf->sizeY) |
Returns the height of the current drawbuffer. On the default drawbuffer (i.e. the screen) it will be the resolution of the PSP LCD, that is 272 pixels.
Available effects for oslSetAlphaWrite.
Enumerator |
---|
OSL_FXAW_NONE |
Does not write alpha.
|
OSL_FXAW_SET |
Sets alpha to value1 if the alpha channel of the pixel is not equal to value2.
|
Define an image as the current drawbuffer. Don't forget to restore the original drawbuffer once you've finished drawing to the image. Here is an example that draws something on an image, and then draws that image on the real screen.
Important: The image pixel format must be non-paletted! (supported formats are 4444, 5551, 5650 and 8888). 8888 mode (32-bit) is slower than others and the image is bigger. Also, the image MUST be in video memory (OSL_IN_VRAM). The GPU can't write to regular RAM (it can only read from it).
A common problem is the image not being displayed because its alpha is null. You can temporarily disable alpha blending by calling oslSetAlpha(OSL_FX_NONE, 0) to prevent this problem, but the best solution is to not forget to always clear the image after you've created it!
void oslSetAlphaWrite |
( |
int |
action, |
|
|
int |
value1, |
|
|
int |
value2 |
|
) |
| |
Enables writing to the alpha channel of the drawbuffer. You won't care about it when using the standard drawbuffer, but when it comes to draw on an image, it may become important. By default, alpha values are never set on the drawbuffer (let as they are).
- Parameters
-
action |
- OSL_FXAW_SET: Set the alpha to value1. Every pixel written to the drawbuffer will set the alpha value to value1. All pixels (for example from a square or rectangle image) will set the alpha value, even if they are transparent. In order to avoid this, you can set-up an alpha test which masks out transparents pixels. They will not be drawn and the alpha value will not be written in the drawbuffer.
|
value1 | If action is OSL_FXAW_SET, this parameter holds the alpha opacity to be written, from 0 to 255 (0 = transparent, 255 = opaque). |
value2 | Not used, let it 0. |
I've not got pure copy of the alpha values to work. If someone has already used it and wants to share his experience, it would be very nice.
void oslSetAlphaTest |
( |
int |
condition, |
|
|
int |
value |
|
) |
| |
Set alpha testing parameters. The test will be made against the alpha value of the pixel to be drawn. If the test passes, the pixel is written to the screen, else it is ignored. Note that pixels from a OSL_PF_5650 image do not initially contain alpha, but obviously it is automatically set to opaque (alpha = 255).
- Parameters
-
condition | Condition for the test to pass. Can be one of the following:
- OSL_FXAT_NEVER: Never passes.
- OSL_FXAT_ALWAYS: Always passes.
- OSL_FXAT_EQUAL: Alpha is equal to value.
- OSL_FXAT_NOTEQUAL: Alpha is not equal to value.
- OSL_FXAT_LESS: Alpha is less than value.
- OSL_FXAT_LEQUAL: Alpha is less or equal to value.
- OSL_FXAT_GREATER: Alpha is greater than value.
- OSL_FXAT_GEQUAL: Alpha is greater or equal to value.
|
value | Reference value for comparision. |
void oslDisableAlphaTest |
( |
| ) |
|
Holds whether alpha testing is currently enabled.