---
name: "CL_Display"
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_Display"
---

# CL\_Display(3)

Main Display class.

## NAME

CL\_Display - Main Display class.

## DESCRIPTION

CL\_Display is the "main" class when dealing with 2D graphics. It contains simple drawing operations, backbuffer clipping and access to the display cards available on the system.

A large amount of the functions in the class have the same purpose as their name equalient in CL\_DisplayCard. The difference is that those placed here operate on a selected display card, while those in CL\_DisplayCard class require an instance to the card.

All backbuffer related drawing operations in other classes (CL\_Surface for instance) work on the currently selected display card, unless you explict pass a pointer pointing to a display card.

The main purpose of this system is to avoid passing around a pointer to the display card in those games, where it only access one single card anyway.

When using OpenGL the GL context will always point to the selected card. So if you need to use OpenGL commands to draw onto another card, you have to select it here.

## CLASS MEMBERS

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

  - static void **flip\_display**(

  ```
  bool sync=false)
  ```

- static void **clear\_display**(

  ```
  float red=0,
  float green=0,
  float blue=0,
  float alpha=1)
  ```

- static void **set\_palette**(

  ```
  CL_Palette *palette)
  ```

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

  - static void **select\_card**(

  ```
  CL_DisplayCard *card)
  ```

- static CL\_DisplayCard \***get\_current\_card**()

  - static void **set\_videomode**(

  ```
  CL_VidMode *mode)
  ```

- static void **set\_videomode**(

  ```
   int width,
  int height,
  int bpp,
  bool fullscreen = true,
  bool allow_resize = false)
  ```

- static CL\_Target \***get\_target**()

  - static int **get\_width**()

  - static int **get\_height**()

  - static int **get\_bpp**()

  - static std::vector\<CL\_DisplayCard\*\> **cards**

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

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

  ```
  const CL_ClipRect &rect)
  ```

- static CL\_ClipRect **get\_clip\_rect**()

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

  ```
  const CL_ClipRect &rect)
  ```

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

  - static void **fill\_rect**(

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

- static void **draw\_line**(

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

- static void **sync\_buffers**()

  ## MEMBERS WITH DESCRIPTIONS

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

  ```
  Description:
  ```

- static void **flip\_display**(

  ```
  bool sync=false)
  ```

  ```
  Parameters:
  sync - VSync on/off
  ```

  ```
  Description:
  ```

  Flips the front and backbuffer. Everything is normally drawn to the backbuffer, and flip\_display() needs to be called before it can be seen onto the screen.

- static void **clear\_display**(

  ```
  float red=0,
  float green=0,
  float blue=0,
  float alpha=1)
  ```

  ```
  Parameters:
  red - red component of the color.
  green - green component of the color.
  blue - blue component of the color.
  alpha - alpha (transparency) component of the color.
  ```

  ```
  Description:
  ```

  Clears backbuffer with the specified color.

- static void **set\_palette**(

  ```
  CL_Palette *palette)
  ```

  ```
  Parameters:
  palette - Palette to use as new system palette.
  ```

  ```
  Description:
  ```

  Set system palette on this card.If the display card is in a non-palettelized mode, this will be the palette used when surfaceproviders doesn't specify a palette themself.

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

  ```
  Description:
  ```

  Return the current system palette on this card.

  ```
  Return value:
  ```

  The system palette.

- static void **select\_card**(

  ```
  CL_DisplayCard *card)
  ```

  ```
  Parameters:
  card - new selected display card.
  ```

  ```
  Description:
  ```

  Selects the display card used by the other memberfunctions of this class.

- static CL\_DisplayCard \***get\_current\_card**()

  ```
  Description:
  ```

  Returns the currently selected display card.

  ```
  Return value:
  ```

  Current display card.

- static void **set\_videomode**(

  ```
  CL_VidMode *mode)
  ```

  ```
  Parameters:
  mode - videomode to be changed to.
  ```

  ```
  Description:
  ```

  Change the display card's video mode.

- static void **set\_videomode**(

  ```
   int width,
  int height,
  int bpp,
  bool fullscreen = true,
  bool allow_resize = false)
  ```

  ```
  Parameters:
  width - width in pixels of the new video mode.
  height - height in pixels of the new video mode.
  bpp - Bits per pixel. The depth of the new video mode. (8, 16, 24, 32)
  ```

  ```
  Description:
  ```

  Change the display card's video mode.

- static CL\_Target \***get\_target**()

  ```
  Description:
  ```

  Returns either NULL or the framebuffer

  ```
  Return value:
  ```

  NULL or the framebuffer

- static int **get\_width**()

  ```
  Description:
  ```

  Returns the width of the current video mode.

  ```
  Return value:
  ```

  Width of current video mode.

- static int **get\_height**()

  ```
  Description:
  ```

  Returns the height of the current video mode.

  ```
  Return value:
  ```

  Height of current video mode.

- static int **get\_bpp**()

  ```
  Description:
  ```

  Returns the depth of the current video mode.

  ```
  Return value:
  ```

  Depth of current video mode.

- static std::vector\<CL\_DisplayCard\*\> **cards**

  ```
  Description:
  ```

  The list of display cards available to the application.

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

  ```
  Description:
  ```

  Pushes the current clipping rectangle onto the cliprect stack.

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

  ```
  const CL_ClipRect &rect)
  ```

  ```
  Parameters:
  rect - The new clipping rectangle to be with the old one 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.

- static CL\_ClipRect **get\_clip\_rect**()

  ```
  Description:
  ```

  Returns the current clipping rectangle.

  ```
  Return value:
  ```

  The current clipping rectangle.

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

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

  ```
  Description:
  ```

  Pop the clipping rectangle last pushed onto the stack.

- static void **fill\_rect**(

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

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

- static void **draw\_line**(

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

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

- static void **sync\_buffers**()

  ```
  Description:
  ```

  Copies the contents of the frontbuffer to all other buffers (usually justthe backbuffer). This ensures that all buffers contain the same image.

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