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 a basic code sample.
◆ oslGetDrawBuffer
| #define oslGetDrawBuffer |
( |
| ) |
osl_curBuf |
Returns the current drawbuffer as an OSL_IMAGE. You can save it to restore it later.
- Returns
- A pointer to the current drawbuffer image.
◆ OSL_DEFAULT_BUFFER
An image representing the primary buffer image, which is the buffer to which you are currently writing.
- Note
- This buffer is managed by
oslSwapBuffers. In single buffering mode, OSL_DEFAULT_BUFFER is identical to OSL_SECONDARY_BUFFER.
◆ OSL_SECONDARY_BUFFER
| #define OSL_SECONDARY_BUFFER (&osl_secondaryBufferImage) |
An image representing the secondary buffer image, which is the buffer currently displayed to the user.
- Note
- In single buffering mode,
OSL_DEFAULT_BUFFER is identical to OSL_SECONDARY_BUFFER. This buffer is updated and managed by oslSwapBuffers.
◆ OSL_SCREEN_WIDTH
| #define OSL_SCREEN_WIDTH (osl_curBuf->sizeX) |
Returns the width of the current drawbuffer.
- Returns
- The width of the current drawbuffer in pixels. For the default drawbuffer (i.e., the screen), it will be 480 pixels, which is the resolution of the PSP LCD.
◆ OSL_SCREEN_HEIGHT
| #define OSL_SCREEN_HEIGHT (osl_curBuf->sizeY) |
Returns the height of the current drawbuffer.
- Returns
- The height of the current drawbuffer in pixels. For the default drawbuffer (i.e., the screen), it will be 272 pixels, which is the resolution of the PSP LCD.
◆ OSL_FX_ALPHAWRITE
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.
|
◆ OSL_FX_ALPHATEST
Alpha test comparison operators. Used with oslSetAlphaTest to define the conditions for alpha testing.
| Enumerator |
|---|
| OSL_FXAT_NEVER | Never passes the alpha test.
|
| OSL_FXAT_ALWAYS | Always passes the alpha test.
|
| OSL_FXAT_EQUAL | Passes the alpha test if the alpha value is equal to the reference value.
|
| OSL_FXAT_NOTEQUAL | Passes the alpha test if the alpha value is not equal to the reference value.
|
| OSL_FXAT_LESS | Passes the alpha test if the alpha value is less than the reference value.
|
| OSL_FXAT_LEQUAL | Passes the alpha test if the alpha value is less than or equal to the reference value.
|
| OSL_FXAT_GREATER | Passes the alpha test if the alpha value is greater than the reference value.
|
| OSL_FXAT_GEQUAL | Passes the alpha test if the alpha value is greater than or equal to the reference value.
|
◆ oslSetDrawBuffer()
Define an image as the current drawbuffer. Use this function to specify the image to which drawing operations will be directed. Remember to restore the original drawbuffer after you have finished drawing.
#define RGB16(r, v, b)
Creates a 16-bit color.
Definition drawing.h:521
#define RGB(r, v, b)
Creates a 32-bit opaque color.
Definition drawing.h:443
void oslDrawFillRect(int x0, int y0, int x1, int y1, OSL_COLOR color)
Draws a filled rectangle from (x0, y0) to (x1, y1).
#define OSL_DEFAULT_BUFFER
Definition drawing.h:2957
void oslSetDrawBuffer(OSL_IMAGE *img)
#define oslDrawImageXY(img, px, py)
Draws an image at the specified position.
Definition drawing.h:1334
void oslClearImage(OSL_IMAGE *img, int color)
OSL_IMAGE * oslCreateImage(int larg, int haut, short location, short pixelFormat)
Creates an empty image in OSLib.
@ OSL_IN_VRAM
In VRAM.
Definition drawing.h:975
@ OSL_PF_5650
16 bits, 5 bits per component, except green which has 6, no alpha
Definition drawing.h:1008
Structure representing an image loaded in memory.
Definition drawing.h:929
Important:
- The image pixel format must be non-paletted. Supported formats are 4444, 5551, 5650, and 8888. Note that 8888 mode (32-bit) is slower and results in a larger image size.
- The image must be in video memory (OSL_IN_VRAM). The GPU can only render into video memory (it reads textures from both RAM and VRAM).
- A common issue is that the image may not be displayed if its alpha is null. To avoid this, either clear the image after creation or temporarily disable alpha blending by calling
oslSetAlpha(OSL_FX_NONE, 0).
- Parameters
-
| img | The image to set as the current drawbuffer. |
◆ oslSetAlphaWrite()
| void oslSetAlphaWrite |
( |
int |
action, |
|
|
int |
value1, |
|
|
int |
value2 |
|
) |
| |
|
extern |
Controls writing to the alpha channel of the draw buffer.
This function is useful when rendering to an image rather than the standard draw buffer. By default, alpha values are not modified in the draw buffer. This function allows you to specify how alpha values should be written based on the given action. It also provides the ability to enable or disable stencil testing, which can control the regions of the buffer where alpha values are written.
- Parameters
-
| action | Specifies the action to take:
OSL_FXAW_SET: Sets the alpha channel to value1. Every pixel written to the draw buffer will set its alpha value to value1. Even fully transparent pixels will have their alpha values set unless additional alpha testing is enabled.
OSL_FXAW_NONE: Disables stencil testing, leaving the alpha channel unchanged.
|
| value1 | If action is OSL_FXAW_SET, this specifies the alpha value to be written, ranging from 0 (transparent) to 255 (opaque). |
| value2 | Currently not used; should be set to 0. |
Example:
#define RGBA(r, v, b, a)
Creates a 32-bit color with alpha (transparency).
Definition drawing.h:456
void oslSetAlphaWrite(int action, int value1, int value2)
Controls writing to the alpha channel of the draw buffer.
void oslSetAlphaTest(int condition, int value)
@ OSL_FXAW_SET
Definition drawing.h:3075
@ OSL_FXAT_GREATER
Definition drawing.h:3099
◆ oslSetAlphaTest()
| void oslSetAlphaTest |
( |
int |
condition, |
|
|
int |
value |
|
) |
| |
|
extern |
Sets alpha testing parameters.
Configures the alpha test, which determines whether a pixel should be drawn based on its alpha value. If the test passes, the pixel is written to the screen; otherwise, it is ignored.
- Parameters
-
| condition | The 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 the value.
- OSL_FXAT_NOTEQUAL: Alpha is not equal to the value.
- OSL_FXAT_LESS: Alpha is less than the value.
- OSL_FXAT_LEQUAL: Alpha is less than or equal to the value.
- OSL_FXAT_GREATER: Alpha is greater than the value.
- OSL_FXAT_GEQUAL: Alpha is greater than or equal to the value.
|
| value | The reference value for comparison. |
- Note
- Pixels from an OSL_PF_5650 image do not initially contain alpha. The alpha value is automatically set to opaque (alpha = 255).
◆ oslDisableAlphaTest()
| void oslDisableAlphaTest |
( |
| ) |
|
|
extern |
Disables alpha testing.
Alpha testing is a method of controlling the visibility of pixels based on their alpha values.
◆ osl_alphaTestEnabled
Holds whether alpha testing is currently enabled.