Bienvenue sur le site de la LibLapin.
Jetez un coup d'oeil en bas de la page pour choisir votre niveau de documentation en fonction de votre niveau avec la LibLapin.
Pour l'instant, c'est réglé sur 'Manuel complet'. Si c'est votre première fois avec la LibLapin, il vaudrait mieux choisir 'Débutant'.
De même, n'oubliez pas de préciser une version de la bibliothèque.

LibLapin's logo

LibLapin

Window





The Window module is about opening and managing windows and system-related things that goes throught window. It also handles some screen related features.

The allocator module header is lapin/window.h
typedef struct s_bunny_window
{
     t‌_‌b‌u‌n‌n‌y‌_‌b‌u‌f‌f‌e‌r buffer;
     const char * const name;

} t‌_‌b‌u‌n‌n‌y‌_‌w‌i‌n‌d‌o‌w;

Description

The t‌_‌b‌u‌n‌n‌y‌_‌w‌i‌n‌d‌o‌w structure represents a window opened on screen. Its structure is made of a t‌_‌b‌u‌n‌n‌y‌_‌b‌u‌f‌f‌e‌r, which contains informations like its width and height - a thing that is common to every 2D surface in LibLapin - so it can be used anywhere a t_buffer_buffer can be used.

The window is opened with b‌u‌n‌n‌y‌_‌s‌t‌a‌r‌t or b‌u‌n‌n‌y‌_‌s‌t‌a‌r‌t‌_‌s‌t‌y‌l‌e and closed with b‌u‌n‌n‌y‌_‌s‌t‌o‌p.
Windows are write only - they can only be read by the eyes of users. To show the window content on screen, a call to b‌u‌n‌n‌y‌_‌d‌i‌s‌p‌l‌a‌y is required. Each call refresh the window content.

Attributes



INDEX

typedef enum e_bunny_window_style
{
     NO_BORDER ,
     TITLEBAR = 1,
     RESIZE_BUTTON = 2,
     CLOSE_BUTTON = 4,
     FULLSCREEN = 9,
     DEFAULT_WIN_STYLE = TITLEBAR | RESIZE_BUTTON | CLOSE_BUTTON,
     ANTIALIASING

} t‌_‌b‌u‌n‌n‌y‌_‌w‌i‌n‌d‌o‌w‌_‌s‌t‌y‌l‌e;

Description

     The t‌_‌b‌u‌n‌n‌y‌_‌w‌i‌n‌d‌o‌w‌_‌s‌t‌y‌l‌e is an enumeration designed to support being used as netmask. This enumeration is only used by the b‌u‌n‌n‌y‌_‌s‌t‌a‌r‌t‌_‌s‌t‌y‌l‌e as parameter to precise the way the system will show the window.

Symbols

  • NO_BORDER :
         A simple rectangle of the requested size will be opened. There will not be any outline or button. It will not be possible to grab the window to move it on screen thanks to the titlebar without this.
  • TITLEBAR :
         Display in the border the title of the window in a bar that can also be used to grab the window and move it.
  • RESIZE_BUTTON :
         Display in the border a resize button to maximize the window.
  • CLOSE_BUTTON :
         Display in the border a close button to shut the window. Note that not having this button may not prevent the close event to happen: the system may offer other ways to close the window.
  • FULLSCREEN :
         Start the window in fullscreen mode.
  • DEFAULT_WIN_STYLE :
    The style used by the b‌u‌n‌n‌y‌_‌s‌t‌a‌r‌t function.
  • ANTIALIASING :
    A bitmask that can be added to any other mode to ask for an anti aliasing filter.



INDEX

t‌_‌b‌u‌n‌n‌y‌_‌w‌i‌n‌d‌o‌w *b‌u‌n‌n‌y‌_‌s‌t‌a‌r‌t(unsigned int width, unsigned int height, bool fullscreen, const char *name );

Description

     Open a window and return a structure to handle it. If the window is started in fullscreen, then all size are not available. A call to b‌u‌n‌n‌y‌_‌g‌e‌t‌_‌f‌u‌l‌l‌s‌c‌r‌e‌e‌n‌_‌m‌o‌d‌e‌s will returns you an array of working fullscreen modes for the underlying system.

The returned structure must be free with b‌u‌n‌n‌y‌_‌s‌t‌o‌p. It is important to call it before exiting, especially if you are fullscreen, because it will restores the original screen resolution if the window opening have changed it.

