### Build Allegro 5 Example on Windows with Visual Studio CLI Source: https://github.com/danoon2/boxedwine/blob/master/lib/imgui/examples/example_allegro5/README.md Build the Allegro 5 example using the Visual Studio command-line compiler. Ensure Allegro 5 is installed via vcpkg and ALLEGRODIR is set correctly. IMGUI_USER_CONFIG is used for 32-bit index support. ```batch set ALLEGRODIR=path_to_your_allegro5_folder cl /Zi /MD /I %ALLEGRODIR%\include /DIMGUI_USER_CONFIG="examples/example_allegro5/imconfig_allegro5.h" /I .. /I ..\.. main.cpp ..\imgui_impl_allegro5.cpp ..\..\imgui*.cpp /link /LIBPATH:%ALLEGRODIR%\lib allegro-5.0.10-monolith-md.lib user32.lib ``` -------------------------------- ### Define Installation Rules Source: https://github.com/danoon2/boxedwine/blob/master/lib/zlib/CMakeLists.txt Specifies installation paths for libraries, headers, and documentation. ```cmake if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL ) install(TARGETS zlib zlibstatic RUNTIME DESTINATION "${INSTALL_BIN_DIR}" ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" LIBRARY DESTINATION "${INSTALL_LIB_DIR}" ) endif() if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL ) install(FILES ${ZLIB_PUBLIC_HDRS} DESTINATION "${INSTALL_INC_DIR}") endif() if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL ) install(FILES zlib.3 DESTINATION "${INSTALL_MAN_DIR}/man3") endif() if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL ) install(FILES ${ZLIB_PC} DESTINATION "${INSTALL_PKGCONFIG_DIR}") endif() ``` -------------------------------- ### Define Example Binaries Source: https://github.com/danoon2/boxedwine/blob/master/lib/zlib/CMakeLists.txt Compiles and tests example programs, including 64-bit variants if supported. ```cmake add_executable(example test/example.c) target_link_libraries(example zlib) add_test(example example) add_executable(minigzip test/minigzip.c) target_link_libraries(minigzip zlib) if(HAVE_OFF64_T) add_executable(example64 test/example.c) target_link_libraries(example64 zlib) set_target_properties(example64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64") add_test(example64 example64) add_executable(minigzip64 test/minigzip.c) target_link_libraries(minigzip64 zlib) set_target_properties(minigzip64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64") endif() ``` -------------------------------- ### Install Include Files Source: https://github.com/danoon2/boxedwine/blob/master/lib/sdl2/CMakeLists.txt Collects and installs header files from both source and binary directories. ```cmake file(GLOB INCLUDE_FILES ${SDL2_SOURCE_DIR}/include/*.h) file(GLOB BIN_INCLUDE_FILES ${SDL2_BINARY_DIR}/include/*.h) foreach(_FNAME ${BIN_INCLUDE_FILES}) get_filename_component(_INCNAME ${_FNAME} NAME) list(REMOVE_ITEM INCLUDE_FILES ${SDL2_SOURCE_DIR}/include/${_INCNAME}) endforeach() list(APPEND INCLUDE_FILES ${BIN_INCLUDE_FILES}) install(FILES ${INCLUDE_FILES} DESTINATION include/SDL2) ``` -------------------------------- ### Complete SDL initialization and shutdown example Source: https://github.com/danoon2/boxedwine/blob/master/lib/sdl1/docs/html/guidebasicsinit.html A full example showing the initialization of Video and Audio subsystems, error handling with SDL_GetError, and proper cleanup with SDL_Quit. ```C #include "SDL.h" /* All SDL App's need this */ #include int main(int argc, char *argv[]) { printf("Initializing SDL.\n"); /* Initialize defaults, Video and Audio */ if((SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO)==-1)) { printf("Could not initialize SDL: %s.\n", SDL_GetError()); exit(-1); } printf("SDL initialized.\n"); printf("Quiting SDL.\n"); /* Shutdown all subsystems */ SDL_Quit(); printf("Quiting....\n"); exit(0); } ``` -------------------------------- ### Convert Audio Data Example Source: https://github.com/danoon2/boxedwine/blob/master/lib/sdl1/docs/html/sdlconvertaudio.html This example demonstrates loading a WAV file, building an audio converter, and then converting the audio data to the desired hardware format. Ensure the SDL library is initialized and audio device is opened before using this. ```c /* Converting some WAV data to hardware format */ void my_audio_callback(void *userdata, Uint8 *stream, int len); SDL_AudioSpec *desired, *obtained; SDL_AudioSpec wav_spec; SDL_AudioCVT wav_cvt; Uint32 wav_len; Uint8 *wav_buf; int ret; /* Allocated audio specs */ desired = malloc(sizeof(SDL_AudioSpec)); obtained = malloc(sizeof(SDL_AudioSpec)); /* Set desired format */ desired->freq=22050; desired->format=AUDIO_S16LSB; desired->samples=8192; desired->callback=my_audio_callback; desired->userdata=NULL; /* Open the audio device */ if ( SDL_OpenAudio(desired, obtained) < 0 ){ fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError()); exit(-1); } free(desired); /* Load the test.wav */ if( SDL_LoadWAV("test.wav", &wav_spec, &wav_buf, &wav_len) == NULL ){ fprintf(stderr, "Could not open test.wav: %s\n", SDL_GetError()); SDL_CloseAudio(); free(obtained); exit(-1); } /* Build AudioCVT */ ret = SDL_BuildAudioCVT(&wav_cvt, wav_spec.format, wav_spec.channels, wav_spec.freq, obtained->format, obtained->channels, obtained->freq); /* Check that the convert was built */ if(ret==-1){ fprintf(stderr, "Couldn't build converter!\n"); SDL_CloseAudio(); free(obtained); SDL_FreeWAV(wav_buf); } /* Setup for conversion */ wav_cvt.buf = malloc(wav_len * wav_cvt.len_mult); wav_cvt.len = wav_len; memcpy(wav_cvt.buf, wav_buf, wav_len); /* We can delete to original WAV data now */ SDL_FreeWAV(wav_buf); /* And now we're ready to convert */ SDL_ConvertAudio(&wav_cvt); /* do whatever */ . . . . ``` -------------------------------- ### Install Targets Source: https://github.com/danoon2/boxedwine/blob/master/lib/sdl2/CMakeLists.txt Defines installation rules for the built libraries, specifying destinations for library, archive, and runtime files. ```cmake install(TARGETS ${_INSTALL_LIBS} EXPORT SDL2Targets LIBRARY DESTINATION "lib${LIB_SUFFIX}" ARCHIVE DESTINATION "lib${LIB_SUFFIX}" RUNTIME DESTINATION bin) ``` -------------------------------- ### Save/Restore All Device State in DirectX9 Example Source: https://github.com/danoon2/boxedwine/blob/master/lib/imgui/docs/CHANGELOG.txt Implements saving and restoring of all device states in the DirectX9 example for better resource management. ```cpp Examples: DirectX9: save/restore all device state. ``` -------------------------------- ### Create and navigate to Mesa directory Source: https://github.com/danoon2/boxedwine/blob/master/docs/How-To-Build-OSMesa-on-Mac.md Initial setup commands to prepare the workspace directory. ```bash mkdir ~/mesa ``` ```bash cd ~/messa ``` -------------------------------- ### Build Allegro 5 Example on Ubuntu/macOS Source: https://github.com/danoon2/boxedwine/blob/master/lib/imgui/examples/example_allegro5/README.md Compile the Allegro 5 example using g++. Ensure IMGUI_USER_CONFIG is set to use the provided imconfig_allegro5.h for 32-bit indices. ```bash g++ -DIMGUI_USER_CONFIG="examples/example_allegro5/imconfig_allegro5.h" -I .. -I ../.. main.cpp ../imgui_impl_allegro5.cpp ../../imgui*.cpp -lallegro -lallegro_main -lallegro_primitives -o allegro5_example ``` -------------------------------- ### Install Packages on FreeBSD Source: https://github.com/danoon2/boxedwine/blob/master/lib/sdl2/src/hidapi/README.txt Installs GNU make, libiconv, and optionally Fox-Toolkit on FreeBSD systems. Required for building HIDAPI and its test GUI. ```bash pkg_add -r gmake libiconv fox16 ``` -------------------------------- ### Configure Platform-Specific Library Installation Source: https://github.com/danoon2/boxedwine/blob/master/lib/sdl2/CMakeLists.txt Handles library symlinks and pkg-config file installation for non-Windows platforms. ```cmake string(TOUPPER "${CMAKE_BUILD_TYPE}" UPPER_BUILD_TYPE) if (UPPER_BUILD_TYPE MATCHES DEBUG) set(SOPOSTFIX "${SDL_CMAKE_DEBUG_POSTFIX}") else() set(SOPOSTFIX "") endif() if(NOT (WINDOWS OR CYGWIN)) if(SDL_SHARED) set(SOEXT ${CMAKE_SHARED_LIBRARY_SUFFIX}) # ".so", ".dylib", etc. get_target_property(SONAME SDL2 OUTPUT_NAME) if(NOT ANDROID) install(CODE " execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink \"lib${SONAME}${SOPOSTFIX}${SOEXT}\" \"libSDL2${SOPOSTFIX}${SOEXT}\" WORKING_DIRECTORY \"${SDL2_BINARY_DIR}\")") install(FILES ${SDL2_BINARY_DIR}/libSDL2${SOPOSTFIX}${SOEXT} DESTINATION "lib${LIB_SUFFIX}") endif() endif() if(FREEBSD) # FreeBSD uses ${PREFIX}/libdata/pkgconfig install(FILES ${SDL2_BINARY_DIR}/sdl2.pc DESTINATION "libdata/pkgconfig") else() install(FILES ${SDL2_BINARY_DIR}/sdl2.pc DESTINATION "lib${LIB_SUFFIX}/pkgconfig") endif() install(PROGRAMS ${SDL2_BINARY_DIR}/sdl2-config DESTINATION bin) # TODO: what about the .spec file? Is it only needed for RPM creation? install(FILES "${SDL2_SOURCE_DIR}/sdl2.m4" DESTINATION "${CMAKE_INSTALL_FULL_DATAROOTDIR}/aclocal") endif() ``` -------------------------------- ### Initialize SDL Subsystems Minimally Source: https://github.com/danoon2/boxedwine/blob/master/lib/imgui/docs/CHANGELOG.txt Initializes only the video and timer subsystems in the SDL example for reduced overhead. ```cpp Examples: SDL: Initialize video+timer subsystem only. ``` -------------------------------- ### Build and Install Fox-Toolkit from Source on macOS Source: https://github.com/danoon2/boxedwine/blob/master/lib/sdl2/src/hidapi/README.txt Builds and installs Fox-Toolkit from source on macOS. This method is necessary if you intend to redistribute the TestGUI app bundle, as the ports version is incompatible with Apple X11 libraries. ```bash ./configure && make && make install ``` -------------------------------- ### Install Build Dependencies for Wine Source: https://github.com/danoon2/boxedwine/blob/master/docs/How-To-Build-Wine-FileSystem.md Installs essential packages for building Wine. Ensure you have sufficient disk space and a stable internet connection. ```bash sudo apt-get install build-essential sudo apt-get install git sudo apt-get build-dep wine ``` -------------------------------- ### Install Autotools on FreeBSD Source: https://github.com/danoon2/boxedwine/blob/master/lib/sdl2/src/hidapi/README.txt Installs Autotools on FreeBSD, required if you downloaded the HIDAPI source directly from the git repository. ```bash pkg_add -r autotools ``` -------------------------------- ### Install Fox-Toolkit on macOS using Ports Source: https://github.com/danoon2/boxedwine/blob/master/lib/sdl2/src/hidapi/README.txt Installs Fox-Toolkit on macOS using the ports system. This method is suitable for building the Test GUI for personal use. ```bash sudo port install fox ``` -------------------------------- ### Install AsmJit Library and Headers Source: https://github.com/danoon2/boxedwine/blob/master/lib/asmjit/CMakeLists.txt Installs the AsmJit library files (runtime, archive, library) and header files to their designated locations. This is conditional on ASMJIT_NO_INSTALL being OFF. ```cmake install(TARGETS asmjit EXPORT asmjit-config RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") ``` ```cmake install(EXPORT asmjit-config NAMESPACE asmjit:: DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/asmjit") ``` ```cmake foreach(_src_file ${ASMJIT_SRC}) if ("${_src_file}" MATCHES "\.h$" AND NOT "${_src_file}" MATCHES "_p\.h$") get_filename_component(_src_dir ${_src_file} PATH) install(FILES "${CMAKE_CURRENT_LIST_DIR}/${_src_file}" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${_src_dir}") endif() endforeach() ``` -------------------------------- ### Execute Wine Build Script Source: https://github.com/danoon2/boxedwine/blob/master/docs/How-To-Build-Wine-FileSystem.md Runs the script to build and install Wine. This script requires sudo privileges and will install Wine into the /opt directory. ```bash bash buildAll.sh ``` -------------------------------- ### Add Timer Example Source: https://github.com/danoon2/boxedwine/blob/master/lib/sdl1/docs/html/sdladdtimer.html Example of how to add a timer to trigger a callback function. Ensure SDL_INIT_TIMER is called before using this function. The interval calculation (33/10)*10 is used to approximate 30 FPS. ```c my_timer_id = SDL_AddTimer((33/10)*10, my_callbackfunc, my_callback_param); ``` -------------------------------- ### iOS Game Center Integration Example Source: https://github.com/danoon2/boxedwine/blob/master/lib/sdl2/docs/README-ios.md This example demonstrates how to integrate Game Center on iOS by using SDL_iPhoneSetAnimationCallback. It shows initializing Game Center and setting up the animation callback to handle frame logic and rendering, yielding control to the Cocoa event loop. ```c extern "C" void ShowFrame(void*) { ... do event handling, frame logic and rendering ... } int main(int argc, char *argv[]) { ... initialize game ... #if __IPHONEOS__ // Initialize the Game Center for scoring and matchmaking InitGameCenter(); // Set up the game to run in the window animation callback on iOS // so that Game Center and so forth works correctly. SDL_iPhoneSetAnimationCallback(window, 1, ShowFrame, NULL); #else while ( running ) { ShowFrame(0); DelayFrame(); } #endif return 0; } ``` -------------------------------- ### Configure and Compile SDL Source: https://github.com/danoon2/boxedwine/blob/master/lib/sdl2/docs/README-raspberrypi.md Sets up the compiler and linker flags for cross-compilation and then configures, builds, and installs SDL within the sysroot. ```bash export CC="/opt/rpi-tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc --sysroot=$SYSROOT -I$SYSROOT/opt/vc/include -I$SYSROOT/usr/include -I$SYSROOT/opt/vc/include/interface/vcos/pthreads -I$SYSROOT/opt/vc/include/interface/vmcs_host/linux" cd mkdir -p build;cd build LDFLAGS="-L$SYSROOT/opt/vc/lib" ../configure --with-sysroot=$SYSROOT --host=arm-raspberry-linux-gnueabihf --prefix=$PWD/rpi-sdl2-installed --disable-pulseaudio --disable-esd make make install ``` -------------------------------- ### GLFW Subdirectory Configuration Source: https://github.com/danoon2/boxedwine/blob/master/lib/imgui/examples/example_glfw_vulkan/CMakeLists.txt Includes the GLFW library as a subdirectory, setting its directory and configuring build options to exclude examples, tests, docs, and installation targets. ```cmake # GLFW set(GLFW_DIR ../../../glfw) # Set this to point to an up-to-date GLFW repo option(GLFW_BUILD_EXAMPLES "Build the GLFW example programs" OFF) option(GLFW_BUILD_TESTS "Build the GLFW test programs" OFF) option(GLFW_BUILD_DOCS "Build the GLFW documentation" OFF) option(GLFW_INSTALL "Generate installation target" OFF) option(GLFW_DOCUMENT_INTERNALS "Include internals in documentation" OFF) add_subdirectory(${GLFW_DIR} binary_dir EXCLUDE_FROM_ALL) include_directories(${GLFW_DIR}/include) ``` -------------------------------- ### Initialize Video and Joystick Subsystems Source: https://github.com/danoon2/boxedwine/blob/master/lib/sdl1/docs/html/sdlinitsubsystem.html This example demonstrates initializing the video subsystem, setting up a display mode, and then initializing the joystick subsystem separately. It shows how to manage individual subsystems after the main SDL initialization. ```c SDL_Init(SDL_INIT_VIDEO); . . SDL_SetVideoMode(640, 480, 16, SDL_DOUBLEBUF|SDL_FULLSCREEN); . /* Do Some Video stuff */ . . /* Initialize the joystick subsystem */ SDL_InitSubSystem(SDL_INIT_JOYSTICK); /* Do some stuff with video and joystick */ . . . /* Shut them both down */ SDL_Quit(); ``` -------------------------------- ### Prepare build environment Source: https://github.com/danoon2/boxedwine/blob/master/docs/How-To-Build-OSMesa-on-Mac.md Create the build directory and navigate to the source directory. ```bash mkdir ~/mesa/build ``` ```bash cd ~/mesa/mesa-21.1.3 ``` -------------------------------- ### Get Current Audio Status Source: https://github.com/danoon2/boxedwine/blob/master/lib/sdl1/docs/html/sdlgetaudiostatus.html Call SDL_GetAudioStatus to determine if audio is currently stopped, paused, or playing. No setup is required beyond initializing the SDL library. ```c #include "SDL.h" SDL_audiostatus SDL_GetAudioStatus(void); ``` ```c typedef enum{ SDL_AUDIO_STOPPED, SDL_AUDIO_PAUSED, SDL_AUDIO_PLAYING } SDL_audiostatus; ``` -------------------------------- ### Install dependencies via Homebrew Source: https://github.com/danoon2/boxedwine/blob/master/docs/How-To-Build-OSMesa-on-Mac.md Install required build tools and remove conflicting cmake installations. ```bash brew install pkg-config brew install bison brew install llvm brew install meson brew uninstall cmake ``` -------------------------------- ### Chroot and Install Dependencies Source: https://github.com/danoon2/boxedwine/blob/master/lib/sdl2/docs/README-raspberrypi.md Enters the chroot environment to install build dependencies within the Raspbian system root. Remember to exit the chroot after installation. ```bash sudo chroot $SYSROOT apt-get install libudev-dev libasound2-dev libdbus-1-dev libraspberrypi0 libraspberrypi-bin libraspberrypi-dev libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxi-dev libxinerama-dev libxxf86vm-dev libxss-dev exit ``` -------------------------------- ### Prepare Chroot Environment Source: https://github.com/danoon2/boxedwine/blob/master/lib/sdl2/docs/README-raspberrypi.md Installs QEMU for emulation and copies the ARM static binary. Mounts necessary virtual filesystems for the chroot environment. ```bash sudo apt-get install qemu binfmt-support qemu-user-static sudo cp /usr/bin/qemu-arm-static $SYSROOT/usr/bin sudo mount --bind /dev $SYSROOT/dev sudo mount --bind /proc $SYSROOT/proc sudo mount --bind /sys $SYSROOT/sys ``` -------------------------------- ### Build and Install Mesa for DirectFB Source: https://github.com/danoon2/boxedwine/blob/master/lib/sdl2/docs/README-directfb.md Compile Mesa for the linux-directfb platform and install it to a specified directory. This process involves multiple make commands and a sudo installation step. ```shell make linux-directfb make echo Installing - please enter sudo pw. sudo make install INSTALL_DIR=/usr/local/dfb_GL cd src/mesa/drivers/directfb make sudo make install INSTALL_DIR=/usr/local/dfb_GL ``` -------------------------------- ### Initialize SDL subsystems Source: https://github.com/danoon2/boxedwine/blob/master/lib/sdl1/docs/html/guidebasicsinit.html Demonstrates how to initialize specific SDL subsystems using bitwise OR flags. ```C SDL_Init ( SDL_INIT_VIDEO ); ``` ```C SDL_Init ( SDL_INIT_VIDEO | SDL_INIT_TIMER ); ``` -------------------------------- ### Initialization and Usage Source: https://github.com/danoon2/boxedwine/blob/master/lib/sdl1/docs/html/cdrom.html Explains the necessary steps to initialize the SDL CD-ROM library and general usage patterns. ```APIDOC ## Initialization and Usage ### Initialization Before using any SDL CD-ROM functions, you must initialize the library by calling `SDL_Init(SDL_INIT_CDROM)`. ```c if (SDL_Init(SDL_INIT_CDROM) < 0) { fprintf(stderr, "Could not initialize SDL CD-ROM: %s\n", SDL_GetError()); return 1; } ``` Check the return code; it should be 0 for successful initialization. ### General Usage Flow 1. **Initialize**: Call `SDL_Init(SDL_INIT_CDROM)`. 2. **Count Drives**: Use `SDL_CDNumDrives()` to find out how many CD-ROM drives are available. 3. **Open Drive**: Use `SDL_CDOpen(drive_index)` to open a specific drive. 4. **Check Status**: Use `SDL_CDStatus(cdrom)` to check if a CD is present and its status. 5. **Control Playback**: Use functions like `SDL_CDPlay()`, `SDL_CDPlayTracks()`, `SDL_CDPause()`, `SDL_CDResume()`, `SDL_CDStop()` as needed. 6. **Eject**: Use `SDL_CDEject(cdrom)` to eject the CD. 7. **Close Drive**: Use `SDL_CDClose(cdrom)` to close the drive handle when done. ### CD-ROM Structure CD-ROMs are organized into tracks, and each track consists of frames. SDL works with frames, but you can convert to minutes/seconds using the `FRAMES_TO_MSF()` macro. ``` -------------------------------- ### Install Autotools on Debian/Ubuntu Source: https://github.com/danoon2/boxedwine/blob/master/lib/sdl2/src/hidapi/README.txt Installs Autotools, which are required if you downloaded the HIDAPI source directly from the git repository. ```bash sudo apt-get install autotools-dev autoconf automake libtool ``` -------------------------------- ### Initialize Best Available Video Mode Source: https://github.com/danoon2/boxedwine/blob/master/lib/sdl1/docs/html/guidevideo.html This example demonstrates how to initialize the video display with a preferred pixel depth, but accepting any available depth if the preferred one is not available. It also prints the actual bits-per-pixel of the chosen mode. ```c /* Have a preference for 8-bit, but accept any depth */ screen = SDL_SetVideoMode(640, 480, 8, SDL_SWSURFACE|SDL_ANYFORMAT); if ( screen == NULL ) { fprintf(stderr, "Couldn't set 640x480x8 video mode: %s\n", SDL_GetError()); exit(1); } printf("Set 640x480 at %d bits-per-pixel mode\n", screen->format->BitsPerPixel); ``` -------------------------------- ### Install evtest Utility Source: https://github.com/danoon2/boxedwine/blob/master/lib/sdl2/docs/README-linux.md Installs the evtest utility for debugging input device events on Debian-based systems. ```bash sudo apt-get install evtest ``` -------------------------------- ### Opening the Audio Device with SDL_OpenAudio Source: https://github.com/danoon2/boxedwine/blob/master/lib/sdl1/docs/html/sdlopenaudio.html This example demonstrates how to allocate and fill an SDL_AudioSpec structure with desired audio parameters, then call SDL_OpenAudio to open the audio device. It includes error handling and freeing allocated memory. ```c #include "SDL.h" /* Prototype of our callback function */ void my_audio_callback(void *userdata, Uint8 *stream, int len); /* Open the audio device */ SDL_AudioSpec *desired, *obtained; SDL_AudioSpec *hardware_spec; /* Allocate a desired SDL_AudioSpec */ desired = malloc(sizeof(SDL_AudioSpec)); /* Allocate space for the obtained SDL_AudioSpec */ obtained = malloc(sizeof(SDL_AudioSpec)); /* 22050Hz - FM Radio quality */ desired->freq=22050; /* 16-bit signed audio */ desired->format=AUDIO_S16LSB; /* Mono */ desired->channels=0; /* Large audio buffer reduces risk of dropouts but increases response time */ desired->samples=8192; /* Our callback function */ desired->callback=my_audio_callback; desired->userdata=NULL; /* Open the audio device */ if ( SDL_OpenAudio(desired, obtained) < 0 ){ fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError()); exit(-1); } /* desired spec is no longer needed */ free(desired); hardware_spec=obtained; ``` -------------------------------- ### Install Raspbian Build Dependencies Source: https://github.com/danoon2/boxedwine/blob/master/lib/sdl2/docs/README-raspberrypi.md Installs essential development libraries for Raspbian. Ensure you have the correct package names for your Raspbian version. ```bash sudo apt-get install libudev-dev libasound2-dev libdbus-1-dev ``` ```bash sudo apt-get install libraspberrypi0 libraspberrypi-bin libraspberrypi-dev ``` -------------------------------- ### Clone and Build on Unix-like Systems Source: https://github.com/danoon2/boxedwine/blob/master/lib/tiny-process/README.md Instructions for cloning the repository, building the project using CMake, and running the examples on Unix-like systems. ```shell git clone http://gitlab.com/eidheim/tiny-process-library cd tiny-process-library mkdir build cd build cmake .. make ./examples ``` -------------------------------- ### Install SDL Build Dependencies on Ubuntu 13.04 Source: https://github.com/danoon2/boxedwine/blob/master/lib/sdl2/docs/README-linux.md Installs the necessary development libraries to enable all SDL features on Ubuntu 13.04. ```bash sudo apt-get install build-essential mercurial make cmake autoconf automake \ libtool libasound2-dev libpulse-dev libaudio-dev libx11-dev libxext-dev \ libxrandr-dev libxcursor-dev libxi-dev libxinerama-dev libxxf86vm-dev \ libxss-dev libgl1-mesa-dev libesd0-dev libdbus-1-dev libudev-dev \ libgles1-mesa-dev libgles2-mesa-dev libegl1-mesa-dev libibus-1.0-dev \ fcitx-libs-dev libsamplerate0-dev libsndio-dev ``` -------------------------------- ### Save/Restore glActiveTexture State in OpenGL3 Example Source: https://github.com/danoon2/boxedwine/blob/master/lib/imgui/docs/CHANGELOG.txt Ensures that the glActiveTexture state is correctly saved and restored in the OpenGL3 example to prevent conflicts. ```cpp Examples: OpenGL3: Saving/restoring glActiveTexture() state. (#602) ``` -------------------------------- ### Building SDL from Command Line Source: https://github.com/danoon2/boxedwine/blob/master/lib/sdl2/docs/README-macosx.md Compile the SDL framework from the command line using `pbxbuild` in the directory containing your `.pbproj` file. ```bash pbxbuild ``` -------------------------------- ### Open the audio device with SDL Source: https://github.com/danoon2/boxedwine/blob/master/lib/sdl1/docs/html/guideaudioexamples.html Configures an SDL_AudioSpec structure and initializes the audio device using SDL_OpenAudio. ```C SDL_AudioSpec wanted; extern void fill_audio(void *udata, Uint8 *stream, int len); /* Set the audio format */ wanted.freq = 22050; wanted.format = AUDIO_S16; wanted.channels = 2; /* 1 = mono, 2 = stereo */ wanted.samples = 1024; /* Good low-latency value for callback */ wanted.callback = fill_audio; wanted.userdata = NULL; /* Open the audio device, forcing the desired format */ if ( SDL_OpenAudio(&wanted, NULL) < 0 ) { fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError()); return(-1); } return(0); ``` -------------------------------- ### Play the entire CD using SDL_CDPlayTracks Source: https://github.com/danoon2/boxedwine/blob/master/lib/sdl1/docs/html/sdlcdplaytracks.html This example demonstrates how to play an entire CD. Ensure the CD is in the drive by checking its status before calling the function. ```c #include "SDL.h" /* assuming cdrom is a previously opened device */ /* Play the entire CD */ if(CD_INDRIVE(SDL_CDStatus(cdrom))) SDL_CDPlayTracks(cdrom, 0, 0, 0, 0); ``` -------------------------------- ### Linux Build - Install Dependencies Source: https://context7.com/danoon2/boxedwine/llms.txt Installs necessary development packages on Ubuntu/Debian systems for building Boxedwine. Ensure your system is up-to-date before running. ```bash sudo apt-get install build-essential zlib1g-dev libminizip-dev libsdl2-dev libssl-dev libcurl4-openssl-dev ``` -------------------------------- ### Initialize Project and Dependencies Source: https://github.com/danoon2/boxedwine/blob/master/lib/sdl2/CMakeLists.txt Sets the minimum CMake version, project name, and includes necessary macro and check files. ```cmake cmake_minimum_required(VERSION 2.8.11) project(SDL2 C CXX) # !!! FIXME: this should probably do "MACOSX_RPATH ON" as a target property # !!! FIXME: for the SDL2 shared library (so you get an # !!! FIXME: install_name ("soname") of "@rpath/libSDL-whatever.dylib" # !!! FIXME: instead of "/usr/local/lib/libSDL-whatever.dylib"), but I'm # !!! FIXME: punting for now and leaving the existing behavior. Until this # !!! FIXME: properly resolved, this line silences a warning in CMake 3.0+. # !!! FIXME: remove it and this comment entirely once the problem is # !!! FIXME: properly resolved. #cmake_policy(SET CMP0042 OLD) include(CheckFunctionExists) include(CheckLibraryExists) include(CheckIncludeFiles) include(CheckIncludeFile) include(CheckSymbolExists) include(CheckCSourceCompiles) include(CheckCSourceRuns) include(CheckCCompilerFlag) include(CheckTypeSize) include(CheckStructHasMember) include(CMakeDependentOption) include(FindPkgConfig) include(GNUInstallDirs) set(CMAKE_MODULE_PATH "${SDL2_SOURCE_DIR}/cmake") include(${SDL2_SOURCE_DIR}/cmake/macros.cmake) include(${SDL2_SOURCE_DIR}/cmake/sdlchecks.cmake) ``` -------------------------------- ### Clone and Build on Windows with MSYS2 Source: https://github.com/danoon2/boxedwine/blob/master/lib/tiny-process/README.md Instructions for cloning the repository, building the project using CMake with MSYS Makefiles, and running the examples on Windows with MSYS2. ```shell git clone http://gitlab.com/eidheim/tiny-process-library cd tiny-process-library mkdir build cd build cmake -G"MSYS Makefiles" .. make ./examples ``` -------------------------------- ### Update SDL Installation Paths Source: https://github.com/danoon2/boxedwine/blob/master/lib/sdl2/docs/README-raspberrypi.md Uses Perl to modify configuration files, updating hardcoded paths to reflect the target installation location on Raspbian. ```bash perl -w -pi -e "s#$PWD/rpi-sdl2-installed#/usr/local#g;" ./rpi-sdl2-installed/lib/libSDL2.la ./rpi-sdl2-installed/lib/pkgconfig/sdl2.pc ./rpi-sdl2-installed/bin/sdl2-config ``` -------------------------------- ### Install Application Bundles Source: https://github.com/danoon2/boxedwine/blob/master/lib/sdl2/docs/README-macosx.md An optional rule for Makefile.am to install the created application bundles into the Applications directory. This hook is typically run after the main build. ```makefile install-exec-hook: APP_NAME_bundle rm -rf $(DESTDIR)$(prefix)/Applications/APP_NAME.app mkdir -p $(DESTDIR)$(prefix)/Applications/ cp -r $< /$(DESTDIR)$(prefix)Applications/ ``` -------------------------------- ### Advanced Dear ImGui Window and Layout Source: https://github.com/danoon2/boxedwine/blob/master/lib/imgui/docs/README.md Shows how to create windows with menu bars, color editors, line plots, and scrolling child regions. ```cpp // Create a window called "My First Tool", with a menu bar. ImGui::Begin("My First Tool", &my_tool_active, ImGuiWindowFlags_MenuBar); if (ImGui::BeginMenuBar()) { if (ImGui::BeginMenu("File")) { if (ImGui::MenuItem("Open..", "Ctrl+O")) { /* Do stuff */ } if (ImGui::MenuItem("Save", "Ctrl+S")) { /* Do stuff */ } if (ImGui::MenuItem("Close", "Ctrl+W")) { my_tool_active = false; } ImGui::EndMenu(); } ImGui::EndMenuBar(); } // Edit a color (stored as ~4 floats) ImGui::ColorEdit4("Color", my_color); // Plot some values const float my_values[] = { 0.2f, 0.1f, 1.0f, 0.5f, 0.9f, 2.2f }; ImGui::PlotLines("Frame Times", my_values, IM_ARRAYSIZE(my_values)); // Display contents in a scrolling region ImGui::TextColored(ImVec4(1,1,0,1), "Important Stuff"); ImGui::BeginChild("Scrolling"); for (int n = 0; n < 50; n++) ImGui::Text("%04d: Some text", n); ImGui::EndChild(); ImGui::End(); ``` -------------------------------- ### Play the first track using SDL_CDPlayTracks Source: https://github.com/danoon2/boxedwine/blob/master/lib/sdl1/docs/html/sdlcdplaytracks.html This example shows how to play only the first track of a CD. It's crucial to verify the CD is present using SDL_CDStatus. ```c #include "SDL.h" /* assuming cdrom is a previously opened device */ /* Play the first track */ if(CD_INDRIVE(SDL_CDStatus(cdrom))) SDL_CDPlayTracks(cdrom, 0, 0, 1, 0); ``` -------------------------------- ### Play a CD track Source: https://github.com/danoon2/boxedwine/blob/master/lib/sdl1/docs/html/sdlcdstatus.html This example demonstrates using SDL_CDStatus and the CD_INDRIVE macro to verify a disk is present before attempting to play a specific track. ```c int playTrack(int track) { int playing = 0; if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) { /* clamp to the actual number of tracks on the CD */ if (track >= cdrom->numtracks) { track = cdrom->numtracks-1; } if ( SDL_CDPlayTracks(cdrom, track, 0, 1, 0) == 0 ) { playing = 1; } } return playing; } ``` -------------------------------- ### Install Development Packages on Debian/Ubuntu Source: https://github.com/danoon2/boxedwine/blob/master/lib/sdl2/src/hidapi/README.txt Installs necessary development packages for libudev, libusb, and Fox-toolkit on Debian/Ubuntu systems. Required for building HIDAPI and its test GUI. ```bash sudo apt-get install libudev-dev libusb-1.0-0-dev libfox-1.6-dev ``` -------------------------------- ### Apply Depth-Stencil State in DirectX10/X11 Examples Source: https://github.com/danoon2/boxedwine/blob/master/lib/imgui/docs/CHANGELOG.txt Applies depth-stencil state in the DirectX10/X11 examples, ensuring correct depth buffer behavior without using the depth buffer itself. ```cpp Examples: DirectX10/X11: Apply depth-stencil state (no use of depth buffer). (#640, #636) ``` -------------------------------- ### Manual Build with Gradle Source: https://github.com/danoon2/boxedwine/blob/master/lib/sdl2/docs/README-android.md For more complex projects, manually set up the project structure and use Gradle to build and install the debug APK on a connected Android device. ```bash ./gradlew installDebug ``` -------------------------------- ### SDL and OpenGL Full Example Source: https://github.com/danoon2/boxedwine/blob/master/lib/sdl1/docs/html/guidevideoopengl.html A complete boilerplate structure for an SDL application using OpenGL, including necessary headers and a cleanup function. ```c /* * SDL OpenGL Tutorial. * (c) Michael Vance, 2000 * briareos@lokigames.com * * Distributed under terms of the LGPL. */ #include #include #include #include #include static GLboolean should_rotate = GL_TRUE; static void quit_tutorial( int code ) { /* * Quit SDL so we can release the fullscreen * mode and restore the previous video settings, * etc. */ SDL_Quit( ); ``` -------------------------------- ### Launch Boxedwine with File System Source: https://github.com/danoon2/boxedwine/blob/master/docs/How-To-Build-Boxedwine.md Launch Boxedwine without command-line arguments to initialize its file system. It will prompt for file system creation if none exists. ```bash boxedwine -root . -zip TinyCore15Wine6.0.zip /bin/wine notepad ``` -------------------------------- ### Load File System from Zip and Write to Root Source: https://context7.com/danoon2/boxedwine/llms.txt Loads the Wine environment from a zip file and directs all changes to a specified root directory. ```bash boxedwine -root c:\myroot -zip wine.zip /bin/wine notepad ``` -------------------------------- ### Build Mesa with Ninja Source: https://github.com/danoon2/boxedwine/blob/master/docs/How-To-Build-OSMesa-on-Mac.md Execute the build process using Ninja. ```bash ninja -C ~/mesa/build ``` -------------------------------- ### SDL_GetAppState Source: https://github.com/danoon2/boxedwine/blob/master/lib/sdl1/docs/html/eventfunctions.html Get the state of the application. ```APIDOC ## SDL_GetAppState ### Description Get the state of the application. ### Method (Not specified, likely a function call) ### Endpoint (Not applicable, this is a library function) ### Parameters (None specified) ### Request Example (Not applicable) ### Response (Not specified) ``` -------------------------------- ### SDL_GetModState Source: https://github.com/danoon2/boxedwine/blob/master/lib/sdl1/docs/html/eventfunctions.html Get the state of modifier keys. ```APIDOC ## SDL_GetModState ### Description Get the state of modifier keys. ### Method (Not specified, likely a function call) ### Endpoint (Not applicable, this is a library function) ### Parameters (None specified) ### Request Example (Not applicable) ### Response (Not specified) ``` -------------------------------- ### Build on Windows with Visual Studio CLI Source: https://github.com/danoon2/boxedwine/blob/master/lib/imgui/examples/example_sdl_opengl2/README.md Use this command for building on Windows with Visual Studio's command-line tools. Ensure SDL2 is installed and SDL2_DIR is set correctly. Supports both 32-bit and 64-bit builds. ```batch set SDL2_DIR=path_to_your_sdl2_folder cl /Zi /MD /I.. /I..\.. /I%SDL2_DIR%\include main.cpp ..\imgui_impl_sdl.cpp ..\imgui_impl_opengl2.cpp ..\..\imgui*.cpp /FeDebug/example_sdl_opengl2.exe /FoDebug/ /link /libpath:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib opengl32.lib /subsystem:console ``` ```batch cl /Zi /MD /I.. /I..\.. /I%SDL2_DIR%\include main.cpp ..\imgui_impl_sdl.cpp ..\imgui_impl_opengl2.cpp ..\..\imgui*.cpp /FeDebug/example_sdl_opengl2.exe /FoDebug/ /link /libpath:%SDL2_DIR%\lib\x64 SDL2.lib SDL2main.lib opengl32.lib /subsystem:console ``` -------------------------------- ### Build Test GUI using Manual Makefiles Source: https://github.com/danoon2/boxedwine/blob/master/lib/sdl2/src/hidapi/README.txt Builds the Test GUI using manual makefiles. This approach is for understanding the build process or embedding the GUI directly into a project. ```bash cd testgui/ make -f Makefile-manual ``` -------------------------------- ### Play a portion of the second track using SDL_CDPlayTracks Source: https://github.com/danoon2/boxedwine/blob/master/lib/sdl1/docs/html/sdlcdplaytracks.html This example plays the first 15 seconds of the second track. It uses CD_FPS to calculate the number of frames for the specified duration. Always check CD status first. ```c #include "SDL.h" /* assuming cdrom is a previously opened device */ /* Play first 15 seconds of the 2nd track */ if(CD_INDRIVE(SDL_CDStatus(cdrom))) SDL_CDPlayTracks(cdrom, 1, 0, 0, CD_FPS*15); ``` -------------------------------- ### SDL_WM_GetCaption Source: https://github.com/danoon2/boxedwine/blob/master/lib/sdl1/docs/html/wm.html Gets the window title and icon name. ```APIDOC ## SDL_WM_GetCaption ### Description Gets the window title and icon name. ### Endpoint SDL_WM_GetCaption ``` -------------------------------- ### SDL_JoystickGetHat Source: https://github.com/danoon2/boxedwine/blob/master/lib/sdl1/docs/html/sdljoystickgethat.html Get the current state of a joystick hat. ```APIDOC ## SDL_JoystickGetHat ### Description Get the current state of a joystick hat. ### Synopsis ```c Uint8 **SDL_JoystickGetHat**(SDL_Joystick *joystick, int hat); ``` ### Parameters #### Path Parameters - **joystick** (SDL_Joystick *) - A pointer to the joystick to query. - **hat** (int) - The index of the hat on the joystick. ### Return Value The current state is returned as a Uint8 which is defined as an OR'd combination of one or more of the following: - SDL_HAT_CENTERED - SDL_HAT_UP - SDL_HAT_RIGHT - SDL_HAT_DOWN - SDL_HAT_LEFT - SDL_HAT_RIGHTUP - SDL_HAT_RIGHTDOWN - SDL_HAT_LEFTUP - SDL_HAT_LEFTDOWN ### See Also - [SDL_JoystickNumHats](sdljoysticknumhats.html) ``` -------------------------------- ### SDL_GetKeyName Source: https://github.com/danoon2/boxedwine/blob/master/lib/sdl1/docs/html/eventfunctions.html Get the name of an SDL virtual keysym. ```APIDOC ## SDL_GetKeyName ### Description Get the name of an SDL virtual keysym. ### Method (Not specified, likely a function call) ### Endpoint (Not applicable, this is a library function) ### Parameters (None specified) ### Request Example (Not applicable) ### Response (Not specified) ``` -------------------------------- ### Initialize SDL Video and Event Handling Source: https://github.com/danoon2/boxedwine/blob/master/lib/sdl1/docs/html/event.html Call this function to initialize SDL video and event handling. It's a prerequisite for receiving user input. ```c SDL_Init(SDL_INIT_VIDEO); ``` -------------------------------- ### Initialize SDL and Set Event Filter Source: https://github.com/danoon2/boxedwine/blob/master/lib/sdl1/docs/html/guideeventexamples.html Initializes the SDL library and sets up a video mode. It then configures event handling by ignoring key events and setting a custom event filter. ```c int main(int argc, char *argv[]) { SDL_Event event; /* Initialize the SDL library (starts the event loop) */ if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) { fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); exit(1); } /* Clean up on exit, exit on window close and interrupt */ atexit(SDL_Quit); /* Ignore key events */ SDL_EventState(SDL_KEYDOWN, SDL_IGNORE); SDL_EventState(SDL_KEYUP, SDL_IGNORE); /* Filter quit and mouse motion events */ SDL_SetEventFilter(FilterEvents); /* The mouse isn't much use unless we have a display for reference */ if ( SDL_SetVideoMode(640, 480, 8, 0) == NULL ) { fprintf(stderr, "Couldn't set 640x480x8 video mode: %s\n", SDL_GetError()); exit(1); } /* Loop waiting for ESC+Mouse_Button */ while ( SDL_WaitEvent(&event) >= 0 ) { switch (event.type) { case SDL_ACTIVEEVENT: { if ( event.active.state & SDL_APPACTIVE ) { if ( event.active.gain ) { printf("App activated\n"); } else { printf("App iconified\n"); } } } break; case SDL_MOUSEBUTTONDOWN: { Uint8 *keys; keys = SDL_GetKeyState(NULL); if ( keys[SDLK_ESCAPE] == SDL_PRESSED ) { printf("Bye bye...\n"); exit(0); } printf("Mouse button pressed\n"); } break; case SDL_QUIT: { printf("Quit requested, quitting.\n"); exit(0); } break; } } /* This should never happen */ printf("SDL_WaitEvent error: %s\n", SDL_GetError()); exit(1); } ``` -------------------------------- ### SDL_GetKeyState Source: https://github.com/danoon2/boxedwine/blob/master/lib/sdl1/docs/html/eventfunctions.html Get a snapshot of the current keyboard state. ```APIDOC ## SDL_GetKeyState ### Description Get a snapshot of the current keyboard state. ### Method (Not specified, likely a function call) ### Endpoint (Not applicable, this is a library function) ### Parameters (None specified) ### Request Example (Not applicable) ### Response (Not specified) ``` -------------------------------- ### Get RGB Values Source: https://github.com/danoon2/boxedwine/blob/master/lib/sdl1/WhatsNew.txt Function to retrieve RGB values. ```C SDL_GetRGB() ```