Commit graph

45 commits

Author SHA1 Message Date
Sam Lantinga dc280c17a0 Moved SDL_intrin.h back into the public headers for application use 2023-01-10 15:50:35 -08:00
Sam Lantinga fde78d12f2 Updated copyright for 2023 2023-01-09 09:41:41 -08:00
Anonymous Maarten f91a747549 include: SDL_dynapi.h depends on platform defines 2023-01-08 21:37:54 +01:00
Sam Lantinga cc0296c934 SDL API renaming: SDL_surface.h
Fixes https://github.com/libsdl-org/SDL/issues/6884
2022-12-27 06:36:39 -08:00
Sam Lantinga 63724c113b Removed the vi format comments from the source
Vim users can use the [editorconfig plugin](https://github.com/editorconfig/editorconfig-vim) to automatically set tab spacing for the SDL coding style.

Fixes https://github.com/libsdl-org/SDL/issues/6903
2022-12-26 11:17:23 -08:00
Daniel Gibson 28b93451dc Make WinRT's SDL_main header-only
As the implementation requires C++, the user will have to include
SDL_main.h in a C++ source file (that needs to be compiled with /ZW).
It's ok to keep the standard main() implementation in plain C and use
an otherwise empty C++ source file for the SDL_main implementation part,
if both source files #include <SDL3/SDL_main.h>

Including SDL_main.h in a C source file will print a message at
compilation (when building for WinRT or possibly other not yet implemented
platforms that require C++ for main), to remind the user of also
including it in a .cpp source file. This message/warning can be disabled
with #define SDL_MAIN_NOIMPL before including SDL_main.h in the C file.
When including it in a .cpp file, there will be a compiler error with
helpful message if it's not compiled with /ZW

For this I renamend _SDL_MAIN_NOIMPL to SDL_MAIN_NOIMPL, because now it's
not for internal use only anymore, but also useful for users (that want
their main() function in a different file than the SDL_main implementation)

Add a project for the testdraw2.c test to the WinRT solution to at least
get some minimal testing on WinRT.
I won't add all tests because it's a lot of manual clicking per test,
but this should be better than nothing :)
2022-12-15 08:01:01 -08:00
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
Sam Lantinga 1f4cc733a1 Removed the nanosecond versions of event and thread primitive waits from the public API
It's not clear applications need this level of precision yet, so let's leave these private for now.
2022-12-02 12:37:41 -08:00
Sam Lantinga 5750bcb174
Update for SDL3 coding style (#6717)
I updated .clang-format and ran clang-format 14 over the src and test directories to standardize the code base.

In general I let clang-format have it's way, and added markup to prevent formatting of code that would break or be completely unreadable if formatted.

The script I ran for the src directory is added as build-scripts/clang-format-src.sh

This fixes:
#6592
#6593
#6594
2022-11-30 12:51:59 -08:00
Sam Lantinga c5790359fd
Added precompiled header support for Visual Studio and Xcode (#6710)
Fixes https://github.com/libsdl-org/SDL/issues/6704
2022-11-29 18:34:15 -08:00
Sam Lantinga 0a48abc860 Switch header convention from #include "SDL.h" to #include <SDL3/SDLh>
I ran this script in the include directory:
```sh
sed -i '' -e 's,#include "\(SDL.*\)",#include <SDL3/\1>,' *.h
```

I ran this script in the src directory:
```sh
for i in ../include/SDL3/SDL*.h
do hdr=$(basename $i)
   if [ x"$(echo $hdr | egrep 'SDL_main|SDL_name|SDL_test|SDL_syswm|SDL_opengl|SDL_egl|SDL_vulkan')" != x ]; then
        find . -type f -exec sed -i '' -e 's,#include "\('$hdr'\)",#include <SDL3/\1>,' {} \;
    else
        find . -type f -exec sed -i '' -e '/#include "'$hdr'"/d' {} \;
    fi
done
```

Fixes https://github.com/libsdl-org/SDL/issues/6575
2022-11-26 22:15:18 -08:00
Sam Lantinga a268c841e3 Remove references to STDC_HEADERS (thanks @sezero!) 2022-11-26 12:51:20 -08:00
Sam Lantinga 63f307fe1f Remove SDL_config.h from the public headers
The SDL headers are no longer dependent on the build configuration.

Fixes https://github.com/libsdl-org/SDL/issues/6643 and https://github.com/libsdl-org/SDL/issues/6641
2022-11-26 04:48:36 -08:00
Sam Lantinga 2c4159b99a First pass at changing SDL 2.0 to SDL 3.0 2022-11-21 20:28:58 -08:00
Cameron Cawley f0566702c5 Fix enabling SDL_DYNAMIC_API in OpenWatcom builds 2022-05-19 20:11:10 +03:00
Sam Lantinga 8cd908e0b9 Fixed building with Visual Studio 2013
Added SDL_vacopy.h since it needs to be included after Windows headers
2022-05-06 10:51:55 -07:00
Michael Fitzmayer fbd230bb6c
Add support for the Nokia N-Gage (#5597)
* Add initial support for the Nokia N-Gage

* N-Gage: disable clipping for the time being, issue needs to be resolved later

* Move va_copy definition to SDL_internal.h

* Move stdlib.h include to SDL_config_ngage.h, much cleaner this way

* Remove redundant include, add HAVE_STDLIB_H

* Revert "N-Gage: disable clipping for the time being, issue needs to be resolved later"

This reverts commit 4f5f0fc36c.

* N-Gage: fix clipping issue by providing proper math functions
2022-05-03 08:51:49 -07:00
Eddy Jansson 97774cdf72 Move in va_copy() define block from stdlib. 2022-04-29 10:39:02 -07:00
Sam Lantinga 120c76c84b Updated copyright for 2022 2022-01-03 09:40:21 -08:00
Sam Lantinga c326ff7c6f Re-enabled the O_CLOEXEC definition so config headers can be fixed 2021-12-14 12:42:39 -08:00
Sam Lantinga 086c74556d Fixed build warning on iOS 2021-12-14 12:08:36 -08:00
Ozkan Sezer 5a0ea7fb17 Check for O_CLOEXEC definition in fcntl.h at configuration time,
If not available, define it internally as 0 (in SDL_internal.h).
Define it as available for macOS >= 10.7 in SDL_config_macosx.h.
2021-11-27 19:23:10 +03:00
Sylvain c27e1249e1 Remove SDL_HAVE_RENDER_GEOMETRY define 2021-10-24 22:27:56 -04:00
Sylvain 47db47c1cc Add SDL_HAVE_RENDER_GEOMETRY to compile or not with RenderGeometry support 2021-08-19 00:10:59 +02:00
Sam Lantinga 9130f7c377 Updated copyright for 2021 2021-01-02 10:25:38 -08:00
Sam Lantinga cb36189692 Fixed bug 5235 - All internal sources should include SDL_assert.h
Ryan C. Gordon

We should really stick this in SDL_internal.h or something so it's always available.
2020-12-09 07:16:22 -08:00
Sam Lantinga b6afbe6317 Added SDL_log.h to SDL_internal.h so logging is available everywhere 2020-04-07 09:38:57 -07:00
Sam Lantinga 30ff5fcfc0 SDL_LEAN_AND_MEAN defaults off 2020-01-23 01:03:23 -08:00
Sam Lantinga b5e3d264f2 Added a single SDL_LEAN_AND_MEAN define to turn on minimal SDL builds
Protected more code with #ifdefs to reduce the size of minimal shared library builds
2020-01-23 01:00:52 -08:00
Sylvain Becker 6f89b059f7 Documentation of the footprint #defines 2020-01-22 15:23:44 +01:00
Sylvain Becker 55afc281fa Add #define SDL_HAVE_BLIT_N_RGB565 to compile out RGB565 LUT 2020-01-21 22:06:09 +01:00
Sylvain Becker 7df22cf2c2 A few #defines to reduce SDL2 footprint.
Only applied when library is statically linked
2020-01-21 21:33:40 +01:00
Sam Lantinga a8780c6a28 Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
Sam Lantinga 5e13087b0f Updated copyright for 2019 2019-01-04 22:01:14 -08:00
Ryan C. Gordon b262b0ebc9 Small stack allocations fall back to malloc if they're unexpectedly large. 2018-10-22 20:50:32 -04:00
Sam Lantinga e3cc5b2c6b Updated copyright for 2018 2018-01-03 10:03:25 -08:00
Ryan C. Gordon 351d6d4784 audio: Port WASAPI to WinRT, remove XAudio2 backend.
XAudio2 doesn't have capture support, so WASAPI was to replace it; the holdout
was WinRT, which still needed it as its primary audio target until the WASAPI
code code be made to work.

The support matrix now looks like:

WinXP: directsound by default, winmm as a fallback for buggy drivers.
Vista+: WASAPI (directsound and winmm as fallbacks for debugging).
WinRT: WASAPI
2017-12-06 12:24:32 -05:00
Ryan C. Gordon d526b8a1e9 Some patches to make SDL compile with armcc (ARM's C compiler). 2017-03-02 13:33:04 -05:00
Sam Lantinga 45b774e3f7 Updated copyright for 2017 2017-01-01 18:33:28 -08:00
Ryan C. Gordon 8b960d4e0f Added SDL_VARIABLE_LENGTH_ARRAY so this #ifdef is localized to one place. 2016-12-06 02:20:58 -05:00
Sam Lantinga 3615633571 Renaming of guard header names to quiet -Wreserved-id-macro
Patch contributed by Sylvain
2016-11-20 21:34:54 -08:00
Sam Lantinga 37696150e2 Fixed build on various platforms 2016-11-11 13:47:40 -08:00
Sam Lantinga 74e1dd4c6f Define _GNU_SOURCE when building SDL 2016-11-11 13:14:00 -08:00
Sam Lantinga 42065e785d Updated copyright to 2016 2016-01-02 10:10:34 -08:00
Philipp Wiesemann 0e45984fa0 Fixed crash if initialization of EGL failed but was tried again later.
The internal function SDL_EGL_LoadLibrary() did not delete and remove a mostly
uninitialized data structure if loading the library first failed. A later try to
use EGL then skipped initialization and assumed it was previously successful
because the data structure now already existed. This led to at least one crash
in the internal function SDL_EGL_ChooseConfig() because a NULL pointer was
dereferenced to make a call to eglBindAPI().
2015-06-21 17:33:46 +02:00