AG_InitVideoSDL
—
agar SDL 1.x interface
#include <agar/core.h>
#include <agar/gui.h>
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).
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_HWSURFACE
- Request a hardware frame buffer (pass
SDL_HWSURFACE
).
- AG_VIDEO_ASYNCBLIT
- Enable asynchronous blitting updates (pass
SDL_ASYNCBLIT
).
- AG_VIDEO_ANYFORMAT
- Disable emulation of surface depth (pass
SDL_ANYFORMAT
).
- AG_VIDEO_HWPALETTE
- Exclusive palette access (pass
SDL_HWPALETTE
).
- AG_VIDEO_DOUBLEBUF
- Enable double-buffering in frame buffer mode.
- AG_VIDEO_FULLSCREEN
- Start up application in full-screen mode
- AG_VIDEO_RESIZABLE
- If a window manager is available, request that the application be
resizable.
- AG_VIDEO_NOFRAME
- If a window manager is available, disable window decorations.
- AG_VIDEO_BGPOPUPMENU
- Whenever 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_OPENGL
- Require OpenGL mode. If OpenGL is not available, initialization will
fail.
- AG_VIDEO_OPENGL_OR_SDL
- Try OpenGL mode if available, otherwise fallback to SDL frame-buffer
mode.
- AG_VIDEO_OVERLAY
- Run 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.
SDL support first appeared in Agar 1.0. The "sdlfb" and
"sdlgl" driver modules first appeared in Agar 1.4.0.