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

# Class CL_Display

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

#include <ClanLib/display.h>

### public function member index:

### Construction:

``virtual`` | `~CL_Display` | `()`;

### Operations (Display Functions):

``static` `void`` | `flip_display` | `(`bool` `sync`=false)`;
``static` `void`` | `put_display` | `(`const` `CL_Rect`& `rect`)`;
``static` `void`` | `sync_buffers` | `()`;
``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` `void`` | `set_videomode` | `(`CL_VidMode`* `mode`)`;
``static` `void`` | `set_videomode` | `(`int` `width`, `int` `height`, `int` `bpp`, `bool` `fullscreen` = false, `bool` `allow_resize` = false, `bool` `video_memory` = true)`;

### Attributes:

``static` `CL_DisplayCard`*` | `get_current_card` | `()`;
``static` `CL_Target`*` | `get_target` | `()`;
``static` `int`` | `get_width` | `()`;
``static` `int`` | `get_height` | `()`;
``static` `int`` | `get_bpp` | `()`;
``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`` | `push_translate_offset` | `()`;
``static` `void`` | `push_translate_offset` | `(`int` `x`, `int` `y`)`;
``static` `int`` | `get_translate_offset_x` | `()`;
``static` `int`` | `get_translate_offset_y` | `()`;
``static` `void`` | `set_translate_offset` | `(`int` `x`, `int` `y`)`;
``static` `void`` | `pop_translate_offset` | `()`;

### Operations (Draw functions):

``static` `void`` | `draw_rect` | `(`int` `x1`, `int` `y1`, `int` `x2`, `int` `y2`, `float` `r`, `float` `g`, `float` `b`, `float` `a`=1.0f)`;
``static` `void`` | `fill_rect` | `(`int` `x1`, `int` `y1`, `int` `x2`, `int` `y2`, `float` `r`, `float` `g`, `float` `b`, `float` `a`=1.0f)`;
``static` `void`` | `draw_line` | `(`int` `x1`, `int` `y1`, `int` `x2`, `int` `y2`, `float` `r`, `float` `g`, `float` `b`, `float` `a`=1.0f)`;
``static` `void`` | `fill_rect` | `(`int` `x1`, `int` `y1`, `int` `x2`, `int` `y2`, `CL_Surface`* `fill_surface`, `int` `focus_x`=0, `int` `focus_y`=0)`;

### Signals:

``static` `CL_Signal_v2`<`int`, `int`>&` | `sig_resized` | `()`;
``static` `CL_Signal_v1`<`const` `CL_Rect`& >&` | `sig_paint` | `()`;

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

## Function Member Descriptions:

CL_Display::clear_display - Clears backbuffer with the specified color.
``static` `void`` `clear_display` `(`float` `red`=0, `float` `green`=0, `float` `blue`=0, `float` `alpha`=1)`;

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

CL_Display::draw_line - Draw a line 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`=1.0f)`;

> 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_Display::draw_rect - Draw a rectangle from ('x1', 'y1') to ('x2', 'y2') using the color ('r', 'g', 'b', 'a').
``static` `void`` `draw_rect` `(`int` `x1`, `int` `y1`, `int` `x2`, `int` `y2`, `float` `r`, `float` `g`, `float` `b`, `float` `a`=1.0f)`;

> 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_Display::fill_rect - Draw a filled rectangle from ('x1', 'y1') to ('x2', 'y2') using the color ('r', 'g', 'b', 'a').
``static` `void`` `fill_rect` `(`int` `x1`, `int` `y1`, `int` `x2`, `int` `y2`, `float` `r`, `float` `g`, `float` `b`, `float` `a`=1.0f)`;

> 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_Display::fill_rect - Draw a filled rectangle from ('x1', 'y1') to ('x2', 'y2') using the surface 'fill_surface' as tiled background
``static` `void`` `fill_rect` `(`int` `x1`, `int` `y1`, `int` `x2`, `int` `y2`, `CL_Surface`* `fill_surface`, `int` `focus_x`=0, `int` `focus_y`=0)`;

> x1 - Leftmost x-coordinate.
> y1 - Upper y-coordinate.
> x2 - Rightmost x-coordinate.
> y2 - Lower y-coordinate.
> fill_surface - surface used to fill the area (tiled)
> focus_x - destination x offset used to offset (0, 0) in fill_surface (controls tiling position)
> focus_y - destination y offset used to offset (0, 0) in fill_surface (controls tiling position)

