Skip to content
Permalink
Browse files

WinRT: merged with latest SDL 2.x/HG code

SDL 2.x recently accepted patches to enable OpenGL ES 2 support via Google's ANGLE library.  The thought is to try to eventually merge SDL/WinRT's OpenGL code with SDL-official's.
  • Loading branch information
DavidLudwig committed Nov 29, 2013
2 parents da0c0a4 + 9fa4da1 commit 46740a5a1c74f1d808e2aca20183b47a1f4d8435
Showing 999 changed files with 140,430 additions and 5,034 deletions.
@@ -95,8 +95,10 @@ elseif(APPLE)
set(MACOSX TRUE)
endif()
# TODO: iOS?
elseif(CMAKE_SYSTEM_NAME MATCHES "Haiku.*|BeOS.*")
set(BEOS TRUE)
elseif(CMAKE_SYSTEM_NAME MATCHES "BeOS.*")
message_error("BeOS support has been removed as of SDL 2.0.2.")
elseif(CMAKE_SYSTEM_NAME MATCHES "Haiku.*")
set(HAIKU TRUE)
endif()

# Don't mistake osx for unix
@@ -264,7 +266,7 @@ endif(ASSERTIONS STREQUAL "auto")
set(HAVE_ASSERTIONS ${ASSERTIONS})

