Go to file
Daniel Gibson ca2fe7be1a Implement SDL_main as header-only lib for Win32
(remaining platforms will follow)

SDL_main.h is *not* included by SDL.h anymore, users are supposed to
include it directly now, usually only in the file they implement main() in.
If they need the header elsewhere or don't want SDL_main to implement
main() (but only call SDL_SetMainReady() or whatever), they
can #define SDL_MAIN_HANDLED first, same as before.
For SDL-internal usage, I added _SDL_MAIN_NOIMPL, which *also* skips the
implementation and `#define main SDL_main`, but still defines
SDL_MAIN_AVAILABLE and SDL_MAIN_NEEDED in SDL_main.h, as before.

To make the implementaion in the header shorter and avoid including windows.h,
I moved most of the Win32 SDL_main code into SDL3.dll via SDL_Win32RunApp(),
so the header-only part is just the different main functions calling
SDL_Win32RunApp(SDL_main, NULL)

Note that I changed changed the return value and type of OutOfMemory()
to return -1 instead of FALSE, so main() (or WinMain() or whatever)
returns -1 instead of 0 in case of an out-of-memory error

Compared to original Win32 SDL_main, I tweaked the part of the
implementation in SDL_main_impl.h a bit to avoid linker warnings
and conflicts with stuff from windows.h:

- replaced windows.h with own define of WINAPI
  and typedef-ing HINSTANCE and LPSTR.
  This prevents conflicts between all the generically-named #defines and
  types in windows.h and user code (like DrawState in some SDL tests)
- only using one of main() or wmain() gets rid of a MSVC linker error
  ("warning LNK4067: ambiguous entry point")
  If this still causes problems, we might try getting rid of wmain(),
  seemed to me like MSVC can use regular main() in UNICODE mode as well
- simplified the UNICODE logic for that - while this is not exactly
  equivalent to the old, it should make sense and Works For Me
2022-12-15 08:01:01 -08:00
.github Cancel current CI actions when a PR is updated 2022-12-04 10:05:54 -08:00
VisualC fix (hopefully) MSVC builds after gesture removal. 2022-12-14 00:50:20 +03:00
VisualC-GDK gesture: Removed the gesture API from SDL3. 2022-12-13 14:54:37 -05:00
VisualC-WinRT gesture: Removed the gesture API from SDL3. 2022-12-13 14:54:37 -05:00
Xcode gesture: Removed the gesture API from SDL3. 2022-12-13 14:54:37 -05:00
Xcode-iOS/Demos render: Remove SDL_GetRenderDriverInfo and change SDL_CreateRenderer. 2022-12-13 23:27:35 -05:00
android-project Removed balls from the joystick API 2022-12-05 13:17:18 -08:00
build-scripts Update for SDL3 coding style (#6717) 2022-11-30 12:51:59 -08:00
cmake cmake: use FindALSA.cmake to find ALSA libraries 2022-12-12 01:37:01 +01:00
docs render: Remove SDL_GetRenderDriverInfo and change SDL_CreateRenderer. 2022-12-13 23:27:35 -05:00
include Implement SDL_main as header-only lib for Win32 2022-12-15 08:01:01 -08:00
mingw/pkg-support/cmake build: don't add SDL3 subfolder to include path for external projects 2022-11-27 14:33:13 -08:00
src Implement SDL_main as header-only lib for Win32 2022-12-15 08:01:01 -08:00
test testime.c: fix wrong {} in switch 2022-12-15 14:26:18 +01:00
wayland-protocols wayland: Add high-resolution event timestamp support 2022-12-04 16:56:26 -08:00
.clang-format Commented out syntax that causes Visual Studio 2019 to complain on every edit 2022-12-02 00:43:01 -08:00
.editorconfig Remove sdl3.m4 and sdl3-config, and document pkg-config as the recommended replacement 2022-11-27 14:11:06 -08:00
.gitignore .gitignore: Replace all SDL2 with SDL3 2022-12-13 09:02:28 -05:00
.wikiheaders-options .wikiheaders-options: Add a warning that SDL3 is WIP. 2022-11-22 13:49:03 -05:00
Android.mk build: add symbol versioning for SDL 2022-12-02 13:05:37 -08:00
BUGS.txt Cleaned up a few more Bugzilla mentions. 2021-02-12 14:46:49 -05:00
CMakeLists.txt cmake: use FindALSA.cmake to find ALSA libraries 2022-12-12 01:37:01 +01:00
CREDITS.txt Use Apple's nomenclature for macOS and iOS 2022-11-25 16:00:06 -08:00
INSTALL.txt Use Apple's nomenclature for macOS and iOS 2022-11-25 16:00:06 -08:00
LICENSE.txt Updated copyright for 2022 2022-01-03 09:40:21 -08:00
Makefile.minimal First pass at changing SDL 2.0 to SDL 3.0 2022-11-21 20:28:58 -08:00
README-SDL.txt More HTTPS changes in the documentation. 2017-02-16 16:52:03 -05:00
README.md First pass at changing SDL 2.0 to SDL 3.0 2022-11-21 20:28:58 -08:00
SDL3Config.cmake.in cmake: Fix detection of ALSA::ALSA for static linking 2022-12-13 09:03:48 -05:00
TODO.txt Fixed up legacy MoinMoin URLs at wiki.libsdl.org 2021-04-01 12:20:33 -04:00
WhatsNew.txt Renamed AUDIODRIVER and VIDEODRIVER hint/env to AUDIO_DRIVER and VIDEO_DRIVER 2022-12-08 09:50:09 -05:00
cmake_uninstall.cmake.in Fixed bug 3867 - Can't find install_manifest.txt when running 'uninstall' target 2017-10-12 08:44:45 -07:00
sdl3.pc.in cmake: use FindALSA.cmake to find ALSA libraries 2022-12-12 01:37:01 +01:00

README.md

Simple DirectMedia Layer (SDL) Version 3.0

https://www.libsdl.org/

Simple DirectMedia Layer is a cross-platform development library designed to provide low level access to audio, keyboard, mouse, joystick, and graphics hardware via OpenGL and Direct3D. It is used by video playback software, emulators, and popular games including Valve's award winning catalog and many Humble Bundle games.

More extensive documentation is available in the docs directory, starting with README.md

Enjoy!

Sam Lantinga (slouken@libsdl.org)