.\" Copyright (c) 2010-2026 Julien Nadeau Carriere .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, .\" INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES .\" (INCLUDING BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR .\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, .\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING .\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" .Dd January 5, 2026 .Dt AG_INITVIDEOSDL2 3 .Os Agar 1.8 .Sh NAME .Nm AG_InitVideoSDL2 .Nd agar SDL2 video initialization .Sh SYNOPSIS .Bd -literal #include #include .Ed .Sh DESCRIPTION .\" IMAGE(/widgets/AG_DriverSDLFB.png, "The sdlfb driver") If Agar was compiled with SDL 2.x support (--with-sdl2), the "sdl2fb" (frame-buffer), "sdl2gl" (single-window GL) and "sdl2mw" (multi-window GL) drivers become available. .Sh INITIALIZATION .nr nS 1 .Ft "int" .Fn AG_InitVideoSDL2 "SDL_Surface *display" "Uint flags" .Pp .Ft "int" .Fn AG_SetVideoSurfaceSDL2 "SDL_Surface *display" .Pp .nr nS 0 The .Fn AG_InitVideoSDL function initializes the GUI to attach to an existing SDL2 display surface. It accepts the following .Fa flags options: .Bl -tag -width "AG_VIDEO_OPENGL_OR_SDL " .It AG_VIDEO_FULLSCREEN Start up application in full-screen mode .It AG_VIDEO_RESIZABLE If a window manager is available, request that the application be resizable. This is the default. .It AG_VIDEO_FIXED If a window manager is available, request that the window be non-resizable. .It AG_VIDEO_BORDERLESS If a window manager is available, disable window decorations. .It AG_VIDEO_NOFRAME Alias for .Dv AG_VIDEO_BORDERLESS . .It 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. .It AG_VIDEO_OPENGL Require OpenGL mode. If OpenGL is not available, initialization will fail. .It AG_VIDEO_OPENGL_OR_SDL Try OpenGL mode if available, otherwise fallback to SDL frame-buffer mode. .It 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 .Dv AG_DRIVER_SW_OVERLAY option to be set (see .Xr AG_DriverSw 3 ) . .El .Pp Note: When creating a new SDL display (as opposed to attaching to an existing one), consider calling .Xr AG_InitGraphics 3 with the "" argument instead of using .Fn AG_InitVideoSDL2 . .Pp The .Fn AG_SetVideoSurfaceSDL2 function can be used to reattach to a different (e.g., a newly resized) SDL display surface without reinitializing the GUI. .Pp Note: The .Fn AG_InitVideoSDL2 and .Fn AG_SetVideoSurfaceSDL2 functions are only available if Agar has been compiled with SDL2 support (to find out at compile-time, include "" and test for .Dv HAVE_SDL2 ) . .Pp .Sh SEE ALSO .Xr AG_Core 3 , .Xr AG_DriverSDLFB 3 , .Xr AG_DriverSDLGL 3 , .Xr AG_DriverSDL2FB 3 , .Xr AG_DriverSDL2GL 3 , .Xr AG_DriverSDL2MW 3 , .Xr AG_InitGraphics 3 , .Xr AG_InitVideoSDL 3 , .Xr AG_Intro 3 .Pp .Bl -tag -compact .It Lk https://libsdl.org/ Simple DirectMedia Layer .El .Sh HISTORY SDL1 support first appeared in Agar 1.0. The "sdlfb" and "sdlgl" driver modules first appeared in Agar 1.4.0. SDL2 support with the "sdl2fb", "sdl2gl" and "sdl2mw" driver modules appeared in Agar 1.7.0.