Agar

<-- Back to AG_Intro.3

SYNOPSIS

#include <agar/core.h>
#include <agar/gui.h>

DESCRIPTION

If Agar has been compiled with SDL 1.x support (--with-sdl), the "sdlfb" and "sdlgl" driver modules become available, and the GUI system can be attached to an existing SDL display context.

Note: If Agar is to create a new SDL display context, one should use a normal AG_InitGraphics(3) call instead (using "<SDL>" as argument if a SDL-capable driver module is required).

INITIALIZATION


int AG_InitVideoSDL (SDL_Surface *display, Uint flags)

int AG_SetVideoSurfaceSDL (SDL_Surface *display)

int AG_ResizeDisplay (int w, int h)

void AG_SetVideoResizeCallback (void (*fn)(Uint w, Uint h)))


The AG_InitVideoSDL() function initializes the GUI to attach to an existing SDL display surface. If the specified surface has the SDL_OPENGL flag, the GL-capable "sdlgl" driver module (see AG_DriverSDLGL(3)) is selected. Otherwise, the direct frame-buffer "sdlfb" driver (see AG_DriverSDLFB(3)) is used. The AG_InitVideoSDL() function accepts the following flags options:
AG_VIDEO_HWSURFACERequest a hardware frame buffer (pass SDL_HWSURFACE).
AG_VIDEO_ASYNCBLITEnable asynchronous blitting updates (pass SDL_ASYNCBLIT).
AG_VIDEO_ANYFORMATDisable emulation of surface depth (pass SDL_ANYFORMAT).
AG_VIDEO_HWPALETTEExclusive palette access (pass SDL_HWPALETTE).
AG_VIDEO_DOUBLEBUFEnable double-buffering in frame buffer mode.
AG_VIDEO_FULLSCREENStart up application in full-screen mode
AG_VIDEO_RESIZABLEIf a window manager is available, request that the application be resizable.
AG_VIDEO_NOFRAMEIf a window manager is available, disable window decorations.
AG_VIDEO_BGPOPUPMENUWhenever the user right-clicks on an area not covered by an Agar window, display a standard pop-up menu with the list of active windows.
AG_VIDEO_OPENGLRequire OpenGL mode. If OpenGL is not available, initialization will fail.
AG_VIDEO_OPENGL_OR_SDLTry OpenGL mode if available, otherwise fallback to SDL frame-buffer mode.
AG_VIDEO_OVERLAYRun in OpenGL "overlay" mode. In this mode, Agar will never clear the background or swap GL buffers. Before rendering itself, Agar will also save the current OpenGL state and restore it completely once rendering is complete. Internally, this option causes the AG_DRIVER_SW_OVERLAY option to be set (see AG_DriverSw(3)).

The AG_SetVideoSurfaceSDL() function can be used to reattach to a different (e.g., a newly resized) SDL display surface without reinitializing the GUI.

Note: The AG_InitVideoSDL() and AG_SetVideoSurfaceSDL() functions are only available if Agar has been compiled with SDL 1.x support (to find out, include "<agar/config/have_sdl.h>" and test for HAVE_SDL).

The AG_ResizeDisplay() function resizes the video display to the specified dimensions in pixels. AG_SetVideoResizeCallback() registers a callback function which will be invoked whenever the display is resized. Both of these functions are only applicable to single-window drivers.

SEE ALSO

AG_Core(3), AG_DriverSDLFB(3), AG_DriverSDLGL(3), AG_InitGraphics(3), AG_Intro(3)

Lk https://libsdl.org/ Simple DirectMedia Layer

HISTORY

SDL support first appeared in Agar 1.0. The "sdlfb" and "sdlgl" driver modules first appeared in Agar 1.4.0.

Csoft.net ElectronTubeStore.com