Data Structures | |
struct | OSL_ALPHA_PARAMS |
Macros | |
#define | oslResetScreenClipping() oslSetScreenClipping(0, 0, osl_curBuf->sizeX, osl_curBuf->sizeY); |
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) |
void | oslSetAlpha (u32 effect, u32 coeff1) |
void | oslGetAlphaEx (OSL_ALPHA_PARAMS *alpha) |
void | oslSetAlphaEx (OSL_ALPHA_PARAMS *alpha) |
void | oslSetBilinearFilter (int enabled) |
void | oslSetDithering (int enabled) |
void | oslSetTransparentColor (OSL_COLOR color) |
Variables | |
int | osl_bilinearFilterEnabled |
int | osl_ditheringEnabled |
int | osl_colorKeyEnabled |
General drawing tasks.
#define oslResetScreenClipping | ( | ) | oslSetScreenClipping(0, 0, osl_curBuf->sizeX, osl_curBuf->sizeY); |
Resets the screen clipping to the whole screen.
void oslClearScreen | ( | int | backColor | ) |
Clears the entire screen with the specified color.
backColor | Color to fill the screen with. |
void oslSetScreenClipping | ( | int | x0, |
int | y0, | ||
int | x1, | ||
int | y1 | ||
) |
Sets the clipping region. Anything outside of the clipping rectangle will not be drawn on the screen. Initially the clipping region is set to the entire screen.
Note: oslSetDrawBuffer automatically adjusts the clipping region to cover the full the drawbuffer image.
void oslSetDepthTest | ( | int | enabled | ) |
Sets the depth test.
void oslSetAlpha2 | ( | u32 | effect, |
u32 | coeff1, | ||
u32 | coeff2 | ||
) |
Sets current special alpha effect parameters. Images and shapes drawn next to this command will be using these parameters.
effect | Can be one of the following:
|
coeff1 | Coefficient used in the operations described above. Either alpha coefficient (0 to 255) or color (0 to 0xffffffff) |
coeff2 | Extended coefficient used in the operations described above. |
Here are some examples:
That's not all, a lot of nice effects can be produced with this function.
About multiplication, note that black won't be tinted as it's a multiplication, zero * something always gives zero. In fact, a multiplication always gives a darker color. Each separate color component is first divided by 255 and then multiplicated with the other one. For example, let's multiply gray RGB(128, 128, 128) by orange RGB(255, 128, 0):
By ranging them to 1.0, we get r1 =0.5, g1 = 0.5, b1 = 0.5, r2 = 1.0, g2 = 0.5, b2 = 0.0. We now multiply r1 by r2, g1 by g2 and b1 by b2. The final result is: RGB(0.5, 0.25, 0.0), which is, when converted again RGB(128, 64, 0), brown! In general, multiplicating by gray always darkens the color, multiplying by white does nothing, and multiplying by black gives black. You can get some nice effects once you've understood correctly what color operations do.
|
inline |
See oslSetAlpha2.
|
inline |
Stores the current alpha parameters to an OSL_ALPHA_PARAMS structure.
|
inline |
Sets the current alpha parameters using an OSL_ALPHA_PARAMS structure.
void oslSetBilinearFilter | ( | int | enabled | ) |
Enables (1) or disables (0) bilinear filtering.
Bilinear filtering "smoothes" images, reducing the edge aliasing when you stretch or rotate them. However for text and unstretched images, smoothing creates a blurry effect, so avoid enabling it permanently.
void oslSetDithering | ( | int | enabled | ) |
Enables (1) or disables (0) dithering. If you are using the 16-bit mode (as specified with oslInitGfx) or you are drawing to a 16-bit image, you can enable dithering. If a color can't be rendered exactly, it will use the nearest available colors and blend them together (with small dots) to give the illusion of an intermediate color. For example, dithering red and yellow gives the illusion of an orange surface.
void oslSetTransparentColor | ( | OSL_COLOR | color | ) |
Enables color keying. Any pixel of the specified color will not be drawn to the screen.
It has not much interest in itself, but the fact is that it takes effect as well when loading images. Any color equal to this one is set as transparent. As transparency is defined by the alpha channel, you can disable color keying then and the image will still contain transparency.
Example 1: loading an image with a color key. You can often see that the background of some sprite images are of a bright and unconventional color, like pink or bright red. This color is not used usually, but is only there to define the transparent parts of the image. Our example uses bright pink as a transparent color:
Example 2: Enable this when drawing (as said, it has nearly no interest in itself):
int osl_bilinearFilterEnabled |
Holds whether bilinear filetering is currently turned on.
int osl_ditheringEnabled |
Holds whether dithering is currently turned on.
int osl_colorKeyEnabled |
Holds whether color keying is enabled.