Detailed Description

These functions provide the basic libcaca routines for display initialisation, system information retrieval and configuration.

Function Documentation

__extern \fBcaca_display_t\fP* caca_create_display (\fBcaca_canvas_t\fP *cv)

Create a graphical context using device-dependent features (ncurses for terminals, an X11 window, a DOS command window...) that attaches to a libcaca canvas. Everything that gets drawn in the libcaca canvas can then be displayed by the libcaca driver.

If no caca canvas is provided, a new one is created. Its handle can be retrieved using caca_get_canvas() and it is automatically destroyed when caca_free_display() is called.

See also caca_create_display_with_driver().

If an error occurs, NULL is returned and errno is set accordingly:

  • ENOMEM Not enough memory.

  • ENODEV Graphical device could not be initialised.

Parameters:

cv The caca canvas or NULL to create a canvas automatically.

Returns:

The caca graphical context or NULL if an error occurred.

References caca_create_display_with_driver().

__extern \fBcaca_display_t\fP* caca_create_display_with_driver (\fBcaca_canvas_t\fP *cv, char const *driver)

Create a graphical context using device-dependent features (ncurses for terminals, an X11 window, a DOS command window...) that attaches to a libcaca canvas. Everything that gets drawn in the libcaca canvas can then be displayed by the libcaca driver.

If no caca canvas is provided, a new one is created. Its handle can be retrieved using caca_get_canvas() and it is automatically destroyed when caca_free_display() is called.

If no driver name is provided, libcaca will try to autodetect the best output driver it can.

See also caca_create_display().

If an error occurs, NULL is returned and errno is set accordingly:

  • ENOMEM Not enough memory.

  • ENODEV Graphical device could not be initialised.

Parameters:

cv The caca canvas or NULL to create a canvas automatically.

driver A string describing the desired output driver or NULL to choose the best driver automatically.

Returns:

The caca graphical context or NULL if an error occurred.

References caca_create_canvas(), caca_free_canvas(), caca_manage_canvas(), and caca_unmanage_canvas().

Referenced by caca_create_display().

__extern char const* const* caca_get_display_driver_list (void)

Return a list of available display drivers. The list is a NULL-terminated array of strings, interleaving a string containing the internal value for the display driver, and a string containing the natural language description for that driver.

This function never fails.

Returns:

An array of strings.

__extern char const* caca_get_display_driver (\fBcaca_display_t\fP *dp)

Return the given display's current output driver.

This function never fails.

Parameters:

dp The caca display.

Returns:

A static string.

__extern int caca_set_display_driver (\fBcaca_display_t\fP *dp, char const *driver)

Dynamically change the given display's output driver.

FIXME: decide what to do in case of failure

Parameters:

dp The caca display.

driver A string describing the desired output driver or NULL to choose the best driver automatically.

Returns:

0 in case of success, -1 if an error occurred.

__extern int caca_free_display (\fBcaca_display_t\fP *dp)

Detach a graphical context from its caca backend and destroy it. The libcaca canvas continues to exist and other graphical contexts can be attached to it afterwards.

If the caca canvas was automatically created by caca_create_display(), it is automatically destroyed and any handle to it becomes invalid.

This function never fails.

Parameters:

dp The libcaca graphical context.

Returns:

This function always returns 0.

References caca_free_canvas(), and caca_unmanage_canvas().

__extern \fBcaca_canvas_t\fP* caca_get_canvas (\fBcaca_display_t\fP *dp)

Return a handle on the caca_canvas_t object that was either attached or created by caca_create_display().

This function never fails.

Parameters:

dp The libcaca graphical context.

Returns:

The libcaca canvas.

__extern int caca_refresh_display (\fBcaca_display_t\fP *dp)

Flush all graphical operations and print them to the display device. Nothing will show on the screen until this function is called.

If caca_set_display_time() was called with a non-zero value, caca_refresh_display() will use that value to achieve constant framerate: if two consecutive calls to caca_refresh_display() are within a time range shorter than the value set with caca_set_display_time(), the second call will be delayed before performing the screen refresh.

This function never fails.

Parameters:

dp The libcaca display context.

Returns:

This function always returns 0.

References caca_clear_dirty_rect_list().

__extern int caca_set_display_time (\fBcaca_display_t\fP *dp, intusec)

Set the refresh delay in microseconds. The refresh delay is used by caca_refresh_display() to achieve constant framerate. See the caca_refresh_display() documentation for more details.

If the argument is zero, constant framerate is disabled. This is the default behaviour.

If an error occurs, -1 is returned and errno is set accordingly:

  • EINVAL Refresh delay value is invalid.

Parameters:

dp The libcaca display context.

usec The refresh delay in microseconds.

Returns:

0 upon success, -1 if an error occurred.

__extern int caca_get_display_time (\fBcaca_display_t\fP const *dp)

Get the average rendering time, which is the average measured time between two caca_refresh_display() calls, in microseconds. If constant framerate was activated by calling caca_set_display_time(), the average rendering time will be close to the requested delay even if the real rendering time was shorter.

This function never fails.

Parameters:

dp The libcaca display context.

Returns:

The render time in microseconds.

__extern int caca_get_display_width (\fBcaca_display_t\fP const *dp)

If libcaca runs in a window, get the usable window width. This value can be used for aspect ratio calculation. If libcaca does not run in a window or if there is no way to know the font size, most drivers will assume a 6x10 font is being used. Note that the units are not necessarily pixels.

This function never fails.

Parameters:

dp The libcaca display context.

Returns:

The display width.

__extern int caca_get_display_height (\fBcaca_display_t\fP const *dp)

If libcaca runs in a window, get the usable window height. This value can be used for aspect ratio calculation. If libcaca does not run in a window or if there is no way to know the font size, assume a 6x10 font is being used. Note that the units are not necessarily pixels.

This function never fails.

Parameters:

dp The libcaca display context.

Returns:

The display height.

__extern int caca_set_display_title (\fBcaca_display_t\fP *dp, char const *title)

If libcaca runs in a window, try to change its title. This works with the ncurses, S-Lang, OpenGL, X11 and Win32 drivers.

If an error occurs, -1 is returned and errno is set accordingly:

  • ENOSYS Display driver does not support setting the window title.

Parameters:

dp The libcaca display context.

title The desired display title.

Returns:

0 upon success, -1 if an error occurred.

__extern int caca_set_mouse (\fBcaca_display_t\fP *dp, intflag)

Show or hide the mouse pointer. This function works with the ncurses, S-Lang and X11 drivers.

If an error occurs, -1 is returned and errno is set accordingly:

  • ENOSYS Display driver does not support hiding the mouse pointer.

Parameters:

dp The libcaca display context.

flag 0 hides the pointer, 1 shows the system's default pointer (usually an arrow). Other values are reserved for future use.

Returns:

0 upon success, -1 if an error occurred.

__extern int caca_set_cursor (\fBcaca_display_t\fP *dp, intflag)

Show or hide the cursor, for devices that support such a feature.

If an error occurs, -1 is returned and errno is set accordingly:

  • ENOSYS Display driver does not support showing the cursor.

Parameters:

dp The libcaca display context.

flag 0 hides the cursor, 1 shows the system's default cursor (usually a white rectangle). Other values are reserved for future use.

Returns:

0 upon success, -1 if an error occurred.

Referenced by caca_conio__setcursortype().

Author

Generated automatically by Doxygen for libcaca from the source code.