CL_Display::flip_display - 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`` `flip_display` `(`bool` `sync`=false)`;

> sync - VSync on/off

CL_Display::get_bpp - Returns the depth of the current video mode.
``static` `int`` `get_bpp` `()`;

> Returns - Depth of current video mode.

CL_Display::get_clip_rect - Returns the current clipping rectangle.
``static` `CL_ClipRect`` `get_clip_rect` `()`;

> Returns - The current clipping rectangle.

CL_Display::get_current_card - Returns the currently selected display card.
``static` `CL_DisplayCard`*` `get_current_card` `()`;

> Returns - Current display card.

CL_Display::get_height - Returns the height of the current video mode.
``static` `int`` `get_height` `()`;

> Returns - Height of current video mode.

CL_Display::get_palette - Return the current system palette on this card.
``static` `CL_Palette`*` `get_palette` `()`;

> Returns - The system palette.

CL_Display::get_target - Returns either NULL or the framebuffer
``static` `CL_Target`*` `get_target` `()`;

> Returns - NULL or the framebuffer

CL_Display::get_translate_offset_x - Returns the current effective x-axis translation offset.
``static` `int`` `get_translate_offset_x` `()`;

CL_Display::get_translate_offset_y - Returns the current effective y-axis translation offset.
``static` `int`` `get_translate_offset_y` `()`;

CL_Display::get_width - Returns the width of the current video mode.
``static` `int`` `get_width` `()`;

> Returns - Width of current video mode.

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

CL_Display::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
``static` `void`` `pop_translate_offset` `()`;

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

CL_Display::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.
``static` `void`` `push_clip_rect` `(`const` `CL_ClipRect`& `rect`)`;

> rect - The new clipping rectangle to be with the old one and then used.

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

CL_Display::push_translate_offset - Push translation offset onto translation stack. This offset will affect any subsequent display operations on the current 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.
``static` `void`` `push_translate_offset` `(`int` `x`, `int` `y`)`;

CL_Display::put_display - Copies the specified area of the backbuffer to the front buffer.
This is in particular useful if you only want to update a limited region, and not - do a full-blown flipping.
``static` `void`` `put_display` `(`const` `CL_Rect`& `rect`)`;

CL_Display::select_card - Selects the display card used by the other memberfunctions of this class.
``static` `void`` `select_card` `(`CL_DisplayCard`* `card`)`;

> card - new selected display card.

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

CL_Display::set_palette - 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` `void`` `set_palette` `(`CL_Palette`* `palette`)`;

> palette - Palette to use as new system palette.

CL_Display::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 current displaycard, by translating the position of the display operation with the offset
``static` `void`` `set_translate_offset` `(`int` `x`, `int` `y`)`;

CL_Display::set_videomode - Change the display card's video mode.
``static` `void`` `set_videomode` `(`CL_VidMode`* `mode`)`;

> mode - videomode to be changed to.
> See also: CL_VidMode - Video mode description class.

CL_Display::set_videomode - Change the display card's video mode.
``static` `void`` `set_videomode` `(`int` `width`, `int` `height`, `int` `bpp`, `bool` `fullscreen` = false, `bool` `allow_resize` = false, `bool` `video_memory` = true)`;

> 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)
> video_memory - Use video memory if possible. System memory may be faster if alpha blending is used a lot.

CL_Display::sig_paint - Returns the paint signal for the currently selected display card.
Use this signal to listen for invalidated screen areas that need to be repainted.
The parameter passed by the signal is the area that need a repaint.
``static` `CL_Signal_v1`<`const` `CL_Rect`& >&` `sig_paint` `()`;

CL_Display::sig_resized - Returns the resize signal for the currently selected display card.
You can use this signal to listen for window resize events.
The parameters passed by the signal are the new width and height of the window.
``static` `CL_Signal_v2`<`int`, `int`>&` `sig_resized` `()`;

CL_Display::sync_buffers - Copies the contents of the frontbuffer to all other buffers (usually just the backbuffer).
This ensures that all buffers contain the same image.
``static` `void`` `sync_buffers` `()`;

## Variable Member Descriptions:

CL_Display::cards - The list of display cards available to the application.
``static` `std::vector`<`CL_DisplayCard`*>` ``cards`;`