---
name: "CL_Target"
section: "3"
platform: "linux"
package: "clanlib0-common-dev"
version: "0.4.4-8"
release: "Debian 3.0 (Woody)"
platforms: ["linux"]
url: "https://new.carta.tech/CL_Target"
---

# CL\_Target(3)

Target class in ClanLib.

## NAME

CL\_Target - Target class in ClanLib.

## 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.

## CLASS MEMBERS

- virtual **~CL\_Target**()

  - virtual bool **is\_video**()

  - virtual void **lock**()

  - virtual void **unlock**()

  - virtual void \***get\_data**()

  - virtual unsigned int **get\_num\_frames**()

  - virtual unsigned int **get\_width**()

  - virtual unsigned int **get\_height**()

  - virtual unsigned int **get\_pitch**()

  - virtual unsigned int **get\_depth**()

  - virtual unsigned int **get\_bytes\_per\_pixel**()

  - virtual bool **is\_indexed**()

  - virtual unsigned int **get\_red\_mask**()

  - virtual unsigned int **get\_green\_mask**()

  - virtual unsigned int **get\_blue\_mask**()

  - virtual unsigned int **get\_alpha\_mask**()

  - virtual CL\_Palette \***get\_palette**()

  - 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**()

  - 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)
  ```

- 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\_line**(

  ```
  int x1,
  int y1,
  int x2,
  int y2,
  float r,
  float g,
  float b,
  float a = 1.0)
  ```

## MEMBERS WITH DESCRIPTIONS

- virtual **~CL\_Target**()

  ```
  Description:
  ```

- virtual bool **is\_video**()

  ```
  Description:
  ```

  Returns true if in video memory.

  ```
  Return value:
  ```

  True if stored in video memory, false otherwise.

- virtual void **lock**()

  ```
  Description:
  ```

  Locks the target. This allows access to the target data using theget\_data() function call.

- virtual void **unlock**()

  ```
  Description:
  ```

  Unlock the target. Must be called after you're finished with modifyingthe target data.

- virtual void \***get\_data**()

  ```
  Description:
  ```

  Returns a pointer to the target data. Only valid between lock/unlockcalls.

  ```
  Return value:
  ```

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

- virtual unsigned int **get\_num\_frames**()

  ```
  Description:
  ```

  Returns the number of frames available on this target.

- virtual unsigned int **get\_width**()

  ```
  Description:
  ```

  Returns the width of the target.

- virtual unsigned int **get\_height**()

  ```
  Description:
  ```

  Returns the height of the target.

- virtual unsigned int **get\_pitch**()

  ```
  Description:
  ```

  Returns the pitch (bytes per line) used by the target.

- virtual unsigned int **get\_depth**()

  ```
  Description:
  ```

  Returns the depth used by the target.

- virtual unsigned int **get\_bytes\_per\_pixel**()

  ```
  Description:
  ```

  Returns the bytes per pixel of the target.

- virtual bool **is\_indexed**()

  ```
  Description:
  ```

  Returns whether the target uses an indexed color mode or not.

- virtual unsigned int **get\_red\_mask**()

  ```
  Description:
  ```

  Returns the red color mask used by the target.

- virtual unsigned int **get\_green\_mask**()

  ```
  Description:
  ```

  Returns the green color mask by the target.

- virtual unsigned int **get\_blue\_mask**()

  ```
  Description:
  ```

  Returns the blue color mask by the target.

- virtual unsigned int **get\_alpha\_mask**()

  ```
  Description:
  ```

  Returns the alpha mask by the target.

- virtual CL\_Palette \***get\_palette**()

  ```
  Description:
  ```

  Returns the palette used by the target.

- virtual void **push\_clip\_rect**()

  ```
  Description:
  ```

  Pushes the current clipping rectangle onto the cliprect stack.

- virtual void **push\_clip\_rect**(

  ```
  const CL_ClipRect &rect)
  ```

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

  ```
  Description:
  ```

  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 CL\_ClipRect **get\_clip\_rect**()

  ```
  Description:
  ```

  Returns the current clipping rectangle.

  ```
  Return value:
  ```

  The current clipping rectangle.

- virtual void **set\_clip\_rect**(

  ```
  const CL_ClipRect &rect)
  ```

  ```
  Description:
  ```

  Sets the current clipping rectangle. This is an absolute set, so it doesn'tget clipped with the previous one.

- virtual void **pop\_clip\_rect**()

  ```
  Description:
  ```

  Pop the clipping rectangle last pushed onto the stack.

- void **draw\_pixel**(

  ```
  int x1,
  int y1,
  int color)
  ```

  ```
  Description:
  ```

  TODO add documentation...

- virtual void **draw\_pixel**(

  ```
  int x,
  int y,
  float r,
  float g,
  float b,
  float a = 1.0)
  ```

  ```
  Description:
  ```

- virtual void **get\_pixel**(

  ```
  int x,
  int y,
  float *r,
  float *g,
  float *b,
  float *a)
  ```

  ```
  Description:
  ```

- virtual int **get\_pixel**(

  ```
  int x,
  int y)
  ```

  ```
  Description:
  ```

- virtual void **fill\_rect**(

  ```
  int x1,
  int y1,
  int x2,
  int y2,
  float r,
  float g,
  float b,
  float a = 1.0)
  ```

  ```
  Parameters:
  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.
  ```

  ```
  Description:
  ```

  Draw a filled rectangle 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)
  ```

  ```
  Parameters:
  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.
  ```

  ```
  Description:
  ```

  Draw a line from (*x1*, *y1*) to (*x2*, *y2*) using the color(*r*, *g*, *b*, *a*).

## SEE ALSO

All ClanLib API classes can be found in **clanlib (3)**.

## AUTHORS

Originally written by Magnus Norddahl \<*mbn@dark.x.dtu.dk*\> and Martin Starch \<*starch@dark.x.dtu.dk*\>. ClanLib is now developed by the ClanLib Development team as an Open Source project.

The ClanLib man pages was created using the Perceps documentation system (another excellent piece of Open Source software, available at **http://somewhere.in.the.world.org**).

See **clanlib (3)** to find out how to get a full list of contributors and details on how to submit bug reports, comments etc.
