Entire Class Index | Main Class Index | Cross Index | Global Index

# Class CL_Target

Target class in ClanLib.
Contained in: global
Derived from: none
Derived by: CL_SurfaceProvider
Group: Display (Display 2D)

#include <ClanLib/display.h>

### public function member index:

### Construction:

`` | `CL_Target` | `()`;
``virtual`` | `~CL_Target` | `()`;

### Attributes:

``virtual` `bool`` | `is_video` | `() `const``;
``virtual` `void`` | `lock` | `()`;
``virtual` `void`` | `unlock` | `()`;
``virtual` `void`*` | `get_data` | `() `const``;
``virtual` `unsigned` `int`` | `get_num_frames` | `() `const``;
``virtual` `unsigned` `int`` | `get_width` | `() `const``;
``virtual` `unsigned` `int`` | `get_height` | `() `const``;
``virtual` `unsigned` `int`` | `get_pitch` | `() `const``;
``virtual` `unsigned` `int`` | `get_depth` | `() `const``;
``virtual` `unsigned` `int`` | `get_bytes_per_pixel` | `() `const``;
``virtual` `bool`` | `is_indexed` | `() `const``;
``virtual` `unsigned` `int`` | `get_red_mask` | `() `const``;
``virtual` `unsigned` `int`` | `get_green_mask` | `() `const``;
``virtual` `unsigned` `int`` | `get_blue_mask` | `() `const``;
``virtual` `unsigned` `int`` | `get_alpha_mask` | `() `const``;
``virtual` `CL_Palette`*` | `get_palette` | `() `const``;
``virtual` `void`` | `push_clip_rect` | `()`;
``virtual` `void`` | `push_clip_rect` | `(`const` `CL_ClipRect`& `rect`)`;
``virtual` `CL_ClipRect`` | `get_clip_rect` | `()`;
``virtual` `void`` | `set_clip_rect` | `(`const` `CL_ClipRect`& `rect`)`;
``virtual` `void`` | `pop_clip_rect` | `()`;
``virtual` `void`` | `push_translate_offset` | `()`;
``virtual` `void`` | `push_translate_offset` | `(`int` `x`, `int` `y`)`;
``virtual` `int`` | `get_translate_offset_x` | `() `const``;
``virtual` `int`` | `get_translate_offset_y` | `() `const``;
``virtual` `void`` | `set_translate_offset` | `(`int` `x`, `int` `y`)`;
``virtual` `void`` | `pop_translate_offset` | `()`;

### Operations:

``void`` | `draw_pixel` | `(`int` `x1`, `int` `y1`, `int` `color`)`;
``virtual` `void`` | `draw_pixel` | `(`int` `x`, `int` `y`, `float` `r`, `float` `g`, `float` `b`, `float` `a` = 1.0)`;
``virtual` `void`` | `get_pixel` | `(`int` `x`, `int` `y`, `float`* `r`, `float`* `g`, `float`* `b`, `float`* `a`)`;
``virtual` `int`` | `get_pixel` | `(`int` `x`, `int` `y`)`;
``void`` | `flip_vertical` | `()`;
``void`` | `flip_horizontal` | `()`;
``virtual` `void`` | `fill_rect` | `(`int` `x1`, `int` `y1`, `int` `x2`, `int` `y2`, `float` `r`, `float` `g`, `float` `b`, `float` `a` = 1.0)`;
``virtual` `void`` | `draw_rect` | `(`int` `x1`, `int` `y1`, `int` `x2`, `int` `y2`, `float` `r`, `float` `g`, `float` `b`, `float` `a` = 1.0)`;
``virtual` `void`` | `draw_line` | `(`int` `x1`, `int` `y1`, `int` `x2`, `int` `y2`, `float` `r`, `float` `g`, `float` `b`, `float` `a` = 1.0)`;

## Description:

