AG_DriverSw
—
agar single-window driver class
#include <agar/core.h>
#include <agar/gui.h>
AG_DriverSw
is a subclass of
AG_Driver(3)
for "single-window" drivers. This class of drivers includes dumb
framebuffers and any other interface where Agar needs to implement a window
manager internally.
The AG_DriverSwClass structure describes a
"single-window" graphics driver (i.e., a dumb framebuffer, or any
other interface where Agar will need to provide its own window manager).
AG_DriverSwClass inherits from
AG_DriverClass and is defined as follows:
typedef struct ag_driver_sw_class {
struct ag_driver_class _inherit;
Uint flags;
int (*openVideo)(void *drv, Uint w, Uint h, int depth,
Uint flags);
int (*openVideoContext)(void *drv, void *ctx, Uint flags);
int (*setVideoContext)(void *drv, void *ctx);
void (*closeVideo)(void *drv);
int (*videoResize)(void *drv, Uint w, Uint h);
int (*videoCapture)(void *drv, AG_Surface **);
void (*videoClear)(void *drv, AG_Color c);
} AG_DriverSwClass;
At this time, there are no flag options and
flags should be initialized to 0.
The openVideo
() operation opens a new
graphics display of specified dimensions w,
h in pixels, and depth in bits
per pixel. The flags argument defines the various
flags options passed by AG_InitVideo
() (see
AG_InitVideo(3)
for a description of those options).
The openVideoContext
() operation
"attaches" Agar to an existing display context, passed as
ctx. For example, drivers for the SDL library will
accept a pointer to a
SDL_Surface(3)
as ctx. The flags argument
specifies video options (see
AG_InitVideo(3)
for the list of options).
The closeVideo
() operation should
"close" or detach from a graphics display, releasing any resources
previously allocated by openVideo
() or
openVideoContext
().
The videoResize
() operation resizes the
video display to the specified geometry in pixels. It should return -1 if
the display cannot be resized, or 0 on success.
videoCapture
() captures the content of the
video display to an
AG_Surface(3).
The function should return 0 on success or -1 on failure.
videoClear
() clears the video background
with the specified color c.
setVideoContext
() changes the existing
display context (assumes openVideoContext
() has been
called before). If the surface size has changed, Agar windows are clamped,
moved or resized as appropriate.
For the AG_DriverSw (driver instance) object:
- Uint flags
- Option flags. Possible flags include:
AG_DRIVER_SW_OVERLAY
- Enables "overlay" mode, forcing the OpenGL state to be
completely initialized and released at every rendering cycle.
- Display a generic "window list" popup menu on right-click
over empty background.
AG_DRIVER_SW_FULLSCREEN
- The driver is currently in full-screen mode (read-only).
- Uint rNom
- Nominal display refresh rate in ms.
- int rCur
- Effective display refresh rate in ms.
- Uint winop
- Modal window-manager operation in effect, may be set to
AG_WINOP_NONE
(normal operation),
AG_WINOP_MOVE
(a window is being moved) or
AG_WINOP_[LRH]RESIZE
(a window is being resized
left/right/horizontally).
The AG_DriverSw
class first appeared in Agar 1.4.0.