# Compiler option evaluation
if(USE_GCC)
if(USE_GCC OR USE_CLANG)
if(DEPENDENCY_TRACKING)
check_c_source_compiles("
#if !defined(__GNUC__) || __GNUC__ < 3
@@ -308,11 +310,11 @@ if(USE_GCC)

check_c_compiler_flag(-Wall HAVE_GCC_WALL)
if(HAVE_GCC_WALL)
if(CMAKE_SYSTEM_NAME MATCHES "Haiku|BeOS")
if(HAIKU)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-multichar")
endif(CMAKE_SYSTEM_NAME MATCHES "Haiku|BeOS")
endif(HAIKU)
endif(HAVE_GCC_WALL)
endif(USE_GCC)
endif(USE_GCC OR USE_CLANG)

if(ASSEMBLY)
if(USE_GCC OR USE_CLANG)
@@ -648,6 +650,21 @@ if(UNIX AND NOT APPLE)
#error EVIOCGNAME() ioctl not available
#endif
int main(int argc, char** argv) {}" HAVE_INPUT_EVENTS)

check_c_source_compiles("
#include <linux/kd.h>
#include <linux/keyboard.h>
int main(int argc, char **argv)
{
struct kbentry kbe;
kbe.kb_table = KG_CTRL;
ioctl(0, KDGKBENT, &kbe);
}" HAVE_INPUT_KD)

file(GLOB CORE_SOURCES ${SDL2_SOURCE_DIR}/src/core/linux/*.c)
set(SOURCE_FILES ${SOURCE_FILES} ${CORE_SOURCES})

if(HAVE_INPUT_EVENTS)
set(SDL_INPUT_LINUXEV 1)
endif(HAVE_INPUT_EVENTS)
@@ -659,6 +676,10 @@ if(UNIX AND NOT APPLE)
set(HAVE_SDL_HAPTIC TRUE)
endif(SDL_HAPTIC AND HAVE_INPUT_EVENTS)

if(HAVE_INPUT_KD)
set(SDL_INPUT_LINUXKD 1)
endif(HAVE_INPUT_KD)

check_include_file("libudev.h" HAVE_LIBUDEV_H)

# !!! FIXME: this needs pkg-config to find the include path, I think.
@@ -746,8 +767,8 @@ elseif(WINDOWS)
#include <windows.h>
int main(int argc, char **argv) { }" HAVE_WIN32_CC)

file(GLOB WIN_SOURCES ${SDL2_SOURCE_DIR}/src/core/windows/*.c)
set(SOURCE_FILES ${SOURCE_FILES} ${WIN_SOURCES})
file(GLOB CORE_SOURCES ${SDL2_SOURCE_DIR}/src/core/windows/*.c)
set(SOURCE_FILES ${SOURCE_FILES} ${CORE_SOURCES})

# Check for DirectX
if(DIRECTX)
@@ -823,7 +844,7 @@ elseif(WINDOWS)

if(SDL_FILESYSTEM)
set(SDL_FILESYSTEM_WINDOWS 1)
file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesytem/windows/*.c)
file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/windows/*.c)
set(SOURCE_FILES ${SOURCE_FILES} ${FILESYSTEM_SOURCES})
set(HAVE_SDL_FILESYSTEM TRUE)
endif(SDL_FILESYSTEM)
@@ -987,15 +1008,15 @@ elseif(APPLE)
endif(SDL_VIDEO)

CheckPTHREAD()
elseif(BEOS)
elseif(HAIKU)
if(SDL_VIDEO)
set(SDL_VIDEO_DRIVER_BWINDOW 1)
file(GLOB BWINDOW_SOURCES ${SDL2_SOURCE_DIR}/src/video/bwindow/*.c)
set(SOURCE_FILES ${SOURCE_FILES} ${BWINDOW_SOURCES})
set(SDL_VIDEO_DRIVER_HAIKU 1)
file(GLOB HAIKUVIDEO_SOURCES ${SDL2_SOURCE_DIR}/src/video/haiku/*.c)
set(SOURCE_FILES ${SOURCE_FILES} ${HAIKUVIDEO_SOURCES})
set(HAVE_SDL_VIDEO TRUE)

set(SDL_FILESYSTEM_BEOS 1)
file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/beos/*.cc)
set(SDL_FILESYSTEM_HAIKU 1)
file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/haiku/*.cc)
set(SOURCE_FILES ${SOURCE_FILES} ${FILESYSTEM_SOURCES})
set(HAVE_SDL_FILESYSTEM TRUE)

@@ -1008,6 +1029,8 @@ elseif(BEOS)
set(HAVE_VIDEO_OPENGL TRUE)
endif(VIDEO_OPENGL)
endif(SDL_VIDEO)

CheckPTHREAD()
endif()

# Dummies
@@ -4,13 +4,14 @@ Simple DirectMedia Layer for Android

Requirements:

Android SDK (version 10 or later)
Android SDK (version 12 or later)
http://developer.android.com/sdk/index.html

Android NDK r7 or later
http://developer.android.com/sdk/ndk/index.html

Minimum API level supported by SDL: 10 (Android 2.3.3)
Joystick support is available for API level >=12 devices.

================================================================================
How the port works
@@ -396,8 +397,11 @@ When you're done instrumenting with valgrind, you can disable the wrapper:
Why is API level 10 the minimum required?
================================================================================

API level 10 is required because SDL requires some functionality for running not
available on older devices and some for building which is not in older NDK/SDKs.
API level 10 is the minimum required level at runtime (that is, on the device)
because SDL requires some functionality for running not
available on older devices. Since the incorporation of joystick support into SDL,
the minimum SDK required to *build* SDL is version 12. Devices running API levels
10-11 are still supported, only with the joystick functionality disabled.

Support for native OpenGL ES and ES2 applications was introduced in the NDK for
API level 4 and 8. EGL was made a stable API in the NDK for API level 9, which
@@ -429,4 +433,6 @@ Reference: http://www.khronos.org/registry/egl/specs/EGLTechNote0001.html
Known issues
================================================================================

- TODO. I'm sure there's a bunch more stuff I haven't thought of
- The number of buttons reported for each joystick is hardcoded to be 36, which
is the current maximum number of buttons Android can report.

@@ -34,9 +34,9 @@ Most programs will want to define an appropriate error threshold and check to be

Saving:
-------
To save a template, call SDL_SaveDollarTemplate(gestureId, src) where gestureId is the id of the gesture you want to save, and src is an SDL_RWops pointer to the file where the gesture will be stored.
To save a template, call SDL_SaveDollarTemplate(gestureId, dst) where gestureId is the id of the gesture you want to save, and dst is an SDL_RWops pointer to the file where the gesture will be stored.

To save all currently loaded templates, call SDL_SaveAllDollarTemplates(src) where source is an SDL_RWops pointer to the file where the gesture will be stored.
To save all currently loaded templates, call SDL_SaveAllDollarTemplates(dst) where dst is an SDL_RWops pointer to the file where the gesture will be stored.

Both functions return the number of gestures successfully saved.

@@ -0,0 +1,80 @@
================================================================================
Simple DirectMedia Layer for Linux
================================================================================

By default SDL will only link against glibc, the rest of the features will be
enabled dynamically at runtime depending on the available features on the target
system. So, for example if you built SDL with Xinerama support and the target
system does not have the Xinerama libraries installed, it will be disabled
at runtime, and you won't get a missing library error, at least with the
default configuration parameters.


================================================================================
Build Dependencies
================================================================================

Ubuntu 13.04, all available features enabled:

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

NOTES:
- This includes all the audio targets except arts, because Ubuntu pulled the
artsc0-dev package, but in theory SDL still supports it.
- DirectFB isn't included because the configure script (currently) fails to find
it at all. You can do "sudo apt-get install libdirectfb-dev" and fix the
configure script to include DirectFB support. Send patches. :)


================================================================================
Joystick does not work
================================================================================

If you compiled or are using a version of SDL with udev support (and you should!)
there's a few issues that may cause SDL to fail to detect your joystick. To
debug this, start by installing the evtest utility. On Ubuntu/Debian:

sudo apt-get install evtest

Then run:

sudo evtest

You'll hopefully see your joystick listed along with a name like "/dev/input/eventXX"
Now run:

cat /dev/input/event/XX

If you get a permission error, you need to set a udev rule to change the mode of
your device (see below)

Also, try:

sudo udevadm info --query=all --name=input/eventXX

If you see a line stating ID_INPUT_JOYSTICK=1, great, if you don't see it,
you need to set up an udev rule to force this variable.

A combined rule for the Saitek Pro Flight Rudder Pedals to fix both issues looks
like:

SUBSYSTEM=="input", ATTRS{idProduct}=="0763", ATTRS{idVendor}=="06a3", MODE="0666", ENV{ID_INPUT_JOYSTICK}="1"
SUBSYSTEM=="input", ATTRS{idProduct}=="0764", ATTRS{idVendor}=="06a3", MODE="0666", ENV{ID_INPUT_JOYSTICK}="1"

You can set up similar rules for your device by changing the values listed in
idProduct and idVendor. To obtain these values, try:

sudo udevadm info -a --name=input/eventXX | grep idVendor
sudo udevadm info -a --name=input/eventXX | grep idProduct

If multiple values come up for each of these, the one you want is the first one of each.

On other systems which ship with an older udev (such as CentOS), you may need
to set up a rule such as:

SUBSYSTEM=="input", ENV{ID_CLASS}=="joystick", ENV{ID_INPUT_JOYSTICK}="1"

@@ -62,6 +62,12 @@ edit $SYSROOT/etc/ld.so.preload and comment out all lines in it.
sudo umount $SYSROOT/proc
sudo umount $SYSROOT/sys
sudo umount /mnt

There's one more fix required, as the libdl.so symlink uses an absolute path
which doesn't quite work in our setup.

sudo rm -rf $SYSROOT/usr/lib/arm-linux-gnueabihf/libdl.so
sudo ln -s ../../../lib/arm-linux-gnueabihf/libdl.so.2 $SYSROOT/usr/lib/arm-linux-gnueabihf/libdl.so

The final step is compiling SDL itself.

@@ -0,0 +1,42 @@
================================================================================
Simple DirectMedia Layer for Windows
================================================================================

================================================================================
OpenGL ES 2.x support
================================================================================

SDL has support for OpenGL ES 2.x under Windows via two alternative
implementations.
The most straightforward method consists in running your app in a system with
a graphic card paired with a relatively recent (as of November of 2013) driver
which supports the WGL_EXT_create_context_es2_profile extension. Vendors known
to ship said extension on Windows currently include nVidia and Intel.

The other method involves using the ANGLE library (https://code.google.com/p/angleproject/)
If an OpenGL ES 2.x context is requested and no WGL_EXT_create_context_es2_profile
extension is found, SDL will try to load the libEGL.dll library provided by
ANGLE.
To obtain the ANGLE binaries, you can either compile from source from
https://chromium.googlesource.com/angle/angle or copy the relevant binaries from
a recent Chrome/Chromium install for Windows. The files you need are:

* libEGL.dll
* libGLESv2.dll
* d3dcompiler_46.dll (supports Windows Vista or later, better shader compiler)
or...
* d3dcompiler_43.dll (supports Windows XP or later)

If you compile ANGLE from source, you can configure it so it does not need the
d3dcompiler_* DLL at all (for details on this, see their documentation).
However, by default SDL will try to preload the d3dcompiler_46.dll to
comply with ANGLE's requirements. If you wish SDL to preload d3dcompiler_43.dll (to
support Windows XP) or to skip this step at all, you can use the
SDL_VIDEO_WIN_D3DCOMPILER hint (see SDL_hints.h for more details).

Known Bugs:

* SDL_GL_SetSwapInterval is currently a no op when using ANGLE. It appears
that there's a bug in the library which prevents the window contents from
refreshing if this is set to anything other than the default value.

@@ -33,6 +33,10 @@ If you need help with the library, or just want to discuss SDL related
issues, you can join the developers mailing list:
http://www.libsdl.org/mailing-list.php

If you want to report bugs or contribute patches, please submit them to
bugzilla:
http://bugzilla.libsdl.org/

Enjoy!
Sam Lantinga (slouken@libsdl.org)

@@ -415,6 +415,18 @@
RelativePath="..\..\include\SDL_cpuinfo.h"
>
</File>
<File
RelativePath="..\..\include\\SDL_egl.h"
>
</File>
<File
RelativePath="..\..\src\video\sdl_egl_c.h"
>
</File>
<File
RelativePath="..\..\src\video\windows\SDL_windowsopengles.h"
>
</File>
<File
RelativePath="..\..\include\SDL_endian.h"
>
@@ -1272,6 +1284,22 @@
RelativePath="..\..\src\video\windows\SDL_windowsopengl.c"
>
</File>
<File
RelativePath="..\..\src\render\opengles2\SDL_render_gles2.c"
>
</File>
<File
RelativePath="..\..\src\render\opengles2\SDL_shaders_gles2.c"
>
</File>
<File
RelativePath="..\..\src\video\SDL_egl.c"
>
</File>
<File
RelativePath="..\..\src\video\windows\SDL_windowsopengles.c"
>
</File>
<File
RelativePath="..\..\src\video\windows\SDL_windowsopengl.h"
>
@@ -553,6 +553,9 @@
<ClInclude Include="..\..\src\events\SDL_windowevents_c.h" />
<ClInclude Include="..\..\src\video\windows\wmmsg.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="..\..\include\SDL_egl.h" />
<ClInclude Include="..\..\src\video\sdl_egl_c.h" />
<ClInclude Include="..\..\src\video\windows\SDL_windowsopengles.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\src\core\windows\SDL_windows.c" />
@@ -669,6 +672,10 @@
<ClCompile Include="..\..\src\video\windows\SDL_windowsvideo.c" />
<ClCompile Include="..\..\src\video\windows\SDL_windowswindow.c" />
<ClCompile Include="..\..\src\events\SDL_windowevents.c" />
<ClCompile Include="..\..\src\render\opengles2\SDL_render_gles2.c" />
<ClCompile Include="..\..\src\render\opengles2\SDL_shaders_gles2.c" />
<ClCompile Include="..\..\src\video\SDL_egl.c" />
<ClCompile Include="..\..\src\video\windows\SDL_windowsopengles.c" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\..\src\main\windows\version.rc" />

0 comments on commit 46740a5

Please sign in to comment.