The CL_Target class represents a renderer target in ClanLib. This can be a part of the framebuffer, or a piece of memory specified by the application.
This class contains a set of functions used to describe a piece of memory, things such as the width, height, color masks and depth. This information can then be used by ClanLib or the application to access the given piece of memory.
To access the memory itself, call get_data() after a call to lock(). When you are finished accessing the memory, call unlock(). Note that after the unlock() call, the pointer obtained from get_data() will be invalid, and new call to lock() is required before get_data() will return anything valid.
CL_Target contain a set of functions doing simple primitive operations: draw boxes, lines and clipping. These are provided for convience so you won't have to do such simple things manually in a lock session.
CL_Surface supports blitting to a target and all surface providers are inheritated from a target. This means that you can do surface to provider blitting. ClanLib has a special surface provider called CL_Canvas which you should use to easilly build a new image.

## Function Member Descriptions:

CL_Target::CL_Target - Target Constructor
`` `CL_Target` `()`;

CL_Target::draw_line - Draw a line from ('x1', 'y1') to ('x2', 'y2') using the color ('r', 'g', 'b', 'a').
``virtual` `void`` `draw_line` `(`int` `x1`, `int` `y1`, `int` `x2`, `int` `y2`, `float` `r`, `float` `g`, `float` `b`, `float` `a` = 1.0)`;

> x1 - Leftmost x-coordinate. //FIXME
> y1 - Upper y-coordinate.
> x2 - Rightmost x-coordinate.
> y2 - Lower y-coordinate.
> r - Red component of the filled color.
> g - Green component of the filled color.
> b - Blue component of the filled color.
> a - Alpha component of the filled color.

CL_Target::draw_pixel - Draw Pixel
``void`` `draw_pixel` `(`int` `x1`, `int` `y1`, `int` `color`)`;

CL_Target::draw_pixel - Draw Pixel
``virtual` `void`` `draw_pixel` `(`int` `x`, `int` `y`, `float` `r`, `float` `g`, `float` `b`, `float` `a` = 1.0)`;

CL_Target::draw_rect - Draw a rectangle from ('x1', 'y1') to ('x2', 'y2') using the color ('r', 'g', 'b', 'a').
``virtual` `void`` `draw_rect` `(`int` `x1`, `int` `y1`, `int` `x2`, `int` `y2`, `float` `r`, `float` `g`, `float` `b`, `float` `a` = 1.0)`;

> x1 - Leftmost x-coordinate.
> y1 - Upper y-coordinate.
> x2 - Rightmost x-coordinate.
> y2 - Lower y-coordinate.
> r - Red component of the filled color.
> g - Green component of the filled color.
> b - Blue component of the filled color.
> a - Alpha component of the filled color.

CL_Target::fill_rect - Draw a filled rectangle from ('x1', 'y1') to ('x2', 'y2') using the color ('r', 'g', 'b', 'a').
``virtual` `void`` `fill_rect` `(`int` `x1`, `int` `y1`, `int` `x2`, `int` `y2`, `float` `r`, `float` `g`, `float` `b`, `float` `a` = 1.0)`;

> x1 - Leftmost x-coordinate.
> y1 - Upper y-coordinate.
> x2 - Rightmost x-coordinate.
> y2 - Lower y-coordinate.
> r - Red component of the filled color.
> g - Green component of the filled color.
> b - Blue component of the filled color.
> a - Alpha component of the filled color.

CL_Target::flip_horizontal - Flips along the X-axis
``void`` `flip_horizontal` `()`;

CL_Target::flip_vertical - Flips along the Y-axis
``void`` `flip_vertical` `()`;

CL_Target::get_alpha_mask - Returns the alpha mask by the target.
``virtual` `unsigned` `int`` `get_alpha_mask` `() `const``;

CL_Target::get_blue_mask - Returns the blue color mask by the target.
``virtual` `unsigned` `int`` `get_blue_mask` `() `const``;

CL_Target::get_bytes_per_pixel - Returns the bytes per pixel of the target.
``virtual` `unsigned` `int`` `get_bytes_per_pixel` `() `const``;

CL_Target::get_clip_rect - Returns the current clipping rectangle.
``virtual` `CL_ClipRect`` `get_clip_rect` `()`;

> Returns - The current clipping rectangle.

CL_Target::get_data - Returns a pointer to the target data. Only valid between lock/unlock calls.
``virtual` `void`*` `get_data` `() `const``;

> Returns - A pointer that points to the beginning of the target pixel data.

CL_Target::get_depth - Returns the depth used by the target.
``virtual` `unsigned` `int`` `get_depth` `() `const``;