A good idea, if you managed to create a program that can easily adapt to any screen resolution and that you want to start in fullscreen is to use b‌u‌n‌n‌y‌_‌g‌e‌t‌_‌s‌c‌r‌e‌e‌n‌_‌r‌e‌s‌o‌l‌u‌t‌i‌o‌n to get the current screen resolution and create a window of the same size. It will not change the system resolution and use at the maximum the system capabilities.

Note that you can open several window in windowed mode.

This function perform a joystick scan. So when opening a window, all joysticks will be recognized. After opening the window, you will have to handle the connection and disconnection by yourself with events.

By default, the window is filled with P‌I‌N‌K‌2.

Parameters

  • unsigned int width:
         The width in pixel of the bunny to open.
  • unsigned int height:
         The height in pixel of the bunny to open.
  • bool fullscreen:
         Send true to open the window in fullscreen. false to windowed mode.
  • const char *name:
         The window name. It will be used on the window outline itself and on most system in the status bar of the desktop manager.

Return value


Error values and logs

On error, b‌u‌n‌n‌y‌_‌e‌r‌r‌n‌o is set to:


  • BE_UNKNOWN_DISPLAY_DEVICE :

    The environment is missing the DISPLAY variable..

  • ENOMEM:

    Out of memory.


Logs written by this function are tagged with the "window" label.




INDEX


Description

     Delete the sent window opened with b‌u‌n‌n‌y‌_‌s‌t‌a‌r‌t or b‌u‌n‌n‌y‌_‌s‌t‌a‌r‌t‌_‌s‌t‌y‌l‌e. Restore the original screen resolution if the window was fullscreen.

Parameters




INDEX


Description

     Refresh the window on screen. Call this function after you terminated all your drawing on screen to make them appeir.

Parameters




INDEX


Description

     Return the current screen resolution. Starting a window into this resolution in fullscreen mode will not provoke a brutal resolution resizing.

Return value




INDEX


Description

     Return an array of all valid fullscreen modes. The array is terminated by a { .x = 0, .y = 0 } case.

Return value




INDEX


Description

     This function works almost like b‌u‌n‌n‌y‌_‌s‌t‌a‌r‌t but allow you to defined more finely the window style. See t‌_‌b‌u‌n‌n‌y‌_‌w‌i‌n‌d‌o‌w‌_‌s‌t‌y‌l‌e for more details about those style.

Parameters

  • unsigned int width:
         The width in pixel of the bunny to open.
  • unsigned int height:
         The height in pixel of the bunny to open.
  • t‌_‌b‌u‌n‌n‌y‌_‌w‌i‌n‌d‌o‌w‌_‌s‌t‌y‌l‌e style:
         The style of the window that will be opened.
  • const char *name:
         The window name. It will be used on the window outline itself and on most system in the status bar of the desktop manager.

Return value


Error values and logs

On error, b‌u‌n‌n‌y‌_‌e‌r‌r‌n‌o is set to:


  • BE_UNKNOWN_DISPLAY_DEVICE :

    The environment is missing the DISPLAY variable..

  • ENOMEM:

    Out of memory.


Logs written by this function are tagged with the "window" label.




INDEX


Description

     Enable or disable the key repetition for the sent window. Note that the key repetition is not made for be used in a video game context: it is not a "keydown status" but a pure tool for text editor. Its speed is system configuration dependant. If you need a keydown status, use b‌u‌n‌n‌y‌_‌g‌e‌t‌_‌k‌e‌y‌b‌o‌a‌r‌d.

Parameters



INDEX


Description

     Display or hide the system mouse cursor when moving over the window.

Parameters



INDEX


Description

     Set the mouse cursor at the sent position, relatively to the sent window.

Parameters



INDEX


Description

     Set the mouse cursor at the sent position.

Parameters

  • int x:
         The horizontal position to warp the mouse on.
  • int y:
         The vertical position to warp the mouse on.


INDEX


Description

     Send a request to the window manager to get the focus back on the sent window.

Parameters



INDEX


Description

     Move the sent window at the sent coordinates.

Parameters



INDEX


Description

     Resize the sent window to match the sent size.

Parameters



INDEX


Description

     Enable or disable vertical synchronization with screen refresh. Disabled by default.

Parameters



INDEX