Commit graph

43 commits

Author SHA1 Message Date
Sam Lantinga e9b86eebf3 Functions which return function pointers now return SDL_FunctionPointer instead of void*
This fixes the clang warning "Cast between pointer-to-function and pointer-to-object is an extension"

You can define SDL_FUNCTION_POINTER_IS_VOID_POINTER in your project to restore the previous behavior.

Fixes https://github.com/libsdl-org/SDL/issues/2866
2023-01-09 15:46:21 -08:00
Sam Lantinga fde78d12f2 Updated copyright for 2023 2023-01-09 09:41:41 -08:00
Sylvain Becker 023f067903
Update GL_GetSwapInterval for backends (#6963) 2023-01-02 10:15:05 -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
Sam Lantinga 8121bbd083 Convert ticks to 64-bit, added nanosecond precision to the API
Fixes https://github.com/libsdl-org/SDL/issues/5512
Fixes https://github.com/libsdl-org/SDL/issues/6731
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
Joshua Root 9a64aa6f95 Fix build with Xcode < 7
The _Nullable attribute is not available in older versions.
2022-11-26 20:35:57 -08:00
Ryan C. Gordon fa5adcafd5 cocoa: Patched to compile on macOS SDK < 10.10.
Fixes #6586.
2022-11-26 13:57:45 -05:00
Ryan C. Gordon 7c760f7f79 cocoa: Update CVDisplayLink timing when screen changes.
This handles both the window moving to a new display and
changing the current display's refresh rate in System
Preferences

Reference Issue #4918.
2022-11-16 11:35:27 -05:00
Ryan C. Gordon 1fd66cc890 Revert "cocoa: Backed out CVDisplayLink code for macOS vsync."
This reverts commit 04b50f6c6b.

It turns out OpenGL vsync has broken again in macOS 12, so
we're reintroducing our CVDisplayLink code to deal with it,
again.

Reference Issue #4918.
2022-11-16 11:34:25 -05:00
Noel Berry 00452e47fa
Adding SDL_GetWindowSizeInPixels for window size in pixels (#6112) 2022-08-24 11:25:13 -07:00
Ryan C. Gordon 3119d58ff5
cocoa: Change the new sync_dispatch hint to async_dispatch.
This is so the default is safer.
2022-08-10 10:48:23 -04:00
Salman Ahmed b4660e9d8b
macOS: Add hint for blocking thread on OpenGL context update dispatch (#5708) 2022-08-09 20:40:00 -04:00
Shootfast 60d1944e46 SDL_video: Added SDL_GL_FLOATBUFFERS to allow Cocoa GL contexts to use EDR 2022-08-02 15:45:30 -07:00
Pierre Wendling 6c536afdb7 Fix C89 declaration for macOS modules.
Since Clang 14, `-Wdeclaration-after-statement` is enforced on every
standard.
2022-06-27 15:19:40 -07:00
Alex Szpakowski f871c178b9 macOS: remove dead code for supporting 10.6 at runtime. 2022-05-10 14:04:14 -07:00
Alex Szpakowski ec8fa57750 macOS: always use Objective-C ARC (automatic ref counting).
Change Cocoa SDL_VideoData and SDL_WindowData implementations from C structs to Objective-C objects, since bridging between C and ObjC is easier that way.
2022-05-09 21:53:40 -07:00
Sam Lantinga 120c76c84b Updated copyright for 2022 2022-01-03 09:40:21 -08:00
Learath 033c0abb58 Use dispatch_async for -[NSOpenGLContext update]. Fixes #3680 2021-03-31 10:46:31 -04:00
Sam Lantinga 9130f7c377 Updated copyright for 2021 2021-01-02 10:25:38 -08:00
Michael Maltese 361417c0a4 cocoa: allow calling CreateWindowFrom on an NSView
This lets applications embed SDL with other widgets surrounding it.
Already possible on Windows and X11.

Fixes Bugzilla #5060.
2020-03-25 16:40:43 -07:00
Ryan C. Gordon 309d6137ae cocoa: OpenGL setView and update must be used on main thread (thanks, Tim!).
If called from background threads, use Grand Central Dispatch to use the
main thread instead. On the main thread, just call them directly.

Fixes Bugzilla #4932.
2020-04-07 14:01:25 -04:00
Ryan C. Gordon f2ff953ef7 cocoa: Just update the OpenGL context directly if on the main thread. 2020-03-26 13:42:56 -04:00
Emir Marincic 5b3b55a181 [NSOpenGLContext update[ is prohibited outside the main thread 2020-03-20 11:52:18 +03:00
Sam Lantinga a8780c6a28 Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
Alex Szpakowski 8fb8adfc90 macOS: Fix SDL_GL_CreateContext/MakeCurrent on non-main threads causing a Main Thread Checker warning when built with Xcode 11 / the macOS 10.15 SDK.
Fixes bug #4714.
2019-07-13 17:04:02 -03:00
Ryan C. Gordon ed8b78d36b cocoa: ignore compiler warnings about OpenGL being deprecated. 2019-06-14 21:18:53 -04:00
Ryan C. Gordon 04b50f6c6b cocoa: Backed out CVDisplayLink code for macOS vsync.
This was to deal with broken vsync support in macOS 10.14, which we assumed
would remain broken indefinitely, but a later 10.14 released fixed it.

This is a loss of late-swap support, but there are several subtle problems
in our CVDiplayLink code that are also evaporating, to be fair.

Fixes Bugzilla #4575.

(Backed out changeset 8760fed23001)
2019-06-11 16:19:01 -04:00
Alex Szpakowski 9d7b26155a macOS: Fix compilation when using the 10.9 SDK or older. 2019-04-17 20:14:40 -03:00
Alex Szpakowski 00c824a8b0 Fix disabling OpenGL vsync on macOS 10.14.4+ (bug #4575). 2019-04-10 22:30:58 -03:00
Sam Lantinga 5e13087b0f Updated copyright for 2019 2019-01-04 22:01:14 -08:00
Ryan C. Gordon 13869f194c cocoa: Implement OpenGL swap interval support with CVDisplayLink.
Not only does this fix macOS 10.14 ("Mojave")'s broken NSOpenGLCPSwapInterval
support, it also lets us implement "adaptive vsync" on macOS!

CVDisplayLink is supported back to macOS 10.4 ("Tiger"), so we just use it
universally without version checks and dump NSOpenGLCPSwapInterval, Mojave or
not.
2018-12-16 01:03:17 -05:00
Ryan C. Gordon 1fb20f0ab9 cocoa: Put a mutex around GL_SwapBuffers.
Prevents deadlock when swapping two different GL contexts on two different
threads at the same time on macOS 10.14 ("Mojave").

Fixes Bugzilla #4278.
2018-10-18 23:38:27 -04:00
Ryan C. Gordon eac3fd28d8 cocoa: GL_GetDrawableSize only uses -[NSView convertRectToBacking] for highDPI.
On Mojave, this will report large numbers for retina displays in fullscreen
mode, which isn't how it works on previous versions.
2018-10-18 11:59:48 -04:00
Sam Lantinga e3cc5b2c6b Updated copyright for 2018 2018-01-03 10:03:25 -08:00
Sam Lantinga 57ebc72714 Fixed bug 3975 - Add GLES2 support for macOS via ANGLE library
Andrey

Seems latest google angle library successfully built & tested under macOS'es.

https://github.com/google/angle

We need to use GLES2 to implement true cross-platform code.
2017-12-04 20:35:01 -08:00
Sam Lantinga 45b774e3f7 Updated copyright for 2017 2017-01-01 18:33:28 -08:00
Sam Lantinga 524bf3c282 Fixed bug 3513 - SDL_GL_SwapWindow does not return error status
Return an error code from SDL_GL_SwapWindow(), like the other SDL APIs.
2016-12-09 01:47:43 -08:00
Ryan C. Gordon 15bc7aea64 Mac: allows apps to use OpenGL on a slower, integrated GPU.
This is often useful for SDL apps that aren't meant to be games: the
integrated GPU starts up faster, uses less power, and is often more than
fast enough.

Note that even with this change, the app will still default to the more
powerful, discrete GPU if one is available; an app that prefers the integrated
GPU will still need the NSSupportsAutomaticGraphicsSwitching key properly
set in its Info.plist and Mac OS X 10.7 or later.

https://developer.apple.com/library/mac/qa/qa1734/_index.html
2016-01-04 22:00:04 -05: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