OldSchool Library
|
Macros | |
#define | oslGetDrawBuffer() |
#define | OSL_DEFAULT_BUFFER (&osl_defaultBufferImage) |
#define | OSL_SECONDARY_BUFFER (&osl_secondaryBufferImage) |
#define | OSL_SCREEN_WIDTH (osl_curBuf->sizeX) |
#define | OSL_SCREEN_HEIGHT (osl_curBuf->sizeY) |
Enumerations | |
enum | OSL_FX_ALPHAWRITE { OSL_FXAW_NONE , OSL_FXAW_SET } |
enum | OSL_FX_ALPHATEST { OSL_FXAT_NEVER = GU_NEVER , OSL_FXAT_ALWAYS = GU_ALWAYS , OSL_FXAT_EQUAL = GU_EQUAL , OSL_FXAT_NOTEQUAL = GU_NOTEQUAL , OSL_FXAT_LESS = GU_LESS , OSL_FXAT_LEQUAL = GU_LEQUAL , OSL_FXAT_GREATER = GU_GREATER , OSL_FXAT_GEQUAL = GU_GEQUAL } |
Functions | |
void | oslSetDrawBuffer (OSL_IMAGE *img) |
void | oslSetAlphaWrite (int action, int value1, int value2) |
Controls writing to the alpha channel of the draw buffer. | |
void | oslSetAlphaTest (int condition, int value) |
void | oslDisableAlphaTest () |
Variables | |
int | osl_alphaTestEnabled |
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.
#define oslGetDrawBuffer | ( | ) |
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.
oslSwapBuffers
. In single buffering mode, OSL_DEFAULT_BUFFER
is identical to 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.
OSL_DEFAULT_BUFFER
is identical to OSL_SECONDARY_BUFFER
. This buffer is updated and managed by oslSwapBuffers
. #define OSL_SCREEN_WIDTH (osl_curBuf->sizeX) |
Returns the width of the current drawbuffer.
#define OSL_SCREEN_HEIGHT (osl_curBuf->sizeY) |
Returns the height of the current drawbuffer.
enum 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. |
enum OSL_FX_ALPHATEST |
Alpha test comparison operators. Used with oslSetAlphaTest to define the conditions for alpha testing.
|
extern |
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.
\code OSL_IMAGE *drawBuf = oslCreateImage(320, 182, OSL_IN_VRAM, OSL_PF_5650); // Clear the image to black oslClearImage(drawBuf, RGB16(0, 0, 0)); // Set that image as the drawbuffer oslSetDrawBuffer(drawBuf); // Draw a red filled rectangle on the image oslDrawFillRect(0, 0, 100, 100, RGB(255, 0, 0)); // Restore the default drawbuffer oslSetDrawBuffer(OSL_DEFAULT_BUFFER); // Draw that image somewhere on the screen oslDrawImageXY(drawBuf, 80, 45); \endcode \b 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 write to video memory and can only read from regular RAM. - 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)`. @param img The image to set as the current drawbuffer. @return None.
|
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.
action | Specifies the action to take:
|
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:
|
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.
condition | The condition for the test to pass. Can be one of the following:
|
value | The reference value for comparison. |
|
extern |
Disables alpha testing.
Alpha testing is a method of controlling the visibility of pixels based on their alpha values.
|
extern |
Holds whether alpha testing is currently enabled.