|
GraphicsColorsALLEGRO_COLOR
An ALLEGRO_COLOR structure describes a color in a device independant way. Use al_map_rgb et al. and al_unmap_rgb et al. to translate from and to various color representations. al_map_rgb
Convert r, g, b (ranging from 0-255) into an ALLEGRO_COLOR, using 255 for alpha. See also: al_map_rgba, al_map_rgba_f, al_map_rgb_f al_map_rgb_f
Convert r, g, b, (ranging from 0.0f-1.0f) into an ALLEGRO_COLOR, using 1.0f for alpha. See also: al_map_rgba, al_map_rgb, al_map_rgba_f al_map_rgba
Convert r, g, b, a (ranging from 0-255) into an ALLEGRO_COLOR. See also: al_map_rgb, al_map_rgba_f, al_map_rgb_f al_map_rgba_f
Convert r, g, b, a (ranging from 0.0f-1.0f) into an ALLEGRO_COLOR. See also: al_map_rgba, al_map_rgb, al_map_rgb_f al_unmap_rgb
Retrieves components of an ALLEGRO_COLOR, ignoring alpha Components will range from 0-255. See also: al_unmap_rgba, al_unmap_rgba_f, al_unmap_rgb_f al_unmap_rgb_f
Retrieves components of an ALLEGRO_COLOR, ignoring alpha. Components will range from 0.0f-1.0f. See also: al_unmap_rgba, al_unmap_rgb, al_unmap_rgba_f al_unmap_rgba
Retrieves components of an ALLEGRO_COLOR. Components will range from 0-255. See also: al_unmap_rgb, al_unmap_rgba_f, al_unmap_rgb_f al_unmap_rgba_f
Retrieves components of an ALLEGRO_COLOR. Components will range from 0.0f-1.0f. See also: al_unmap_rgba, al_unmap_rgb, al_unmap_rgb_f Locking and pixel formatsALLEGRO_LOCKED_REGION
Users who wish to manually edit or read from a bitmap are required to lock it first. The ALLEGRO_LOCKED_REGION structure represents the locked region of the bitmap. This call will work with any bitmap, including memory bitmaps.
ALLEGRO_PIXEL_FORMAT
Pixel formats. Each pixel format specifies the exact size and bit layout of a pixel in memory. Components are specified from high bits to low bits, so for example a fully opaque red pixel in ARGB_8888 format is 0xFFFF0000. Note: The pixel format is independent of endianness. That is, in the above example you can always get the red component with (pixel & 0x00ff0000) >> 16 But you can not rely on this code: *(pixel + 2) It will return the red component on little endian systems, but the green component on big endian systems. Also note that Allegro's naming is different from OpenGL naming here, where a format of GL_RGBA8 merely defines the component order and the exact layout including endianness treatment is specified separately. Usually GL_RGBA8 will correspond to ALLEGRO_PIXEL_ABGR_8888 though on little endian systems, so care must be taken (note the reversal of RGBA <-> ABGR). The only exception to this ALLEGRO_PIXEL_FORMAT_ABGR_8888_LE which will always have the components as 4 bytes corresponding to red, green, blue and alpha, in this order, independent of the endianness.
al_get_pixel_size
al_get_pixel_format_bits
al_lock_bitmap
Lock an entire bitmap for reading or writing. If the bitmap is a display bitmap it will be updated from system memory after the bitmap is unlocked (unless locked read only). Returns NULL if the bitmap cannot be locked, e.g. the bitmap was locked previously and not unlocked. Flags are:
'format' indicates the pixel format that the returned buffer will be in. To lock in the same format as the bitmap stores it's data internally, call with Note: While a bitmap is locked, you can not use any drawing operations on it (with the sole exception of al_put_pixel and al_draw_pixel). al_lock_bitmap_region
Like al_lock_bitmap, but only locks a specific area of the bitmap. If the bitmap is a display bitmap, only that area of the texture will be updated when it is unlocked. Locking only the region you indend to modify will be faster than locking the whole bitmap. See Also: al_lock_bitmap al_unlock_bitmap
Unlock a previously locked bitmap or bitmap region. If the bitmap is a display bitmap, the texture will be updated to match the system memory copy (unless it was locked read only). Bitmap creationALLEGRO_BITMAP
Abstract type representing a bitmap (2D image). al_clone_bitmap
Clone a bitmap "exactly", formats can be different. al_create_bitmap
Creates a new bitmap using the bitmap format and flags for the current thread. Blitting between bitmaps of differing formats, or blitting between memory bitmaps and display bitmaps may be slow. Unless you set the ALLEGRO_MEMORY_BITMAP flag, the bitmap is created for the current display. Blitting to another display may be slow. If a display bitmap is created, there may be limitations on the allowed dimensions. For example a DirectX or OpenGL backend usually has a maximum allowed texture size - so if bitmap creation fails for very large dimensions, you may want to re-try with a smaller bitmap. See Also: al_set_new_bitmap_format, al_set_new_bitmap_flags al_create_sub_bitmap
Creates a sub-bitmap of the parent, at the specified coordinates and of the specified size. A sub-bitmap is a bitmap that shares drawing memory with a pre-existing (parent) bitmap, but possibly with a different size and clipping settings. If the sub-bitmap does not lie completely inside the parent bitmap, then it is automatically clipped so that it does. The parent bitmap's clipping rectangles are ignored. If a sub-bitmap was not or cannot be created then NULL is returned. Note that destroying parents of sub-bitmaps will not destroy the sub-bitmaps; instead the sub-bitmaps become invalid and should no longer be used. al_destroy_bitmap
Destroys the given bitmap, freeing all resources used by it. Does nothing if given the null pointer. al_get_new_bitmap_flags
Returns the flags used for newly created bitmaps. al_get_new_bitmap_format
Returns the format used for newly created bitmaps. al_load_bitmap
Load a bitmap from a file using the bitmap format and flags of the current thread. See Also: al_set_new_bitmap_format, al_set_new_bitmap_flags al_set_new_bitmap_flags
Sets the flags to use for newly created bitmaps. Valid flags are:
XXX al_create_memory_bitmap doesn't exist any more
al_set_new_bitmap_format
Sets the pixel format for newly created bitmaps. The default format is 0 and means the display driver will choose the best format. Bitmap propertiesal_get_bitmap_flags
Return the flags user to create the bitmap. al_get_bitmap_format
Returns the pixel format of a bitmap. al_get_bitmap_height
Returns the height of a bitmap in pixels. al_get_bitmap_width
Returns the width of a bitmap in pixels. al_get_pixel
Get a pixel's color value from the specified bitmap. This operation is slow on non-memory bitmaps. Consider locking the bitmap if you are going to use this function multiple times on the same bitmap. al_is_bitmap_locked
Returns whether or not a bitmap is already locked. al_is_compatible_bitmap
D3D and OpenGL allow sharing a texture in a way so it can be used for multiple windows. Each ALLEGRO_BITMAP created with al_create_bitmap however is usually tied to a single ALLEGRO_DISPLAY. This function can be used to know if the bitmap is compatible with the current display, even if it is another display than the one it was created with. It returns true if the bitmap is compatible (things like a cached texture version can be used) and false otherwise (blitting in the current display will be slow). The only time this function is useful is if you are using multiple windows and need accelerated blitting of the same bitmaps to both. al_is_sub_bitmap
Returns true if the specified bitmap is a sub-bitmap, false otherwise. Drawing operationsAll drawing operations draw to the current "target bitmap" of the current thread. Initially, the target bitmap will be the backbuffer of the last display created in a thread. al_clear_to_color
Clear the complete target bitmap, but confined by the clipping rectangle. al_draw_bitmap
Draws an unscaled, unrotated bitmap at the given position to the current target bitmap (see al_set_target_bitmap). flags can be a combination of:
al_draw_bitmap_region
Draws a region of the given bitmap to the target bitmap.
al_draw_pixel
Draws a single pixel at x, y. This function, unlike al_put_pixel, does blending. This operation is slow on non-memory bitmaps. Consider locking the bitmap if you are going to use this function multiple times on the same bitmap.
al_draw_rotated_bitmap
Draws a rotated version of the given bitmap to the target bitmap. The bitmap is rotated by 'angle' radians counter clockwise. The point at cx/cy inside the bitmap will be drawn at dx/dy and the bitmap is rotated around this point.
al_draw_rotated_scaled_bitmap
Like al_draw_rotated_bitmap, but can also scale the bitmap. The point at cx/cy in the bitmap will be drawn at dx/dy and the bitmap is rotated and scaled around this point.
al_draw_scaled_bitmap
Draws a scaled version of the given bitmap to the target bitmap.
al_get_target_bitmap
Return the target bitmap of the current display. al_put_pixel
Draw a single pixel on the target bitmap. This operation is slow on non-memory bitmaps. Consider locking the bitmap if you are going to use this function multiple times on the same bitmap. al_set_target_bitmap
Select the bitmap to which all subsequent drawing operations in the calling thread will draw. Select the backbuffer (see al_get_backbuffer) to return to drawing to the screen normally. OpenGL note: Framebuffer objects (FBOs) allow OpenGL to directly draw to a bitmap, which is very fast. However, each created FBO needs additional resources, therefore an FBO is not automatically assigned to each non-memory bitmap when it is created (as is done with textures). When using an OpenGL display, only if all of the following conditions are met an FBO will be created for the bitmap:
Once created, the FBO is kept around until the bitmap is destroyed or you explicitely call al_remove_opengl_fbo on the bitmap. In the following example, no FBO will be created:
The above allows using al_put_pixel on a locked bitmap without creating an FBO. In this example an FBO is created however:
And an OpenGL command will be used to directly draw the line into the bitmap's associated texture. Blending modesal_get_blender
Returns the active blender for the current thread. You can pass NULL for values you are not interested in. al_get_separate_blender
Returns the active blender for the current thread. You can pass NULL for values you are not interested in. al_set_blender
Sets the function to use for blending for the current thread. Blending means, the source and destination colors are combined in drawing operations. Assume, the source color (e.g. color of a rectangle to draw, or pixel of a bitmap to draw), is given as its red/green/blue/alpha components (if the bitmap has no alpha, it always is assumed to be fully opaque, so 255 for 8-bit or 1.0 for floating point): sr, sg, sb, sa. And this color is drawn to a destination, which already has a color: dr, dg, db, da. Blending formula: The conceptional formula used by Allegro to draw any pixel then is
Blending functions: Valid values for
The color parameter specified the blend color, it is multipled with the source color before the above blending operation. Blending examples: So for example, to restore the default of using alpha blending, you would use (pseudo code)
If in addition you want to draw half transparently
Additive blending would be achieved with
Copying the source to the destination (including alpha) unmodified
al_set_separate_blender
Like al_set_blender, but allows specifying a separate blending operation for the alpha channel. Clippingal_get_clipping_rectangle
Gets the clipping rectangle of the target bitmap. al_set_clipping_rectangle
Set the region of the target bitmap or display that pixels get clipped to. The default is to clip pixels to the entire bitmap. Miscellaneousal_convert_mask_to_alpha
Convert the given mask color to an alpha channel in the bitmap. Can be used to convert older 4.2-style bitmaps with magic pink to alpha-ready bitmaps. |
Last updated: 2009-08-09 08:22:38 UTC