OldSchool Library
|
Data Structures | |
struct | OSL_ALPHA_PARAMS |
Structure containing data for a special alpha effect. More... | |
Macros | |
#define | oslResetScreenClipping() |
Resets the screen clipping region to the entire screen. | |
#define | OSL_FX_DEFAULT OSL_FX_RGBA |
Default effect that combines RGBA channels. | |
#define | OSL_FX_OPAQUE OSL_FX_NONE |
Opaque effect with no special processing. | |
#define | OSL_FX_TINT (OSL_FX_ALPHA | OSL_FX_COLOR) |
Tint effect that combines alpha blending and color. | |
Enumerations | |
enum | { OSL_FX_NONE = 0 , OSL_FX_FLAT , OSL_FX_ALPHA , OSL_FX_ADD , OSL_FX_SUB } |
Functions | |
void | oslClearScreen (int backColor) |
void | oslSetScreenClipping (int x0, int y0, int x1, int y1) |
void | oslSetDepthTest (int enabled) |
void | oslSetAlpha2 (u32 effect, u32 coeff1, u32 coeff2) |
Configures the current alpha effect parameters for subsequent drawing operations. | |
void | oslSetBilinearFilter (int enabled) |
void | oslSetDithering (int enabled) |
void | oslSetTransparentColor (OSL_COLOR color) |
Enables color keying, making a specific color transparent. | |
void | oslDisableTransparentColor () |
Disables color keying, preventing any color-based transparency. | |
Variables | |
int | osl_currentAlphaEffect |
Current global alpha effect. | |
OSL_COLOR | osl_currentAlphaCoeff |
Current first coefficient for the global alpha effect. | |
OSL_COLOR | osl_currentAlphaCoeff2 |
Current second coefficient for the global alpha effect. | |
int | osl_bilinearFilterEnabled |
Indicates whether bilinear filtering is currently enabled. | |
int | osl_ditheringEnabled |
Indicates whether dithering is currently enabled. | |
int | osl_colorKeyEnabled |
Indicates whether color keying is currently enabled. | |
General drawing tasks in OSLib.
#define oslResetScreenClipping | ( | ) |
Resets the screen clipping region to the entire screen.
This macro resets the clipping region, ensuring that drawing operations affect the whole screen.
#define OSL_FX_DEFAULT OSL_FX_RGBA |
Default effect that combines RGBA channels.
This macro is used as the default alpha effect, combining red, green, blue, and alpha channels.
#define OSL_FX_OPAQUE OSL_FX_NONE |
Opaque effect with no special processing.
This macro sets the alpha effect to none, resulting in full opacity with no special processing.
#define OSL_FX_TINT (OSL_FX_ALPHA | OSL_FX_COLOR) |
Tint effect that combines alpha blending and color.
This macro applies an alpha blending effect combined with a color effect, useful for tinting.
anonymous enum |
|
extern |
Clears the entire screen with the specified color.
This function fills the screen with the given color.
backColor | The color to fill the screen with. |
|
extern |
Sets the clipping region.
Defines a rectangular area on the screen within which rendering is allowed. Any drawing outside this rectangle will not appear on the screen. Initially, the clipping region is set to cover the entire screen.
x0 | The x-coordinate of the top-left corner of the clipping region. |
y0 | The y-coordinate of the top-left corner of the clipping region. |
x1 | The x-coordinate of the bottom-right corner of the clipping region. |
y1 | The y-coordinate of the bottom-right corner of the clipping region. |
|
extern |
Sets the depth test.
Enables or disables depth testing, which determines whether a pixel should be drawn based on its depth value compared to what is currently in the depth buffer.
enabled | Set to 1 to enable depth testing, or 0 to disable it. |
|
extern |
Configures the current alpha effect parameters for subsequent drawing operations.
This function sets the blending mode and other related parameters that affect how images and shapes are rendered with alpha blending. The effect of this function persists for all subsequent draw calls until it is changed again.
effect | Specifies the blending mode to use:
|
coeff1 | A coefficient used in the blending operation, either as an alpha value (0 to 255) or a 32-bit color (0x00000000 to 0xFFFFFFFF). |
coeff2 | An extended coefficient used in the additive or subtractive blending modes, either as an alpha value or a 32-bit color. |
Examples:
Understanding how color multiplication works can help you achieve various effects. For example, multiplying colors generally darkens them, with black always resulting in black, while multiplying by white leaves the color unchanged.
|
extern |
Enables or disables bilinear filtering.
Bilinear filtering smoothes images, reducing edge aliasing when they are stretched or rotated. However, this can cause blurring in text or images that are not stretched, so it is generally not recommended to enable bilinear filtering permanently.
enabled | Set to 1 to enable bilinear filtering, or 0 to disable it. |
|
extern |
Enables or disables dithering.
Dithering is useful in 16-bit color modes or when drawing to a 16-bit image. If enabled, it blends colors that cannot be rendered exactly by using the nearest available colors and applying a pattern of small dots. This gives the illusion of intermediate colors, such as creating the appearance of orange by dithering red and yellow.
enabled | Set to 1 to enable dithering, or 0 to disable it. |
|
extern |
Enables color keying, making a specific color transparent.
This function enables color keying, which makes any pixel matching the specified color (color
) fully transparent. This is particularly useful when loading images with a specific background color that should be treated as transparent, such as bright pink backgrounds in sprite sheets.
The transparency effect persists even after disabling color keying, as it modifies the alpha channel of the image.
Example 1: Loading an image with a color key
Example 2: Drawing with color keying enabled
color | The color to be treated as transparent. |
|
extern |
Disables color keying, preventing any color-based transparency.
When color keying is disabled, all pixels will be drawn to the screen, including those that match the previously set transparent color. This function should be called after loading images with transparency or after drawing operations where color keying was used.
|
extern |
Current global alpha effect.
This variable holds the identifier of the alpha effect currently in use.
|
extern |
Current first coefficient for the global alpha effect.
This variable holds the first coefficient used by the current global alpha effect.
|
extern |
Current second coefficient for the global alpha effect.
This variable holds the second coefficient used by the current global alpha effect.
|
extern |
Indicates whether bilinear filtering is currently enabled.
This variable holds the state of bilinear filtering, which affects the smoothing of textures when they are scaled or rotated. A non-zero value means bilinear filtering is enabled, while a value of zero means it is disabled.
|
extern |
Indicates whether dithering is currently enabled.
This variable holds the state of dithering, which can be used to reduce the appearance of color banding by blending colors. A non-zero value means dithering is enabled, while a value of zero means it is disabled.
|
extern |
Indicates whether color keying is currently enabled.
This variable holds the state of color keying, a technique used to make certain colors transparent. A non-zero value means color keying is enabled, while a value of zero means it is disabled.