CL_Target::get_green_mask - Returns the green color mask by the target.
``virtual` `unsigned` `int`` `get_green_mask` `() `const``;

CL_Target::get_height - Returns the height of the target.
``virtual` `unsigned` `int`` `get_height` `() `const``;

CL_Target::get_num_frames - Returns the number of frames available on this target.
``virtual` `unsigned` `int`` `get_num_frames` `() `const``;

CL_Target::get_palette - Returns the palette used by the target.
``virtual` `CL_Palette`*` `get_palette` `() `const``;

CL_Target::get_pitch - Returns the pitch (bytes per line) used by the target.
``virtual` `unsigned` `int`` `get_pitch` `() `const``;

CL_Target::get_pixel - Get Pixel
``virtual` `void`` `get_pixel` `(`int` `x`, `int` `y`, `float`* `r`, `float`* `g`, `float`* `b`, `float`* `a`)`;

CL_Target::get_pixel - Get Pixel
``virtual` `int`` `get_pixel` `(`int` `x`, `int` `y`)`;

CL_Target::get_red_mask - Returns the red color mask used by the target.
``virtual` `unsigned` `int`` `get_red_mask` `() `const``;

CL_Target::get_translate_offset_x - Returns the current effective x-axis translation offset.
``virtual` `int`` `get_translate_offset_x` `() `const``;

CL_Target::get_translate_offset_y - Returns the current effective y-axis translation offset.
``virtual` `int`` `get_translate_offset_y` `() `const``;

CL_Target::get_width - Returns the width of the target.
``virtual` `unsigned` `int`` `get_width` `() `const``;

CL_Target::is_indexed - Returns whether the target uses an indexed color mode or not.
``virtual` `bool`` `is_indexed` `() `const``;

CL_Target::is_video - Returns true if in video memory.
``virtual` `bool`` `is_video` `() `const``;

> Returns - True if stored in video memory, false otherwise.

CL_Target::lock - Locks the target. This allows access to the target data using the get_data() function call.
``virtual` `void`` `lock` `()`;

CL_Target::pop_clip_rect - Pop the clipping rectangle last pushed onto the stack.
``virtual` `void`` `pop_clip_rect` `()`;

CL_Target::pop_translate_offset - Pops the last pushed translation offset from the translation offset stack. If the stack is empty, nothing will happen, and if the last translation offset is popped, the translation offset will be set to 0,0
``virtual` `void`` `pop_translate_offset` `()`;

CL_Target::push_clip_rect - Pushes the current clipping rectangle onto the cliprect stack.
``virtual` `void`` `push_clip_rect` `()`;

CL_Target::push_clip_rect - Pushes the current clipping rectangle onto the cliprect stack. It then clips the passed rectangle 'rect' with the current one, and uses the result as the new clipping rect.
``virtual` `void`` `push_clip_rect` `(`const` `CL_ClipRect`& `rect`)`;

> rect - The new clipping rectangle to be clipped with the current cliprect and then used.

CL_Target::push_translate_offset - Pushes the current translation rectangle onto the cliprect stack.
``virtual` `void`` `push_translate_offset` `()`;

CL_Target::push_translate_offset - Push translation offset onto translation stack. This offset will affect any subsequent display operations on the displaycard, by translating the position of the display operation with the offset. The offset will be offset by any previous offsets pushed onto the stack, eg. it inherits the previous offset.
``virtual` `void`` `push_translate_offset` `(`int` `x`, `int` `y`)`;

CL_Target::set_clip_rect - Sets the current clipping rectangle. This is an absolute set, so it doesn't
get clipped with the previous one.
``virtual` `void`` `set_clip_rect` `(`const` `CL_ClipRect`& `rect`)`;

CL_Target::set_translate_offset - Sets the translation offset as a new absolute translation offset. The new offset will disregard any previous offset's, but will not empty the translation stack. The new translation offset will affect any subsequent display operations on the displaycard, by translating the position of the display operation with the offset
``virtual` `void`` `set_translate_offset` `(`int` `x`, `int` `y`)`;

CL_Target::unlock - Unlock the target. Must be called after you're finished with modifying the target data.
``virtual` `void`` `unlock` `()`;

CL_Target::~CL_Target - Target destructor
``virtual`` `~CL_Target` `()`;

## Variable Member Descriptions: