Skip to content

Commit

Permalink
Merged Ryan's SDL-gui-backend branch.
Browse files Browse the repository at this point in the history
Adds three APIs, and implements them on X11, Cocoa, and Windows:

- SDL_CaptureMouse()
- SDL_GetGlobalMouseState()
- SDL_SetWindowHitTest()
  • Loading branch information
icculus committed Jun 25, 2014
2 parents 8436956 + 704d9bd commit b29740b
Show file tree
Hide file tree
Showing 282 changed files with 30,353 additions and 26,648 deletions.
21 changes: 21 additions & 0 deletions .hgignore
Expand Up @@ -39,6 +39,27 @@ Release
*.ncb
*.suo
*.sdf
VisualC/tests/loopwave/sample.wav
VisualC/tests/testautomation/CompareSurfaces0001_Reference.bmp
VisualC/tests/testautomation/CompareSurfaces0001_TestOutput.bmp
VisualC/tests/testgamecontroller/axis.bmp
VisualC/tests/testgamecontroller/button.bmp
VisualC/tests/testgamecontroller/controllermap.bmp
VisualC/tests/testoverlay2/moose.dat
VisualC/tests/testrendertarget/icon.bmp
VisualC/tests/testrendertarget/sample.bmp
VisualC/tests/testscale/icon.bmp
VisualC/tests/testscale/sample.bmp
VisualC/tests/testsprite2/icon.bmp
VisualC/visualtest/icon.bmp
VisualC/visualtest/testquit.actions
VisualC/visualtest/testquit.config
VisualC/visualtest/testquit.exe
VisualC/visualtest/testquit.parameters
VisualC/visualtest/testsprite2.exe
VisualC/visualtest/testsprite2_sample.actions
VisualC/visualtest/testsprite2_sample.config
VisualC/visualtest/testsprite2_sample.parameters

# for Android
android-project/local.properties
Expand Down
2 changes: 1 addition & 1 deletion Android.mk
Expand Up @@ -61,7 +61,7 @@ LOCAL_MODULE := SDL2_static

LOCAL_MODULE_FILENAME := libSDL2

LOCAL_SRC_FILES += $(LOCAL_PATH)/src/main/android/SDL_android_main.c
LOCAL_SRC_FILES += $(subst $(LOCAL_PATH)/,,$(LOCAL_PATH)/src/main/android/SDL_android_main.c)

LOCAL_LDLIBS :=
LOCAL_EXPORT_LDLIBS := -Wl,--undefined=Java_org_libsdl_app_SDLActivity_nativeInit -ldl -lGLESv1_CM -lGLESv2 -llog -landroid
Expand Down
14 changes: 12 additions & 2 deletions CMakeLists.txt
Expand Up @@ -334,6 +334,7 @@ if(USE_GCC OR USE_CLANG)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-multichar")
endif()
endif()
#check_c_compiler_flag(-Wshadow HAVE_GCC_WSHADOW)
endif()

if(ASSEMBLY)
Expand Down Expand Up @@ -494,7 +495,7 @@ if(LIBC)
strlen _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa
_ultoa strtol strtoul strtoll strtod atoi atof strcmp strncmp
_stricmp _strnicmp sscanf atan atan2 acos asin ceil copysign cos
cosf fabs floor log pow scalbn sin sinf sqrt)
cosf fabs floor log pow scalbn sin sinf sqrt sqrtf tan tanf)
string(TOUPPER ${_FN} _UPPER)
set(HAVE_${_UPPER} 1)
endforeach()
Expand Down Expand Up @@ -541,7 +542,7 @@ if(LIBC)
set(CMAKE_REQUIRED_LIBRARIES m)
foreach(_FN
atan atan2 ceil copysign cos cosf fabs floor log pow scalbn sin
sinf sqrt)
sinf sqrt sqrtf tan tanf)
string(TOUPPER ${_FN} _UPPER)
set(_HAVEVAR "HAVE_${_UPPER}")
check_function_exists("${_FN}" ${_HAVEVAR})
Expand Down Expand Up @@ -1308,3 +1309,12 @@ else()
install(TARGETS SDL2 RUNTIME DESTINATION bin)
endif()

##### Uninstall target #####

configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)

add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
27 changes: 21 additions & 6 deletions Makefile.in
Expand Up @@ -42,15 +42,25 @@ SDLTEST_OBJECTS = @SDLTEST_OBJECTS@
SRC_DIST = *.txt acinclude Android.mk autogen.sh android-project build-scripts cmake configure configure.in debian include Makefile.* sdl2-config.in sdl2.m4 sdl2.pc.in SDL2.spec.in src test VisualC.html VisualC Xcode Xcode-iOS
GEN_DIST = SDL2.spec

ifneq ($V,1)
RUN_CMD_AR = @echo " AR " $@;
RUN_CMD_CC = @echo " CC " $@;
RUN_CMD_CXX = @echo " CXX " $@;
RUN_CMD_LTLINK = @echo " LTLINK" $@;
RUN_CMD_RANLIB = @echo " RANLIB" $@;
LIBTOOL += --quiet
endif

HDRS = \
SDL.h \
SDL_assert.h \
SDL_atomic.h \
SDL_audio.h \
SDL_bits.h \
SDL_bits.h \
SDL_blendmode.h \
SDL_clipboard.h \
SDL_cpuinfo.h \
SDL_egl.h \
SDL_endian.h \
SDL_error.h \
SDL_events.h \
Expand All @@ -70,8 +80,13 @@ HDRS = \
SDL_mutex.h \
SDL_name.h \
SDL_opengl.h \
SDL_opengl_glext.h \
SDL_opengles.h \
SDL_opengles2_gl2ext.h \
SDL_opengles2_gl2.h \
SDL_opengles2_gl2platform.h \
SDL_opengles2.h \
SDL_opengles2_khrplatform.h \
SDL_pixels.h \
SDL_platform.h \
SDL_power.h \
Expand Down Expand Up @@ -123,15 +138,15 @@ update-revision:
.PHONY: all update-revision install install-bin install-hdrs install-lib install-data uninstall uninstall-bin uninstall-hdrs uninstall-lib uninstall-data clean distclean dist $(OBJECTS:.lo=.d)

$(objects)/$(TARGET): $(OBJECTS) $(VERSION_OBJECTS)
$(LIBTOOL) --tag=CC --mode=link $(CC) -o $@ $(OBJECTS) $(VERSION_OBJECTS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LT_LDFLAGS)
$(RUN_CMD_LTLINK)$(LIBTOOL) --tag=CC --mode=link $(CC) -o $@ $(OBJECTS) $(VERSION_OBJECTS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LT_LDFLAGS)

$(objects)/$(SDLMAIN_TARGET): $(SDLMAIN_OBJECTS)
$(AR) cru $@ $(SDLMAIN_OBJECTS)
$(RANLIB) $@
$(RUN_CMD_AR)$(AR) cru $@ $(SDLMAIN_OBJECTS)
$(RUN_CMD_RANLIB)$(RANLIB) $@

$(objects)/$(SDLTEST_TARGET): $(SDLTEST_OBJECTS)
$(AR) cru $@ $(SDLTEST_OBJECTS)
$(RANLIB) $@
$(RUN_CMD_AR)$(AR) cru $@ $(SDLTEST_OBJECTS)
$(RUN_CMD_RANLIB)$(RANLIB) $@

install: all install-bin install-hdrs install-lib install-data
install-bin:
Expand Down
3 changes: 3 additions & 0 deletions README-linux.txt
Expand Up @@ -22,6 +22,9 @@ 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

Ubuntu 14.04 can also add "libwayland-dev libmirclient-dev libxkbcommon-dev"
to that command line for Wayland and Mir support.

NOTES:
- This includes all the audio targets except arts, because Ubuntu pulled the
artsc0-dev package, but in theory SDL still supports it.
Expand Down
104 changes: 104 additions & 0 deletions README-nacl.txt
@@ -0,0 +1,104 @@
================================================================================
Simple DirectMedia Layer for Native Client
================================================================================

Requirements:

* Native Client SDK (https://developer.chrome.com/native-client),
(tested with Pepper version 33 or higher).

The SDL backend for Chrome's Native Client has been tested only with the PNaCl
toolchain, which generates binaries designed to run on ARM and x86_32/64
platforms. This does not mean it won't work with the other toolchains!

================================================================================
Building SDL for NaCl
================================================================================

Set up the right environment variables (see naclbuild.sh), then configure SDL with:

configure --host=pnacl --prefix some/install/destination

Then "make".

As an example of how to create a deployable app a Makefile project is provided
in test/nacl/Makefile, which includes some monkey patching of the common.mk file
provided by NaCl, without which linking properly to SDL won't work (the search
path can't be modified externally, so the linker won't find SDL's binaries unless
you dump them into the SDK path, which is inconvenient).
Also provided in test/nacl is the required support file, such as index.html,
manifest.json, etc.
SDL apps for NaCl run on a worker thread using the ppapi_simple infrastructure.
This allows for blocking calls on all the relevant systems (OpenGL ES, filesystem),
hiding the asynchronous nature of the browser behind the scenes...which is not the
same as making it disappear!


================================================================================
Running tests
================================================================================

Due to the nature of NaCl programs, building and running SDL tests is not as
straightforward as one would hope. The script naclbuild.sh in build-scripts
automates the process and should serve as a guide for users of SDL trying to build
their own applications.

Basic usage:

./naclbuild.sh path/to/pepper/toolchain (i.e. ~/naclsdk/pepper_35)

This will build testgles2.c by default.

If you want to build a different test, for example testrendercopyex.c:

SOURCES=~/sdl/SDL/test/testrendercopyex.c ./naclbuild.sh ~/naclsdk/pepper_35

Once the build finishes, you have to serve the contents with a web server (the
script will give you instructions on how to do that with Python).

================================================================================
RWops and nacl_io
================================================================================

SDL_RWops work transparently with nacl_io. Two functions control the mount points:

int mount(const char* source, const char* target,
const char* filesystemtype,
unsigned long mountflags, const void *data);
int umount(const char *target);

For convenience, SDL will by default mount an httpfs tree at / before calling
the app's main function. Such setting can be overridden by calling:

umount("/");

And then mounting a different filesystem at /

It's important to consider that the asynchronous nature of file operations on a
browser is hidden from the application, effectively providing the developer with
a set of blocking file operations just like you get in a regular desktop
environment, which eases the job of porting to Native Client, but also introduces
a set of challenges of its own, in particular when big file sizes and slow
connections are involved.

For more information on how nacl_io and mount points work, see:

https://developer.chrome.com/native-client/devguide/coding/nacl_io
https://src.chromium.org/chrome/trunk/src/native_client_sdk/src/libraries/nacl_io/nacl_io.h

To be able to save into the directory "/save/" (like backup of game) :

mount("", "/save", "html5fs", 0, "type=PERSISTENT");

And add to manifest.json :

"permissions": [
"unlimitedStorage"
]

================================================================================
TODO - Known Issues
================================================================================
* Testing of all systems with a real application (something other than SDL's tests)
* Key events don't seem to work properly

1 change: 1 addition & 0 deletions README-platforms.txt
Expand Up @@ -25,6 +25,7 @@ Platforms supported by volunteers
Haiku - maintained by Axel Dörfler <axeld@pinc-software.de>
PSP - maintained by 527721088@qq.com
Pandora - maintained by Scott Smith <pickle136@sbcglobal.net>
NaCl - maintained by Gabriel Jacobo <gabomdq@gmail.com>

Platforms that need maintainers
===============================
10 changes: 4 additions & 6 deletions VisualC.html
Expand Up @@ -22,8 +22,7 @@ <H3>
<P>
There are different solution files for the various
versions of the IDE. Please use the appropiate version
2008, 2010 or 2012; the 2010EE and 2012EE files
should be used with the "Express Edition" releases.
2008, 2010, 2012 or 2013.
</P>
<P>
Build the <CODE>.dll</CODE> and <CODE>.lib</CODE> files.
Expand Down Expand Up @@ -111,17 +110,16 @@ <H3>
</H3>
<P>
Now create the basic body of your project. The body of your program should take
the following form: <CODE>
<PRE>
the following form:
<PRE><CODE>
#include "SDL.h"

int main( int argc, char* argv[] )
{
// Body of the program goes here.
return 0;
}
</PRE>
</CODE>
</CODE></PRE>
<P></P>
<H3>
That's it!
Expand Down

0 comments on commit b29740b

Please sign in to comment.