Merge branch 'master' of github.com:supertuxkart/stk-code

This commit is contained in:
hiker 2017-08-03 21:23:32 +10:00
commit 623bb460c6
824 changed files with 74846 additions and 54796 deletions

View File

@ -1,16 +1,18 @@
environment:
DEPS_DIR: c:\\projects\dependencies
DEPS_BRANCH: master
ASSETS_DIR: c:\\projects\stk-assets
APPVEYOR_CACHE_ENTRY_ZIP_ARGS: -t7z -m0=lzma2 -mx=9
IRC_NOTIFY_SCRIPT: c:\\projects\stk-code\tools\appveyor-irc-notify.py
os: Visual Studio 2015
clone_depth: 1
shallow_clone: true
platform:
- x86
#- x64
# - x86
- x64
configuration:
- Debug
- Release
@ -18,15 +20,15 @@ configuration:
matrix:
fast_finish: true
cache:
- '%DEPS_DIR%'
#cache:
# - '%DEPS_DIR%'
#- '%ASSETS_DIR%'
install:
- ps: >-
If(!(Test-Path "$env:DEPS_DIR")) {
Write-Host "Downloading dependencies";
Start-Process -FilePath "git" -ArgumentList "clone --branch master --single-branch --depth 1 https://github.com/supertuxkart/dependencies.git $env:DEPS_DIR" -Wait;
Start-Process -FilePath "git" -ArgumentList "clone --branch $env:DEPS_BRANCH --single-branch --depth 1 https://github.com/supertuxkart/dependencies.git $env:DEPS_DIR" -Wait;
}
Else {
Write-Host "Updating dependencies";
@ -45,13 +47,20 @@ install:
#Get-ChildItem $env:ASSETS_DIR | Measure-Object -property length -sum
before_build:
- ps: Copy-Item "${env:DEPS_DIR}\windows\dependencies" c:\projects\stk-code\dependencies Recurse
- ps: Copy-Item "${env:DEPS_DIR}\windows_64bit\dependencies" c:\projects\stk-code\dependencies Recurse
- cmd: |
md build
cd build
if "%platform%"=="x86" set CMAKE_GENERATOR_NAME="Visual Studio 14 2015"
if "%platform%"=="x64" set CMAKE_GENERATOR_NAME="Visual Studio 14 2015 Win64"
cmake -G %CMAKE_GENERATOR_NAME% -DCMAKE_BUILD_TYPE="%configuration%" .. -DCHECK_ASSETS=OFF
build:
parallel: true
project: build\ALL_BUILD.vcxproj
on_success:
- "python %IRC_NOTIFY_SCRIPT% supertuxkart [{author}:{branch}] {short_commit}: {message} {color_green}Succeeded,Details: {build_url},Commit: {commit_url}"
on_failure:
- "python %IRC_NOTIFY_SCRIPT% supertuxkart [{author}:{branch}] {short_commit}: {message} {color_red}Failed,Details: {build_url},Commit: {commit_url}"

20
.gitignore vendored
View File

@ -51,3 +51,23 @@ packets_log.txt
history.dat
README.dependencies
xx
android/android-ndk*
android/android-sdk*
android/assets
android/bin
android/build
android/libs
android/obj
android/.gradle
android-*
*.apk
*.keystore
lib/curl
lib/freetype
lib/ifaddrs
lib/libogg
lib/libvorbis
lib/openal
lib/openssl

View File

@ -53,7 +53,7 @@ before_script:
script:
- mkdir "build"
- cd "build"
- cmake .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DSERVER_ONLY=$SERVER_ONLY -DCHECK_ASSETS=off
- cmake .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DSERVER_ONLY=$SERVER_ONLY -DCHECK_ASSETS=off -DBUILD_RECORDER=off
- make VERBOSE=1 -j $THREADS
notifications:

View File

@ -1,3 +1,17 @@
## SuperTuxKart 0.9.3
* Reduced RAM and VRAM usage, reducing load times by Auria and Benau
* New kart Wilbert by Jymis
* New kart Hexley by Jymis
* New track Cornfield Crossing by samuncle
* Physics improvements and various physics bugfixes by hiker
* Kart GFX improvements (exhaust and headlight)
* In-game screen recording feature by Benau and Stragus
* Bug fixes on the old render pipeline by Benau and Stragus
* Hardware skinning
* New smoother camera by Auria
* New grand prix win scene
* Various improvements (wall driving fixes, parachutes, GP points, cannon fixes, colorization shader)
## SuperTuxKart 0.9.2
* Ghost replay races by Benau
* Battle mode AI by Benau

View File

@ -1,6 +1,6 @@
# root CMakeLists for the SuperTuxKart project
project(SuperTuxKart)
set(PROJECT_VERSION "0.9.1")
set(PROJECT_VERSION "git")
cmake_minimum_required(VERSION 2.8.4)
if(NOT (CMAKE_MAJOR_VERSION VERSION_LESS 3))
@ -8,6 +8,7 @@ if(NOT (CMAKE_MAJOR_VERSION VERSION_LESS 3))
endif()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")
include(CMakeDependentOption)
include(BuildTypeSTKRelease)
if (NOT CMAKE_BUILD_TYPE)
@ -19,7 +20,10 @@ option(SERVER_ONLY "Create a server only (i.e. no graphics or sound)" OFF)
option(USE_FRIBIDI "Support for right-to-left languages" ON)
option(CHECK_ASSETS "Check if assets are installed in ../stk-assets" ON)
option(USE_SYSTEM_ANGELSCRIPT "Use system angelscript instead of built-in angelscript. If you enable this option, make sure to use a compatible version." OFF)
option(ENABLE_NETWORK_MULTIPLAYER "Enable network multiplayer. This will replace the online profile GUI in the main menu with the network multiplayer GUI" OFF)
option(ENABLE_WAYLAND_DEVICE "Enable Wayland device for linux build" OFF)
CMAKE_DEPENDENT_OPTION(BUILD_RECORDER "Build opengl recorder" ON
"NOT SERVER_ONLY;NOT USE_GLES2;NOT APPLE" OFF)
if (UNIX AND NOT APPLE)
option(USE_GLES2 "Use OpenGL ES2 renderer" OFF)
@ -74,6 +78,10 @@ if(SERVER_ONLY)
add_definitions(-DNO_IRR_COMPILE_WITH_X11_)
endif()
if(DISABLE_VPX)
add_definitions(-DNO_VPX)
endif()
# Build the Bullet physics library
add_subdirectory("${PROJECT_SOURCE_DIR}/lib/bullet")
include_directories("${PROJECT_SOURCE_DIR}/lib/bullet/src")
@ -89,7 +97,7 @@ if(NOT USE_GLES2 AND NOT SERVER_ONLY)
include_directories("${PROJECT_SOURCE_DIR}/lib/glew/include")
endif()
if((WIN32 AND NOT MINGW) OR APPLE)
if(MSVC OR APPLE)
if (NOT APPLE)
# Build zlib library
add_subdirectory("${PROJECT_SOURCE_DIR}/lib/zlib")
@ -100,22 +108,54 @@ if((WIN32 AND NOT MINGW) OR APPLE)
endif()
# Build png library
set (SKIP_INSTALL_ALL TRUE)
set (PNG_STATIC TRUE)
set (PNG_TESTS FALSE)
set (PNG_SHARED FALSE)
set(SKIP_INSTALL_ALL TRUE)
set(PNG_STATIC TRUE CACHE BOOL "Build static lib")
set(PNG_TESTS FALSE CACHE BOOL "Build libpng tests")
set(PNG_SHARED FALSE CACHE BOOL "Build shared lib")
add_subdirectory("${PROJECT_SOURCE_DIR}/lib/libpng")
include_directories("${PROJECT_SOURCE_DIR}/lib/libpng")
#build jpeg library
set(PNG_PNG_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/lib/libpng/")
set(PNG_LIBRARY png_static)
endif()
# Add jpeg library
if (APPLE)
add_subdirectory("${PROJECT_SOURCE_DIR}/lib/jpeglib")
include_directories("${PROJECT_SOURCE_DIR}/lib/jpeglib")
set(PNG_PNG_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/lib/libpng/")
set(PNG_LIBRARY png15_static)
set(JPEG_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/lib/jpeglib/")
set(JPEG_LIBRARY jpeglib)
else()
find_package(JPEG REQUIRED)
include_directories(${JPEG_INCLUDE_DIR})
endif()
if (BUILD_RECORDER)
find_library(OPENGLRECORDER_LIBRARY NAMES openglrecorder libopenglrecorder PATHS "${PROJECT_SOURCE_DIR}/dependencies/lib")
find_path(OPENGLRECORDER_INCLUDEDIR NAMES openglrecorder.h PATHS "${PROJECT_SOURCE_DIR}/dependencies/include")
if (NOT OPENGLRECORDER_LIBRARY OR NOT OPENGLRECORDER_INCLUDEDIR)
if(PROJECT_VERSION STREQUAL "git")
message(WARNING "libopenglrecorder not found, disabling in-game recorder. "
"To use recorder, install libopenglrecorder.")
set(OPENGLRECORDER_LIBRARY CACHE INTERNAL "")
set(OPENGLRECORDER_INCLUDEDIR CACHE INTERNAL "")
set(BUILD_RECORDER OFF)
else()
message(FATAL_ERROR "libopenglrecorder not found. "
"Either install libopenglrecorder or disable in-game recorder with -DBUILD_RECORDER=0")
endif()
else()
include_directories(${OPENGLRECORDER_INCLUDEDIR})
mark_as_advanced(OPENGLRECORDER_LIBRARY OPENGLRECORDER_INCLUDEDIR)
add_definitions(-DENABLE_RECORDER)
endif()
endif()
if(NOT SERVER_ONLY AND NOT USE_GLES2)
add_subdirectory("${PROJECT_SOURCE_DIR}/lib/graphics_utils")
include_directories("${PROJECT_SOURCE_DIR}/lib/graphics_utils")
endif()
# Build the irrlicht library
add_subdirectory("${PROJECT_SOURCE_DIR}/lib/irrlicht")
include_directories("${PROJECT_SOURCE_DIR}/lib/irrlicht/include")
@ -204,13 +244,6 @@ if(USE_FRIBIDI)
endif()
endif()
# OpenMP
find_package(OpenMP)
if (OPENMP_FOUND)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()
# OpenGL
if(NOT USE_GLES2 AND NOT SERVER_ONLY)
find_package(OpenGL REQUIRED)
@ -249,11 +282,6 @@ if(MINGW AND CMAKE_BUILD_TYPE MATCHES Release)
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--subsystem,windows")
endif()
# Netwowk Multiplayer
if(ENABLE_NETWORK_MULTIPLAYER)
add_definitions(-DENABLE_NETWORK_MULTIPLAYER_SCREEN)
endif()
if(WIN32)
# By default windows.h has macros defined for min and max that screw up everything
add_definitions(-DNOMINMAX)
@ -356,7 +384,9 @@ else()
endif()
# CURL
if(WIN32)
if(MSVC)
target_link_libraries(supertuxkart ${PROJECT_SOURCE_DIR}/dependencies/lib/libcurl.lib)
elseif(MINGW)
target_link_libraries(supertuxkart ${PROJECT_SOURCE_DIR}/dependencies/lib/libcurldll.a)
else()
find_package(CURL REQUIRED)
@ -375,13 +405,16 @@ target_link_libraries(supertuxkart
${OGGVORBIS_LIBRARIES}
${OPENAL_LIBRARY}
${FREETYPE_LIBRARIES}
${JPEG_LIBRARIES}
${TURBOJPEG_LIBRARY}
${VPX_LIBRARIES}
)
if(NOT SERVER_ONLY)
if(NOT USE_GLES2)
target_link_libraries(supertuxkart ${OPENGL_LIBRARIES} glew)
target_link_libraries(supertuxkart ${OPENGL_gl_LIBRARY} glew graphics_utils)
else()
target_link_libraries(supertuxkart EGL GLESv2)
target_link_libraries(supertuxkart GLESv2)
endif()
endif()
@ -396,6 +429,10 @@ if(UNIX AND NOT APPLE)
endif()
endif()
if(BUILD_RECORDER)
target_link_libraries(supertuxkart ${OPENGLRECORDER_LIBRARY})
endif()
# FreeBSD does not search in /usr/local/lib, but at least Freetype is installed there :(
if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/usr/local/lib")
@ -453,10 +490,6 @@ if(MINGW)
if(LIBSTDCPP)
file(COPY ${LIBSTDCPP} DESTINATION ${CMAKE_BINARY_DIR}/bin/)
endif()
find_library(LIBOPENMP NAMES "libgomp-1.dll" PATHS ${CMAKE_FIND_ROOT_PATH})
if(LIBOPENMP)
file(COPY ${LIBOPENMP} DESTINATION ${CMAKE_BINARY_DIR}/bin/)
endif()
find_library(LIBPTHREAD NAMES "winpthread-1.dll" "libwinpthread-1.dll" "pthreadGC2.dll" PATHS ${CMAKE_FIND_ROOT_PATH})
if(LIBPTHREAD)
file(COPY ${LIBPTHREAD} DESTINATION ${CMAKE_BINARY_DIR}/bin/)
@ -500,9 +533,9 @@ if(STK_ASSETS_DIR AND CHECK_ASSETS)
install(DIRECTORY ${STK_ASSETS_DIR} DESTINATION ${STK_INSTALL_DATA_DIR}/data PATTERN ".svn" EXCLUDE PATTERN ".git" EXCLUDE)
endif()
install(FILES ${STK_DATA_DIR}/supertuxkart.desktop DESTINATION share/applications)
install(FILES data/supertuxkart_32.png DESTINATION share/icons/hicolor/32x32/apps RENAME supertuxkart.png)
install(FILES data/supertuxkart_48.png DESTINATION share/icons/hicolor/48x48/apps RENAME supertuxkart.png)
install(FILES data/supertuxkart_128.png DESTINATION share/icons/hicolor/128x128/apps RENAME supertuxkart.png)
install(FILES data/supertuxkart_32.png data/supertuxkart_128.png DESTINATION share/pixmaps)
install(FILES data/supertuxkart_48.png DESTINATION share/pixmaps RENAME supertuxkart.png)
install(FILES data/supertuxkart.appdata.xml DESTINATION share/appdata)
if(MINGW)

124
README.md
View File

@ -1,47 +1,51 @@
# SuperTuxKart
[![Build Status](https://travis-ci.org/supertuxkart/stk-code.png?branch=master)](https://travis-ci.org/supertuxkart/stk-code)
[![Build Status](https://travis-ci.org/supertuxkart/stk-code.svg?branch=master)](https://travis-ci.org/supertuxkart/stk-code)
[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/supertuxkart/stk-code?svg=true&branch=master)](https://ci.appveyor.com/project/supertuxkart/stk-code)
[![#supertuxkart on the freenode IRC network](https://img.shields.io/badge/freenode-%23supertuxkart-brightgreen.svg)](https://webchat.freenode.net/?channels=supertuxkart)
SuperTuxKart is a free kart racing game. It focuses on fun and not on realistic kart physics. Instructions can be found on the in-game help page.
The SuperTuxKart homepage can be found at <https://supertuxkart.net/>. There is also our [FAQ](https://supertuxkart.net/FAQ) and information on how get in touch with the [community](https://supertuxkart.net/Community)
## Hardware Requirements
* You need a 3D graphics card. (NVIDIA GeForce 8xxx and higher, ATI Radeon HD 4xxx and higher or Intel HD 3000 and higher.)
* You should have a CPU that's running at 1GHz or better.
To run SuperTuxKart, make sure that your computer's specifications are equal or higher than the following specifications:
* A graphics card capable of 3D rendering - NVIDIA GeForce 8 series and newer (GeForce 8100 or newer), AMD/ATI Radeon HD 4000 series and newer, Intel HD Graphics 3000 and newer. OpenGL >= 3.1
* You should have a CPU that's running at 1 GHz or faster.
* You'll need at least 512 MB of free VRAM (video memory).
* Disk space: 400MB
* Ideally, you want a joystick with at least 6 buttons.
* Minimum disk space: 800 MB
* Ideally, you'll want a joystick with at least 6 buttons.
## License
This software is released under the GNU General Public License (GPL) which can be found in the file [`COPYING`](/COPYING) in the same directory as this file. Information about the licenses for artwork are contained in `data/licenses`.
The software is released under the GNU General Public License (GPL) which can be found in the file [`COPYING`](/COPYING) in the same directory as this file. Information about the licenses for the artwork is contained in `data/licenses`.
## 3D coordinates
A reminder for those looking at the code and 3d models:
A reminder for those who are looking at the code and 3D models:
STK : X right, Y up, Z forwards
SuperTuxKart: X right, Y up, Z forwards
Blender: X right, Y forwards, Z up
The exporters perform the needed transform, so in Blender you just work with XY plane as ground, and things will appear fine in STK (using XZ as ground in the code, obviously).
The export utilities perform the needed transformation, so in Blender you just work with the XY plane as ground, and things will appear fine in STK (using XZ as ground in the code, obviously).
## Building from source
First, you need both the code and the assets (See <https://supertuxkart.net/Source_control> for more information):
In order to build SuperTuxKart from source, you'll need both the code and the assets (See <https://supertuxkart.net/Source_control> for more information):
```
git clone https://github.com/supertuxkart/stk-code
svn checkout https://svn.code.sf.net/p/supertuxkart/code/stk-assets stk-assets
```bash
git clone https://github.com/supertuxkart/stk-code stk-code
svn co https://svn.code.sf.net/p/supertuxkart/code/stk-assets stk-assets
```
## Building on Linux
## Building SuperTuxKart on Linux
### Dependencies
Install the following packages:
To build SuperTuxKart from source, you'll need to install the following packages:
* OpenGL (mesa)
* OpenAL (recommended: openal-soft-devel)
* Ogg (libogg-dev)
* Ogg (libogg-dev)
* Vorbis (libvorbis-dev)
* Freetype (libfreetype6-dev)
* libcurl (libcurl-devel)
@ -52,18 +56,23 @@ Install the following packages:
Ubuntu command:
```
```bash
sudo apt-get install build-essential cmake libbluetooth-dev \
libcurl4-gnutls-dev libfreetype6-dev libfribidi-dev libgl1-mesa-dev \
libjpeg-dev libogg-dev libopenal-dev libpng-dev libvorbis-dev libxrandr-dev \
mesa-common-dev pkg-config zlib1g-dev
```
### In-game recorder
In order to build the in-game recorder for STK, you have to install
libopenglrecorder from your distribution, or compile it yourself from [here](https://github.com/Benau/libopenglrecorder).
Compilation instruction is explained there. If you don't need this feature, pass `-DBUILD_RECORDER=off` to cmake.
### Compiling
Compile SuperTuxKart:
Run the following commands to compile SuperTuxKart:
```
```bash
mkdir cmake_build
cd cmake_build
cmake ..
@ -73,15 +82,15 @@ STK can then be run from the build directory with `bin/supertuxkart`
### Further options
To create a debug version of STK, use:
To create a debug version of STK, run:
```
```bash
cmake .. -DCMAKE_BUILD_TYPE=Debug
```
You can install your build system-wide:
```
```bash
sudo make install
```
@ -92,22 +101,59 @@ location, specify `CMAKE_INSTALL_PREFIX` when running cmake, e.g.:
`cmake .. -DCMAKE_INSTALL_PREFIX=/opt/stk`
## Windows
1. Install VS 2013 (or later). The free express versions work fine.
2. Download and install a source package - either a released package or from our [git/svn repositories](https://supertuxkart.net/Source_control).
3. Download the latest dependency package from [here](https://sourceforge.net/projects/supertuxkart/files/SuperTuxKart%20Dependencies/Windows/). Unzip it in the root directory, so that the dependencies directory is next to the src and data directories (if you are updating from a previous dependency package, you can delete the .dll files in the root directory, they are not needed anymore).
4. Download cmake and install it. Then start cmake-gui and select the STK root directory as 'Where is the source code', and a new directory in the root directory (next to src, data etc) as the build directory (for now I assume that this directory is called bld).
5. Click on configure. You will be asked to create the directory (yes), then for your VS version. Make sure you select the right version (be aware of the easy to confuse version numbers: VS 2013 = version 12). Click on configure, then generate. This will create the directory 'bld', and a VS solution in that directory.
6. In Visual Studio open the project file generated in the 'bld' folder.
7. Right click on the supertuxkart project in the solution explorer, and select "Set as StartUp Project".
8. Select Build->Build Solution (or press F7) to compile.
## Building SuperTuxKart on Windows
To Build SuperTuxKart on Windows, follow these instructions:
## OS X
1. Download and install Visual Studio from here: [Visual Studio - Download](https://www.visualstudio.com/downloads/). The free Visual Studio Community edition works fine.
2. Download the SuperTuxKart source package from either [SuperTuxKart download area - SourceForge.net](https://sourceforge.net/projects/supertuxkart/files/SuperTuxKart/0.9.2) or [SuperTuxKart.net - Source Control](https://supertuxkart.net/Source_control), and unpack it.
*Note: If you downloaded the source package from here: [SuperTuxKart.net - Source Control](https://supertuxkart.net/Source_control), then both `stk-code` and `stk-assets` **must** be in the same directory, otherwise the build can result in failure*
3. Download the Windows dependencies package from either [SuperTuxKart download area: Dependecies - SourceForge.net](https://sourceforge.net/projects/supertuxkart/files/SuperTuxKart%20Dependencies/Windows/)
or [SuperTuxKart on GitHub - Dependencies](https://github.com/supertuxkart/dependencies), and unpack it; then, copy the `dependencies` directory from either the `windows` or the `windows_64bit` directories into the `stk-code` directory
4. Download CMake from here: [CMake - download page](https://cmake.org/download/), install it; once CMake is installed, double click on the CMake icon on your desktop, and point it towards your `stk-code` directory in the 'Where is the source code' field, and point it to a directory called `build` or `bld`
5. Press 'Configure'; CMake will ask you if it is OK to create the aformentioned directory, press `Yes`. CMake will then ask you about your version of Visual Studio.
Confirm your selection; *Please look at the table below to avoid confusion between version numbers and releases of Visual Studio*;
CMake will begin creating the required files for the build in the directory.
6. Navigate to your build directory and open the `SuperTuxKart.sln` file; Visual Studio will now load the solution.
7. In the 'Solution Explorer', right click on the `supertuxkart` project and select "Set as StartUp project"
8. Open the 'Build' menu and select 'Build Solution'; or, press the default keyboard shortcut: `CTRL + SHIFT + B` to build the solution.
*Note: To avoid confusion between releases and versions, refer to this table:*
Visual Studio Release | Version
----------------------|------------
Visual Studio 2017| 15
Visual Studio 2015| 14
Visual Studio 2013| 13
## Building SuperTuxKart on Windows (from PowerShell/Command line)
1. Download and install Visual Studio from here: [Visual Studio - Download](https://www.visualstudio.com/downloads/), the free Visual Studio Community edition works fine.
2. Download a source package from either [SuperTuxKart 0.9.2 download area - SourceForge.net](https://sourceforge.net/projects/supertuxkart/files/SuperTuxKart/0.9.2) or [SuperTuxKart.net - Source Control](https://supertuxkart.net/Source_control)
NOTE: the `stk-code` and `stk-assets` directories **must** be in the same directory
3. Download the Windows dependencies package from either [SuperTuxKart download area - SourceForge.net](https://sourceforge.net/projects/supertuxkart/files/SuperTuxKart%20Dependencies/Windows/)
or [SuperTuxKart on GitHub - Dependencies](https://github.com/supertuxkart/dependencies)
and unpack the archive; once unpacked, copy the `dependencies` directory from either the `windows` or the `windows_64bit` directories into the `stk-code` directory
4. Download CMake from here: [CMake - download page](https://cmake.org/download/); and install it. Navigate to the `stk-code` directory; and create an directory called "build":
```cmd
mkdir build
cd build
```
5. Once inside the build directory; run CMake to start the compilation process:
```cmd
cmake ..
```
6. Now that CMake finished configuring and creating the necessary files for the build, run the build command in the same directory:
```cmd
msbuild.exe SuperTuxKart.sln
```
SuperTuxKart can now be run as `bin\Debug\supertuxkart.exe` or `bin\Release\supertuxkart.exe`
## Building SuperTuxKart on macOS
### Getting Started
Install developer tools, either from the OS X Install DVD or from Apple's website.
Install the developer tools, either from the OS X Install DVD or from Apple's website.
If you have never built anything before, you have create `/usr/local/include/` first:
@ -142,23 +188,23 @@ You'll have to run these commands inside your stk-code directory.
With clang:
```
```bash
mkdir cmake_build
cd cmake_build
cmake ..
make
```
With GCC :
```
With GCC:
```bash
mkdir cmake_build
cd cmake_build
cmake .. -DCMAKE_CXX_COMPILER=/usr/bin/g++ -DCMAKE_C_COMPILER=/usr/bin/gcc
make
```
Building on 10.10 with 10.9 compat
```
Building on 10.10 with 10.9 compatibility:
```bash
cmake .. -DCMAKE_OSX_SYSROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -DCMAKE_OSX_DEPLOYMENT_TARGET=10.9
```
@ -172,7 +218,7 @@ mkdir xcode_build && cd xcode_build
cmake .. -GXcode
```
Use Finder to navigate to your stk-code/xcode_build folder and open the newly generated Xcode project (SuperTuxKart.xcodeproj).
Use Finder to navigate to your stk-code/xcode_build folder and open the newly generated Xcode project (`SuperTuxKart.xcodeproj`).
You can then build the project in Xcode using Product -> Build

174
android/Android.mk Normal file
View File

@ -0,0 +1,174 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
# OpenAL
LOCAL_MODULE := openal
LOCAL_SRC_FILES := obj/openal/libopenal.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
# OGG
LOCAL_MODULE := ogg
LOCAL_SRC_FILES := obj/libogg/src/.libs/libogg.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
# Vorbis
LOCAL_MODULE := vorbis
LOCAL_SRC_FILES := obj/libvorbis/lib/.libs/libvorbis.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
# Vorbisfile
LOCAL_MODULE := vorbisfile
LOCAL_SRC_FILES := obj/libvorbis/lib/.libs/libvorbisfile.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
# CURL
LOCAL_MODULE := curl
LOCAL_SRC_FILES := obj/curl/lib/.libs/libcurl.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
# libcrypto
LOCAL_MODULE := libcrypto
LOCAL_SRC_FILES := obj/openssl/libcrypto.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
# libssl
LOCAL_MODULE := libssl
LOCAL_SRC_FILES := obj/openssl/libssl.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
# JPEG
LOCAL_MODULE := jpeglib
LOCAL_SRC_FILES := obj/jpeglib/libjpeglib.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
# Freetype
LOCAL_MODULE := freetype
LOCAL_SRC_FILES := obj/freetype/objs/.libs/libfreetype.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
# zlib
LOCAL_MODULE := zlib
LOCAL_SRC_FILES := obj/zlib/libz.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
# PNG
LOCAL_MODULE := png
LOCAL_SRC_FILES := obj/libpng/libpng.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
# ifaddrs
LOCAL_MODULE := ifaddrs
LOCAL_PATH := .
LOCAL_SRC_FILES := ../lib/ifaddrs/ifaddrs.c
LOCAL_CFLAGS := -I../lib/ifaddrs
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
# AngelScript
LOCAL_MODULE := angelscript
LOCAL_PATH := .
LOCAL_CPP_FEATURES += rtti exceptions
LOCAL_SRC_FILES := $(wildcard ../lib/angelscript/source/*.S) \
$(wildcard ../lib/angelscript/source/*.cpp)
LOCAL_CFLAGS := -I../lib/angelscript/source/
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
# ENET
LOCAL_MODULE := enet
LOCAL_PATH := .
LOCAL_CPP_FEATURES += rtti
LOCAL_SRC_FILES := $(wildcard ../lib/enet/*.c)
LOCAL_CFLAGS := -I../lib/enet/include/ -DHAS_SOCKLEN_T
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
# Bullet
LOCAL_MODULE := bullet
LOCAL_PATH := .
LOCAL_CPP_FEATURES += rtti
LOCAL_SRC_FILES := $(wildcard ../lib/bullet/src/*/*.cpp) \
$(wildcard ../lib/bullet/src/*/*/*.cpp)
LOCAL_CFLAGS := -I../lib/bullet/src/
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
# Irrlicht
LOCAL_MODULE := irrlicht
LOCAL_PATH := .
LOCAL_CPP_FEATURES += rtti
LOCAL_SRC_FILES := $(wildcard ../lib/irrlicht/source/Irrlicht/*.cpp) \
$(wildcard ../lib/irrlicht/source/Irrlicht/Android/*.cpp)
LOCAL_CFLAGS := -I../lib/irrlicht/source/Irrlicht/ \
-I../lib/irrlicht/include/ \
-Iobj/jpeglib/ \
-Iobj/libpng/ \
-Iobj/zlib/ \
-I$(call my-dir)/../../sources/android/native_app_glue
-std=gnu++0x
LOCAL_STATIC_LIBRARIES := jpeglib png zlib
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
# STK
LOCAL_MODULE := main
LOCAL_PATH := .
LOCAL_CPP_FEATURES += rtti exceptions
LOCAL_SRC_FILES := $(wildcard ../src/*.cpp) \
$(wildcard ../src/*/*.cpp) \
$(wildcard ../src/*/*/*.cpp)
LOCAL_LDLIBS := -llog -landroid -lEGL -lGLESv3 -lOpenSLES
LOCAL_CFLAGS := -I../lib/angelscript/include \
-I../lib/bullet/src \
-I../lib/enet/include \
-I../lib/ifaddrs \
-I../lib/irrlicht/include \
-I../lib/irrlicht/source/Irrlicht \
-I../src \
-Iobj/curl/include \
-Iobj/freetype/include \
-Iobj/libogg/include \
-Iobj/libvorbis/include \
-Iobj/openal/include \
-I$(call my-dir)/../../sources/android/native_app_glue \
-DUSE_GLES2 \
-DHAVE_OGGVORBIS \
-DNDEBUG \
-std=gnu++0x
LOCAL_STATIC_LIBRARIES := irrlicht bullet enet freetype ifaddrs angelscript \
vorbisfile vorbis ogg openal curl libssl libcrypto \
gnustl_static android_native_app_glue
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
$(call import-module,android/native_app_glue)

View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.supertuxkart.stk"
android:versionCode="1"
android:versionName="1.0">
<!-- This .apk has no Java code itself, so set hasCode to false. -->
<application android:label="@string/app_name"
android:icon="@drawable/icon"
android:hasCode="false"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:hardwareAccelerated="true">
<activity android:name="android.app.NativeActivity"
android:label="@string/app_name"
android:configChanges="keyboardHidden|orientation"
android:screenOrientation="sensorLandscape">
<!-- Tell NativeActivity the name of or .so -->
<meta-data android:name="android.app.lib_name"
android:value="main" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="19" />
<uses-feature android:glEsVersion="0x00020000" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_MEDIA_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_MEDIA_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
</manifest>

179
android/README.ANDROID Normal file
View File

@ -0,0 +1,179 @@
================================================================================
SUPERTUXKART
================================================================================
--------------------------------------------------------------------------------
SYSTEM REQUIREMENTS
--------------------------------------------------------------------------------
To run SuperTuxKart on Android, you need a device that meets following
requirements:
- Android 4.4 or later
- Processor compatible with armv7 or x86
- GPU that supports OpenGL ES 3.0
- 1 GB RAM (STK uses ~150 MB in minimal configuration)
- 300 MB of free space on internal storage
- Touch screen or external keyboard
--------------------------------------------------------------------------------
COMPILATION
--------------------------------------------------------------------------------
The build scripts are designed to run under linux. They may work under cygwin
after some tweaks, but atm. only linux is supported.
Dependencies list (may be incomplete):
autoconf, automake, make, python, gradle, ant, imagemagick, cmake,
vorbis-tools
Additionally some dependencies for optimize_data script:
advancecomp, libjpeg-progs, optipng
Before compilation you must download the package with dependencies from:
https://github.com/supertuxkart/dependencies
and extract it to stk-code/lib. It contains sources of libraries that are used
in STK, but are not availiable in stk-code repository (curl, freetype, openal).
You need also Android SDK for android-19 platform (the API for Android 4.4) and
Android NDK r12b.
You need to create proper "android-sdk" and "android-ndk" symlinks in the
directory with Android project, so that the compilation script will have access
to the SDK and NDK.
These paths can be also set in SDK_PATH and NDK_PATH environmental variables.
Before running the compilation, run the generate_assets script, so that
selected assets will be copied to "assets" directory, and then included in the
apk file.
You can select different karts and tracks by setting KARTS and TRACKS variables
in the generate_assets.sh script at the beginning of file.
When you are creating the assets directory manually, note that the
directories.txt file is urgently needed and it is used by the application for
extracting assets.
If the assets directory is already prepared, you can run "./make.sh" command to
build the project and create an apk file. Note that all arguments are passed to
the make command, so that you can run "./make.sh -j5" for multi-threaded build.
If you want to prepare a package for particular architecture, you can choose it
by setting the COMPILE_ARCH environmental variable. At this stage, supported
architectures are "armv7", "x86" and "aarch64". The default is "armv7".
You can choose build type by setting BUILD_TYPE environment variable to "debug"
or "release". The default is debug build. Note that if you choose release build,
you have to manually sign the apk with your key and run zipalign.
Additionally you can choose the build tool by setting BUILD_TOOL environment
variable to "gradle" or "ant". Note that ant has been already removed from
Android SDK, so you have to use SDK <= 25.2.5 for building with ant. By default
the BUILD_TOOL is set to "gradle". It has hardcoded version of SDK build-tools
that are set to "25.0.3", so you have to use this particular version (or you can
edit build.gradle file).
Basically if all dependencies are installed in the system, it should be enough
to just run:
export SDK_PATH=/path/to/your/android/sdk
export NDK_PATH=/path/to/your/android/ndk
./generate_assets.sh
./make.sh -j5
--------------------------------------------------------------------------------
RELEASE BUILD
--------------------------------------------------------------------------------
Making a release build is similar to typical compilation, but there are few
additional things to do.
You have to change version numbers. This is important, because assets manager
in STK checks these numbers and detects if already extracted data files are
up to date. So that when you will install new STK version, this will force new
data extraction automatically.
So that you have to:
1. Change "data/supertuxkart.git" to "data/supertuxkart.VERSION_NUMBER"
2. Open "src/utils/constants.cpp" and change:
const char STK_VERSION[] = "git";
to
const char STK_VERSION[] = "VERSION_NUMBER";
where "VERSION_NUMBER" is for example "0.9.3" or "git20170409" or whatever.
3. You can also update these lines in "android/AndroidManifest.xml":
android:versionCode="1"
android:versionName="1.0"
Before compilation you have to set:
export BUILD_TYPE=release
and then you make standard compilation with:
./generate_assets.sh
./make.sh -j5
The compiled apk is unsigned, so you have to sign it with your key. To sign it,
you have to run:
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore \
my-release-key.keystore SuperTuxKart-release-unsigned.apk alias_name
and then:
zipalign -v 4 SuperTuxKart-release-unsigned.apk SuperTuxKart-release.apk
--------------------------------------------------------------------------------
KNOWN ISSUES
--------------------------------------------------------------------------------
1. It's not possible to compile STK for Android < 4.4 due to missing GLES 3.0
functions. It is technically possible to do - check GLES context version,
load OpenGL functions dynamically using EGL, and if they are not loaded
properly, then fallback to GLES 2.0.
2. It never ocurred for me, but it's possible that EGL context is lost in some
cases. SuperTuxKart is not designed to re-create all textures at any moment,
so this is a "Wontfix", at least for now.
3. We use "exit(0)" at the end of main function. We shouldn't do it and we
should just return from the main function. But STK uses some global
variables and their values are remembered when the game is restarted. We
should properly clear them or re-initialize on startup. Using the "exit(0)"
is not-that-bad workaround, but it may cause a crash on exit sometimes.
It seems to affect only Android 5.0. More information about the crash:
https://code.google.com/p/android/issues/detail?id=160824
4. STK crashes on startup on some devices when aarch64 build is made using
Android r13 NDK. The r13 version has rather big modifications (it uses clang
instead of gcc by default). This is probably a bug in NDK/compiler/OS, but
for this reason using NDK r12 for 64-bit arm compilation is preferred.
5. Angelscript doesn't have full support for aarch64 builds, so that scripting
won't work on this platform.
6. Turning left/right using accelerometer is available, but at this stage the
default screen orientation is not automatically detected and user must
manually choose if he needs "phone" or "tablet" accelerometer.

31
android/build.gradle Normal file
View File

@ -0,0 +1,31 @@
buildscript
{
repositories
{
jcenter()
}
dependencies
{
classpath 'com.android.tools.build:gradle:2.2.3'
}
}
apply plugin: 'com.android.application'
android
{
compileSdkVersion sdkVersion.toInteger()
buildToolsVersion "25.0.3"
sourceSets
{
main
{
manifest.srcFile 'AndroidManifest.xml'
jniLibs.srcDirs = ['libs']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
}

6
android/build.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="SuperTuxKart" default="help">
<import file="${sdk.dir}/tools/ant/build.xml" />
</project>

453
android/generate_assets.sh Executable file
View File

@ -0,0 +1,453 @@
#!/bin/sh
#
# (C) 2016-2017 Dawid Gan, under the GPLv3
#
# A script that generates data files for Android apk
# Below you can find some simple configuration variables.
# It's allowed to set "all" for KARTS and TRACKS if it's intended to create
# package with full data.
# The karts and tracks directories shouldn't exist in ASSETS_DIRS variable
# because they are handled separately.
# The TEXTURE_SIZE and SOUND_QUALITY take effect only if DECREASE_QUALITY has
# value greater than 0.
# The CONVERT_TO_JPG variable enables converting all images that are safe to
# convert and keeps other images untouched.
# The script needs imagemagick and ogg utils installed to use DECREASE_QUALITY
# feature
################################################################################
export KARTS="elephpant gnu nolok pidgin suzanne tux xue"
export TRACKS="battleisland cornfield_crossing featunlocked gplose gpwin \
hacienda introcutscene introcutscene2 lighthouse olivermath \
overworld sandtrack scotland snowmountain snowtuxpeak \
soccer_field tutorial"
export ASSETS_PATHS="../data \
../../stk-assets \
../../supertuxkart-assets"
export ASSETS_DIRS="library models music sfx textures"
export TEXTURE_SIZE=256
export JPEG_QUALITY=85
export PNG_QUALITY=95
export SOUND_QUALITY=42
export SOUND_MONO=1
export SOUND_SAMPLE=32000
export RUN_OPTIMIZE_SCRIPT=0
export DECREASE_QUALITY=1
export CONVERT_TO_JPG=1
export BLACKLIST_FILES="data/music/cocoa_river_fast.ogg2"
################################################################################
export LANG=C
cd "`dirname "$0"`"
# Find assets path
for ASSETS_PATH in $ASSETS_PATHS; do
if [ -d $ASSETS_PATH ] && [ `ls $ASSETS_PATH | grep -c tracks` -gt 0 ]; then
echo "Assets found in $ASSETS_PATH"
ASSETS_PATH_FOUND=1
break
fi
done
if [ -z $ASSETS_PATH_FOUND ]; then
echo "Couldn't find assets path"
exit 1
fi
if [ ! -d "../data" ]; then
echo "Couldn't find data directory"
exit 1
fi
# Clear previous assets directory
echo "Clear previous assets directory"
rm -rf assets
# Copy all assets
echo "Copy all assets"
mkdir -p assets/data
for DIR in `ls $ASSETS_PATH`; do
CAN_BE_COPIED=0
for ASSETS_DIR in $ASSETS_DIRS; do
if [ $DIR = $ASSETS_DIR ]; then
CAN_BE_COPIED=1
break
fi
done;
# Don't copy karts and tracks. It will be handled later
BLACKLIST_ASSETS="karts tracks"
for ASSETS_DIR in $BLACKLIST_ASSETS; do
if [ $DIR = $ASSETS_DIR ]; then
CAN_BE_COPIED=0
break
fi
done;
if [ $CAN_BE_COPIED -gt 0 ]; then
cp -a "$ASSETS_PATH/$DIR" assets/data/
fi
done;
# Copy selected tracks
echo "Copy selected tracks"
mkdir -p assets/data/tracks
for DIR in `ls $ASSETS_PATH/tracks`; do
CAN_BE_COPIED=0
if [ "$TRACKS" != "all" ]; then
for TRACK in $TRACKS; do
if [ $DIR = $TRACK ]; then
CAN_BE_COPIED=1
break
fi
done;
else
CAN_BE_COPIED=1
fi
if [ $CAN_BE_COPIED -gt 0 ]; then
cp -a "$ASSETS_PATH/tracks/$DIR" assets/data/tracks/
fi
done
# Copy selected karts
echo "Copy selected karts"
mkdir -p assets/data/karts
for DIR in `ls $ASSETS_PATH/karts`; do
CAN_BE_COPIED=0
if [ "$KARTS" != "all" ]; then
for KART in $KARTS; do
if [ $DIR = $KART ]; then
CAN_BE_COPIED=1
break
fi
done;
else
CAN_BE_COPIED=1
fi
if [ $CAN_BE_COPIED -gt 0 ]; then
cp -a "$ASSETS_PATH/karts/$DIR" assets/data/karts/
fi
done
# Decrease assets quality in order to save some disk space and RAM
echo "Decrease assets quality"
convert_image()
{
if [ -z "$1" ]; then
echo "No file to convert"
return
fi
FILE="$1"
FILE_TYPE="$2"
W=`identify -format "%[fx:w]" "$FILE"`
H=`identify -format "%[fx:h]" "$FILE"`
if [ -z $W ] || [ -z $H ]; then
echo "Couldn't convert $FILE file"
return
fi
if [ $W -gt $TEXTURE_SIZE ] || [ $H -gt $TEXTURE_SIZE ]; then
if [ $W -gt $H ]; then
SCALED_W=$TEXTURE_SIZE
SCALED_H=$(($TEXTURE_SIZE * $H / $W))
else
SCALED_W=$(($TEXTURE_SIZE * $W / $H))
SCALED_H=$TEXTURE_SIZE
fi
SCALE_CMD="-scale ${SCALED_W}x${SCALED_H}"
fi
if [ "$FILE_TYPE" = "jpg" ]; then
QUALITY_CMD="-quality $JPEG_QUALITY"
elif [ "$FILE_TYPE" = "png" ]; then
QUALITY_CMD="-quality $PNG_QUALITY"
fi
convert $SCALE_CMD $QUALITY_CMD "$FILE" "tmp.$FILE_TYPE"
if [ -s "tmp.$FILE_TYPE" ]; then
SIZE_OLD=`du -k "$FILE" | cut -f1`
SIZE_NEW=`du -k "tmp.$FILE_TYPE" | cut -f1`
if [ $SIZE_NEW -lt $SIZE_OLD ]; then
mv "tmp.$FILE_TYPE" "$FILE"
fi
fi
rm -f "tmp.$FILE_TYPE"
}
convert_sound()
{
if [ -z "$1" ]; then
echo "No file to convert"
return
fi
FILE="$1"
oggdec "$FILE" -o tmp.wav
if [ -s tmp.wav ]; then
OGGENC_CMD=""
if [ "$SOUND_MONO" -gt 0 ]; then
OGGENC_CMD="$OGGENC_CMD --downmix"
fi
OGG_RATE=`ogginfo "$FILE" | grep "Rate: " | cut -f 2 -d " " \
| grep -o '[0-9]*'`
if [ ! -z "$OGG_RATE" ] && [ "$OGG_RATE" -gt "$SOUND_SAMPLE" ]; then
OGGENC_CMD="$OGGENC_CMD --resample $SOUND_SAMPLE"
fi
OGGENC_CMD="$OGGENC_CMD -b $SOUND_QUALITY"
oggenc $OGGENC_CMD tmp.wav -o tmp.ogg
fi
if [ -s tmp.ogg ]; then
SIZE_OLD=`du -k "$FILE" | cut -f1`
SIZE_NEW=`du -k "tmp.ogg" | cut -f1`
if [ $SIZE_NEW -lt $SIZE_OLD ]; then
mv tmp.ogg "$FILE"
fi
fi
rm -f tmp.wav tmp.ogg
}
convert_b3d()
{
if [ -z "$1" ]; then
echo "No file to convert"
return
fi
FILE="$1"
echo "Convert file: $FILE"
if [ ! -f "$FILE" ]; then
echo " File doesn't exist."
return
fi
HEX_FILE=`hexdump -ve '1/1 "%.2x"' "$FILE"`
TEXS_CHUNK="54455853"
TEXS_CHUNK_POS=24
FOUND_CHUNK=`echo $HEX_FILE | head -c $(($TEXS_CHUNK_POS + 8)) \
| tail -c +$(($TEXS_CHUNK_POS + 1))`
if [ -z "$FOUND_CHUNK" ] || [ "$FOUND_CHUNK" != "$TEXS_CHUNK" ]; then
echo " Unsupported format."
return
fi
TEXS_SIZE=`echo $HEX_FILE | head -c $(($TEXS_CHUNK_POS + 16)) | tail -c 8`
TEXS_SIZE_CONVERTED=`echo $TEXS_SIZE | cut -c7-8`
TEXS_SIZE_CONVERTED=$TEXS_SIZE_CONVERTED`echo $TEXS_SIZE | cut -c5-6`
TEXS_SIZE_CONVERTED=$TEXS_SIZE_CONVERTED`echo $TEXS_SIZE | cut -c3-4`
TEXS_SIZE_CONVERTED=$TEXS_SIZE_CONVERTED`echo $TEXS_SIZE | cut -c1-2`
TEXS_SIZE_CONVERTED=`echo $((0x$TEXS_SIZE_CONVERTED))`
if [ $TEXS_SIZE_CONVERTED -le 0 ]; then
echo " Invalid TEXS size value."
return
fi
TEXS_BEGIN=$(($TEXS_CHUNK_POS + 16))
TEXS_END=$(($TEXS_BEGIN + $TEXS_SIZE_CONVERTED * 2))
HEX_TEXS=`echo $HEX_FILE | head -c $TEXS_END | tail -c +$(($TEXS_BEGIN+1))`
CURR_POS=0
cp "$FILE" tmp.b3d
while [ $CURR_POS -lt $TEXS_END ]; do
NULL_POS=`echo $HEX_TEXS | tail -c +$(($CURR_POS+1)) | grep -b -o "00" \
| head -n 1 | cut -f1 -d":"`
if [ -z $NULL_POS ]; then
echo " Done."
break
fi
if [ $NULL_POS -lt 4 ]; then
echo " Something went wrong..."
break
fi
TEXNAME_BEGIN=$((($TEXS_BEGIN + $CURR_POS) / 2))
TEXNAME_END=$((($TEXS_BEGIN + $CURR_POS + $NULL_POS) / 2))
CURR_POS=$(($CURR_POS + $NULL_POS + 58))
TEXTURE_NAME=`dd if="$FILE" bs=1 skip=$TEXNAME_BEGIN \
count=$(($TEXNAME_END - $TEXNAME_BEGIN)) 2> /dev/null`
DIRNAME=`dirname "$FILE"`
TEXTURE_PATH="$DIRNAME/$TEXTURE_NAME"
echo " Texture: $TEXTURE_NAME"
ALREADY_CONVERTED=0
if [ -s "./converted_textures" ]; then
while read -r CONVERTED_TEXTURE; do
if [ "$TEXTURE_PATH" = "$CONVERTED_TEXTURE" ]; then
ALREADY_CONVERTED=1
break
fi
done < "./converted_textures"
fi
if [ $ALREADY_CONVERTED -eq 0 ]; then
if [ ! -f "$TEXTURE_PATH" ]; then
echo " Couldn't find texture file. Ignore..."
continue
fi
FILE_EXTENSION=`echo "$TEXTURE_PATH" | tail -c 5`
if [ `echo "$FILE_EXTENSION" | head -c 1` != "." ]; then
echo " Unsupported file extension. Ignore..."
continue
fi
FILE_FORMAT=`identify -format %m "$TEXTURE_PATH"`
if [ "$FILE_FORMAT" = "JPEG" ]; then
echo " File is already JPEG. Ignore..."
continue
fi
#IS_OPAQUE=`identify -format '%[opaque]' "$TEXTURE_PATH"`
HAS_ALPHA=`identify -format '%A' "$TEXTURE_PATH"`
if [ "$HAS_ALPHA" = "True" ] || [ "$HAS_ALPHA" = "true" ]; then
echo " File has alpha channel. Ignore..."
continue
fi
NEW_TEXTURE_NAME="`echo $TEXTURE_NAME | head -c -5`.jpg"
NEW_TEXTURE_PATH="`echo $TEXTURE_PATH | head -c -5`.jpg"
if [ -f "$NEW_TEXTURE_PATH" ]; then
echo " There is already a file with .jpg extension. Ignore..."
continue
fi
convert -quality $JPEG_QUALITY "$TEXTURE_PATH" "$NEW_TEXTURE_PATH"
rm -f "$TEXTURE_PATH"
if [ -s "$DIRNAME/materials.xml" ]; then
sed -i "s/name=\"$TEXTURE_NAME\"/name=\"$NEW_TEXTURE_NAME\"/g" \
"$DIRNAME/materials.xml"
fi
if [ -s "$DIRNAME/scene.xml" ]; then
sed -i "s/name=\"$TEXTURE_NAME\"/name=\"$NEW_TEXTURE_NAME\"/g" \
"$DIRNAME/scene.xml"
fi
echo "$TEXTURE_PATH" >> "./converted_textures"
fi
echo -n ".jpg" | dd of=./tmp.b3d bs=1 seek=$(($TEXNAME_END - 4)) \
conv=notrunc 2> /dev/null
done
SIZE_OLD=`du -b "$FILE" | cut -f1`
SIZE_NEW=`du -b "tmp.b3d" | cut -f1`
if [ $SIZE_NEW -ne $SIZE_OLD ]; then
echo " Something went wrong..."
exit
fi
mv tmp.b3d "$FILE"
}
if [ $DECREASE_QUALITY -gt 0 ]; then
find assets/data -iname "*.png" | while read f; do convert_image "$f" "png"; done
find assets/data -iname "*.jpg" | while read f; do convert_image "$f" "jpg"; done
find assets/data -iname "*.ogg" | while read f; do convert_sound "$f"; done
fi
if [ $CONVERT_TO_JPG -gt 0 ]; then
find assets/data -iname "*.b3d" | while read f; do convert_b3d "$f"; done
if [ -s "./converted_textures" ]; then
echo "Converted textures:"
cat "./converted_textures"
rm -f "./converted_textures"
fi
fi
# Copy data directory
echo "Copy data directory"
cp -a ../data/* assets/data/
# Remove unused files
for BLACKLIST_FILE in $BLACKLIST_FILES; do
rm -f "assets/$BLACKLIST_FILE"
done
# Run optimize_data.sh script
if [ $RUN_OPTIMIZE_SCRIPT -gt 0 ]; then
echo "Run optimize_data.sh script"
sh -c 'cd assets/data; ../../../data/optimize_data.sh'
fi
# Generate directories list
echo "Generate directories list"
find assets/* -type d > assets/directories.txt
sed -i s/'.\/assets\/'// assets/directories.txt
sed -i s/'assets\/'// assets/directories.txt
# It will be probably ignored by ant, but create it anyway...
touch assets/.nomedia
echo "Done."
exit 0

334
android/make.sh Executable file
View File

@ -0,0 +1,334 @@
#!/bin/sh
#
# (C) 2016-2017 Dawid Gan, under the GPLv3
#
# A script that creates the apk build
export DIRNAME=$(realpath "$(dirname "$0")")
export NDK_PATH_DEFAULT="$DIRNAME/android-ndk"
export SDK_PATH_DEFAULT="$DIRNAME/android-sdk"
export NDK_TOOLCHAIN_PATH="$DIRNAME/obj/bin"
export NDK_BUILD_SCRIPT="$DIRNAME/Android.mk"
export PATH="$DIRNAME/obj/bin:$PATH"
export CROSS_SYSROOT="$DIRNAME/obj/sysroot"
#export NDK_CCACHE=ccache
export NDK_CPPFLAGS="-O3 -g"
export NDK_ABI_ARMV7=armeabi-v7a
export ARCH_ARMV7=arm
export HOST_ARMV7=arm-linux-androideabi
export NDK_PLATFORM_ARMV7=android-19
export SDK_VERSION_ARMV7=19
export NDK_ABI_X86=x86
export ARCH_X86=x86
export HOST_X86=i686-linux-android
export NDK_PLATFORM_X86=android-19
export SDK_VERSION_X86=19
export NDK_ABI_AARCH64=arm64-v8a
export ARCH_AARCH64=arm64
export HOST_AARCH64=aarch64-linux-android
export NDK_PLATFORM_AARCH64=android-21
export SDK_VERSION_AARCH64=21
# A helper function that checks if error ocurred
check_error()
{
if [ $? -gt 0 ]; then
echo "Error ocurred."
exit
fi
}
# Handle clean command
if [ ! -z "$1" ] && [ "$1" = "clean" ]; then
rm -rf bin
rm -rf build
rm -rf libs
rm -rf obj
rm -rf .gradle
exit
fi
# Check if compilation for different platform has been started before
if [ -f "$DIRNAME/obj/compile_arch" ]; then
PROJECT_ARCH=$(cat "$DIRNAME/obj/compile_arch")
if [ -z "$COMPILE_ARCH" ]; then
COMPILE_ARCH="$PROJECT_ARCH"
elif [ "$PROJECT_ARCH" != "$COMPILE_ARCH" ]; then
echo "Error: Compilation for different platform has been already made."
echo "Run './make.sh clean' first or set COMPILE_ARCH variable" \
"to '$PROJECT_ARCH.'"
exit
fi
fi
# Update variables for selected architecture
if [ -z "$COMPILE_ARCH" ]; then
COMPILE_ARCH="armv7"
fi
if [ "$COMPILE_ARCH" = "armv7" ]; then
export NDK_PLATFORM=$NDK_PLATFORM_ARMV7
export NDK_ABI=$NDK_ABI_ARMV7
export ARCH=$ARCH_ARMV7
export HOST=$HOST_ARMV7
export SDK_VERSION=$SDK_VERSION_ARMV7
elif [ "$COMPILE_ARCH" = "x86" ]; then
export NDK_PLATFORM=$NDK_PLATFORM_X86
export NDK_ABI=$NDK_ABI_X86
export ARCH=$ARCH_X86
export HOST=$HOST_X86
export SDK_VERSION=$SDK_VERSION_X86
elif [ "$COMPILE_ARCH" = "aarch64" ]; then
export NDK_PLATFORM=$NDK_PLATFORM_AARCH64
export NDK_ABI=$NDK_ABI_AARCH64
export ARCH=$ARCH_AARCH64
export HOST=$HOST_AARCH64
export SDK_VERSION=$SDK_VERSION_AARCH64
else
echo "Unknow COMPILE_ARCH: $COMPILE_ARCH. Possible values are: " \
"armv7, aarch64, x86"
exit
fi
# Update variables for selected build type
if [ -z "$BUILD_TYPE" ]; then
BUILD_TYPE="debug"
fi
if [ "$BUILD_TYPE" = "debug" ] || [ "$BUILD_TYPE" = "Debug" ]; then
export ANT_BUILD_TYPE="debug"
export GRADLE_BUILD_TYPE="assembleDebug"
export IS_DEBUG_BUILD=1
elif [ "$BUILD_TYPE" = "release" ] || [ "$BUILD_TYPE" = "Release" ]; then
export ANT_BUILD_TYPE="release"
export GRADLE_BUILD_TYPE="assembleRelease"
export IS_DEBUG_BUILD=0
else
echo "Unsupported BUILD_TYPE: $BUILD_TYPE. Possible values are: " \
"debug, release"
exit
fi
# Check selected build tool
if [ -z "$BUILD_TOOL" ]; then
BUILD_TOOL="gradle"
fi
if [ "$BUILD_TOOL" != "gradle" ] && [ "$BUILD_TOOL" != "ant" ]; then
echo "Unsupported BUILD_TOOL: $BUILD_TOOL. Possible values are: " \
"gradle, ant"
exit
fi
# Check if we have access to the Android NDK and SDK
if [ -z "$NDK_PATH" ]; then
export NDK_PATH="$NDK_PATH_DEFAULT"
fi
if [ -z "$SDK_PATH" ]; then
export SDK_PATH="$SDK_PATH_DEFAULT"
fi
NDK_PATH=$(realpath "$NDK_PATH")
SDK_PATH=$(realpath "$SDK_PATH")
if [ ! -d "$NDK_PATH" ]; then
echo "Error: Couldn't find $NDK_PATH directory. Please create a symlink" \
"to your Android NDK installation in the $NDK_PATH_DEFAULT or set" \
"proper path in the NDK_PATH variable"
exit
fi
if [ ! -d "$SDK_PATH" ]; then
echo "Error: Couldn't find $SDK_PATH directory. Please create a symlink" \
"to your Android SDK installation in the $SDK_PATH_DEFAULT or set" \
"proper path in the SDK_PATH variable"
exit
fi
# Standalone toolchain
if [ ! -f "$DIRNAME/obj/make_standalone_toolchain.stamp" ]; then
echo "Creating standalone toolchain"
rm -rf "$DIRNAME/obj"
${NDK_PATH}/build/tools/make-standalone-toolchain.sh \
--platform=$NDK_PLATFORM \
--install-dir="$DIRNAME/obj/" \
--arch=$ARCH
check_error
touch "$DIRNAME/obj/make_standalone_toolchain.stamp"
echo $COMPILE_ARCH > "$DIRNAME/obj/compile_arch"
fi
# Freetype
if [ ! -f "$DIRNAME/obj/freetype.stamp" ]; then
echo "Compiling freetype"
mkdir -p "$DIRNAME/obj/freetype"
cp -a -f "$DIRNAME/../lib/freetype/"* "$DIRNAME/obj/freetype"
cd "$DIRNAME/obj/freetype"
./configure --host=$HOST \
--without-zlib \
--without-png \
--without-harfbuzz &&
make $@
check_error
touch "$DIRNAME/obj/freetype.stamp"
fi
# Zlib
if [ ! -f "$DIRNAME/obj/zlib.stamp" ]; then
echo "Compiling zlib"
mkdir -p "$DIRNAME/obj/zlib"
cp -a -f "$DIRNAME/../lib/zlib/"* "$DIRNAME/obj/zlib"
cd "$DIRNAME/obj/zlib"
cmake . -DCMAKE_TOOLCHAIN_FILE=../../../cmake/Toolchain-android.cmake \
-DHOST=$HOST &&
make $@
check_error
touch "$DIRNAME/obj/zlib.stamp"
fi
# Libpng
if [ ! -f "$DIRNAME/obj/libpng.stamp" ]; then
echo "Compiling libpng"
mkdir -p "$DIRNAME/obj/libpng"
mkdir -p "$DIRNAME/obj/libpng/lib"
cp -a -f "$DIRNAME/../lib/libpng/"* "$DIRNAME/obj/libpng"
cd "$DIRNAME/obj/libpng"
cmake . -DCMAKE_TOOLCHAIN_FILE=../../../cmake/Toolchain-android.cmake \
-DHOST=$HOST \
-DZLIB_LIBRARY="$DIRNAME/obj/zlib/libz.a" \
-DZLIB_INCLUDE_DIR="$DIRNAME/obj/zlib/" \
-DPNG_TESTS=0 &&
make $@
check_error
touch "$DIRNAME/obj/libpng.stamp"
fi
# Openal
if [ ! -f "$DIRNAME/obj/openal.stamp" ]; then
echo "Compiling openal"
mkdir -p "$DIRNAME/obj/openal"
cp -a -f "$DIRNAME/../lib/openal/"* "$DIRNAME/obj/openal"
cd "$DIRNAME/obj/openal"
cmake . -DCMAKE_TOOLCHAIN_FILE=../../../cmake/Toolchain-android.cmake \
-DHOST=$HOST \
-DALSOFT_UTILS=0 \
-DALSOFT_EXAMPLES=0 \
-DALSOFT_TESTS=0 \
-DLIBTYPE=STATIC &&
make $@
check_error
touch "$DIRNAME/obj/openal.stamp"
fi
# OpenSSL
if [ ! -f "$DIRNAME/obj/openssl.stamp" ]; then
echo "Compiling openssl"
mkdir -p "$DIRNAME/obj/openssl"
cp -a -f "$DIRNAME/../lib/openssl/"* "$DIRNAME/obj/openssl"
cd "$DIRNAME/obj/openssl"
./Configure android --cross-compile-prefix="$HOST-"
make $@
check_error
touch "$DIRNAME/obj/openssl.stamp"
fi
# Curl
if [ ! -f "$DIRNAME/obj/curl.stamp" ]; then
echo "Compiling curl"
mkdir -p "$DIRNAME/obj/curl"
cp -a -f "$DIRNAME/../lib/curl/"* "$DIRNAME/obj/curl"
cd "$DIRNAME/obj/curl"
CPPFLAGS="-I$DIRNAME/obj/openssl/include $CPPFLAGS" \
LDFLAGS="-L$DIRNAME/obj/openssl/ $LDFLAGS" \
./configure --host=$HOST \
--with-ssl \
--disable-shared \
--enable-static \
--enable-threaded-resolver &&
make $@
check_error
touch "$DIRNAME/obj/curl.stamp"
fi
# Jpeglib
if [ ! -f "$DIRNAME/obj/jpeglib.stamp" ]; then
echo "Compiling jpeglib"
mkdir -p "$DIRNAME/obj/jpeglib"
cp -a -f "$DIRNAME/../lib/jpeglib/"* "$DIRNAME/obj/jpeglib"
cd "$DIRNAME/obj/jpeglib"
cmake . -DCMAKE_TOOLCHAIN_FILE=../../../cmake/Toolchain-android.cmake \
-DHOST=$HOST &&
make $@
check_error
touch "$DIRNAME/obj/jpeglib.stamp"
fi
# Libogg
if [ ! -f "$DIRNAME/obj/libogg.stamp" ]; then
echo "Compiling libogg"
mkdir -p "$DIRNAME/obj/libogg"
cp -a -f "$DIRNAME/../lib/libogg/"* "$DIRNAME/obj/libogg"
cd "$DIRNAME/obj/libogg"
./configure --host=$HOST &&
make $@
check_error
touch "$DIRNAME/obj/libogg.stamp"
fi
# Libvorbis
if [ ! -f "$DIRNAME/obj/libvorbis.stamp" ]; then
echo "Compiling libvorbis"
mkdir -p "$DIRNAME/obj/libvorbis"
cp -a -f "$DIRNAME/../lib/libvorbis/"* "$DIRNAME/obj/libvorbis"
cd "$DIRNAME/obj/libvorbis"
CPPFLAGS="-I$DIRNAME/obj/libogg/include $CPPFLAGS" \
LDFLAGS="-L$DIRNAME/obj/libogg/src/.libs $LDFLAGS" \
./configure --host=$HOST &&
make $@
check_error
touch "$DIRNAME/obj/libvorbis.stamp"
fi
# STK
echo "Compiling STK"
cd "$DIRNAME"
${NDK_PATH}/ndk-build $@ \
APP_BUILD_SCRIPT="$NDK_BUILD_SCRIPT" \
APP_ABI="$NDK_ABI" \
APP_PLATFORM="$NDK_PLATFORM" \
APP_CPPFLAGS="$NDK_CPPFLAGS" \
APP_STL=gnustl_static \
NDK_DEBUG=$IS_DEBUG_BUILD
check_error
# Build apk
echo "Building APK"
if [ "$BUILD_TOOL" = "gradle" ]; then
export ANDROID_HOME="$SDK_PATH"
gradle -PsdkVersion=$SDK_VERSION $GRADLE_BUILD_TYPE
elif [ "$BUILD_TOOL" = "ant" ]; then
ant $ANT_BUILD_TYPE -Dsdk.dir="$SDK_PATH" -Dtarget=$NDK_PLATFORM
fi
check_error

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">SuperTuxKart</string>
</resources>

View File

@ -15,6 +15,7 @@ find_path(OGGVORBIS_VORBIS_INCLUDE_DIR NAMES vorbis/vorbisfile.h PATHS "${PROJEC
find_library(OGGVORBIS_OGG_LIBRARY NAMES ogg Ogg libogg PATHS "${PROJECT_SOURCE_DIR}/dependencies/lib")
find_library(OGGVORBIS_VORBIS_LIBRARY NAMES vorbis Vorbis libvorbis PATHS "${PROJECT_SOURCE_DIR}/dependencies/lib")
find_library(OGGVORBIS_VORBISFILE_LIBRARY NAMES vorbisfile libvorbisfile PATHS "${PROJECT_SOURCE_DIR}/dependencies/lib")
find_library(OGGVORBIS_VORBISENC_LIBRARY NAMES vorbisenc libvorbisenc PATHS "${PROJECT_SOURCE_DIR}/dependencies/lib")
if (APPLE)
set(OGGVORBIS_OGG_INCLUDE_DIR "/Library/Frameworks/Ogg.framework/Headers/")
@ -26,6 +27,11 @@ if(APPLE AND NOT OGGVORBIS_VORBISFILE_LIBRARY)
set(OGGVORBIS_VORBISFILE_LIBRARY ${OGGVORBIS_VORBIS_LIBRARY})
endif()
if(APPLE AND NOT OGGVORBIS_VORBISENC_LIBRARY)
# Seems to be the same on Apple systems
set(OGGVORBIS_VORBISENC_LIBRARY ${OGGVORBIS_VORBIS_LIBRARY})
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(OggVorbis DEFAULT_MSG
OGGVORBIS_OGG_INCLUDE_DIR OGGVORBIS_VORBIS_INCLUDE_DIR
@ -33,8 +39,8 @@ find_package_handle_standard_args(OggVorbis DEFAULT_MSG
# Publish variables
set(OGGVORBIS_INCLUDE_DIRS ${OGGVORBIS_OGG_INCLUDE_DIR} ${OGGVORBIS_VORBIS_INCLUDE_DIR})
set(OGGVORBIS_LIBRARIES ${OGGVORBIS_OGG_LIBRARY} ${OGGVORBIS_VORBIS_LIBRARY} ${OGGVORBIS_VORBISFILE_LIBRARY})
set(OGGVORBIS_LIBRARIES ${OGGVORBIS_OGG_LIBRARY} ${OGGVORBIS_VORBIS_LIBRARY} ${OGGVORBIS_VORBISFILE_LIBRARY} ${OGGVORBIS_VORBISENC_LIBRARY})
list(REMOVE_DUPLICATES OGGVORBIS_INCLUDE_DIRS)
list(REMOVE_DUPLICATES OGGVORBIS_LIBRARIES)
mark_as_advanced(OGGVORBIS_OGG_INCLUDE_DIR OGGVORBIS_VORBIS_INCLUDE_DIR)
mark_as_advanced(OGGVORBIS_OGG_LIBRARY OGGVORBIS_VORBIS_LIBRARY OGGVORBIS_VORBISFILE_LIBRARY)
mark_as_advanced(OGGVORBIS_OGG_LIBRARY OGGVORBIS_VORBIS_LIBRARY OGGVORBIS_VORBISFILE_LIBRARY OGGVORBIS_VORBISENC_LIBRARY)

View File

@ -0,0 +1,32 @@
# Cross-compiling requires CMake 2.6 or newer. Example:
# cmake .. -DCMAKE_TOOLCHAIN_FILE=../XCompile-Android.txt -DHOST=arm-linux-androideabi
# Where 'arm-linux-androideabi' is the host prefix for the cross-compiler. If
# you already have a toolchain file setup, you may use that instead of this
# file. Make sure to set CMAKE_FIND_ROOT_PATH to where the NDK toolchain was
# installed (e.g. "$ENV{HOME}/toolchains/arm-linux-androideabi-r10c-21").
# the name of the target operating system
SET(CMAKE_SYSTEM_NAME Linux)
# which compilers to use for C and C++
SET(CMAKE_C_COMPILER "${HOST}-gcc")
SET(CMAKE_CXX_COMPILER "${HOST}-g++")
SET(CMAKE_RC_COMPILER "${HOST}-windres")
# here is the target environment located
SET(CMAKE_FIND_ROOT_PATH $ENV{NDK_TOOLCHAIN_PATH})
# here is where stuff gets installed to
SET(CMAKE_INSTALL_PREFIX "${CMAKE_FIND_ROOT_PATH}" CACHE STRING "Install path prefix, prepended onto install directories." FORCE)
# adjust the default behaviour of the FIND_XXX() commands:
# search headers and libraries in the target environment, search
# programs in the host environment
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
# set env vars so that pkg-config will look in the appropriate directory for
# .pc files (as there seems to be no way to force using ${HOST}-pkg-config)
set(ENV{PKG_CONFIG_LIBDIR} "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig")
set(ENV{PKG_CONFIG_PATH} "")

View File

@ -9,8 +9,11 @@ SET(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc-posix)
SET(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++-posix)
SET(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres)
# figure out folder to look in
execute_process(COMMAND sh -c "ls /usr/lib/gcc/x86_64-w64-mingw32/ | grep posix | tr -d '\n'" OUTPUT_VARIABLE MINGW_DEPS_FOLDER)
# here is the target environment located
SET(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32 /usr/lib/gcc/x86_64-w64-mingw32/4.9-posix ${PROJECT_SOURCE_DIR}/dependencies)
SET(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32 /usr/lib/gcc/x86_64-w64-mingw32/${MINGW_DEPS_FOLDER}/ ${PROJECT_SOURCE_DIR}/dependencies)
# adjust the default behaviour of the FIND_XXX() commands:
# search headers and libraries in the target environment, search

View File

@ -9,8 +9,11 @@ SET(CMAKE_C_COMPILER i686-w64-mingw32-gcc-posix)
SET(CMAKE_CXX_COMPILER i686-w64-mingw32-g++-posix)
SET(CMAKE_RC_COMPILER i686-w64-mingw32-windres)
# figure out folder to look in
execute_process(COMMAND sh -c "ls /usr/lib/gcc/x86_64-w64-mingw32/ | grep posix | tr -d '\n'" OUTPUT_VARIABLE MINGW_DEPS_FOLDER)
# here is the target environment located
SET(CMAKE_FIND_ROOT_PATH /usr/i686-w64-mingw32 /usr/lib/gcc/i686-w64-mingw32/4.9-posix ${PROJECT_SOURCE_DIR}/dependencies)
SET(CMAKE_FIND_ROOT_PATH /usr/i686-w64-mingw32 /usr/lib/gcc/i686-w64-mingw32/${MINGW_DEPS_FOLDER}/ ${PROJECT_SOURCE_DIR}/dependencies)
# adjust the default behaviour of the FIND_XXX() commands:
# search headers and libraries in the target environment, search

View File

@ -119,6 +119,9 @@ Karts
Objects
- GeekPenguinBR, TuxKartDriver : Models from Las Dunas Stadium
Jymis
- Karts and icons
Minibjorn
- Powerups and baddies (models + icons)
- Explosion and smoke particles
@ -188,6 +191,7 @@ Voice acting
Sound effects
- Mike Koening and soundbible.com
- The Audio Monkey ( http://www.theaudiomonkey.co.uk )
- Battle For Wesnoth
- Iwan 'qubodup' Gabovitch
- The Trigger-Rally project

View File

@ -4,7 +4,7 @@
name="Christoffel Columbus" description="Play every official track at least once." >
<city goal="1"/>
<cocoa_temple goal="1"/>
<farm goal="1"/>
<cornfield_crossing goal="1"/>
<fortmagma goal="1"/>
<gran_paradiso_island goal="1"/>
<greenvalley goal="1"/>

View File

@ -14,6 +14,6 @@
</medium>
<easy>
<karts number="4"/>
<requirements time="275"/>
<requirements time="290"/>
</easy>
</challenge>

View File

@ -14,7 +14,7 @@
</medium>
<easy>
<karts number="5"/>
<requirements position="1" time="105"/>
<requirements position="1" time="130"/>
</easy>
</challenge>

View File

@ -10,8 +10,8 @@
<material file="explode.png" />
<!-- Amount of particles emitted per second -->
<rate min="500"
max="800" />
<rate min="400"
max="600" />
<!-- Minimal and maximal lifetime of a particle, in milliseconds. -->
<lifetime min="1000"

View File

@ -10,8 +10,8 @@
<material file="explode.png" />
<!-- Amount of particles emitted per second -->
<rate min="500"
max="800" />
<rate min="400"
max="600" />
<!-- Minimal and maximal lifetime of a particle, in milliseconds. -->
<lifetime min="1000"

View File

@ -10,8 +10,8 @@
<material file="explode.png" />
<!-- Amount of particles emitted per second -->
<rate min="500"
max="800" />
<rate min="400"
max="600" />
<!-- Minimal and maximal lifetime of a particle, in milliseconds. -->
<lifetime min="1000"

View File

@ -1,9 +1,16 @@
<?xml version="1.0"?>
<graphical-restrictions>
<card is="Intel(R) HD Graphics" os="windows" version="<9.0" disable="ForceLegacyDevice"/>
<card is="Intel(R) HD Graphics" os="windows" version="<9.0" disable="HighDefinitionTextures"/>
<card is="Intel(R) HD Graphics 2000" os="windows" disable="UniformBufferObject"/>
<card is="Intel(R) HD Graphics 2000" os="windows" disable="AdvancedPipeline"/>
<card is="Intel(R) HD Graphics 2000" os="windows" disable="FramebufferSRGBWorking"/>
<card is="Intel(R) HD Graphics 2000" os="windows" disable="HighDefinitionTextures"/>
<card is="Intel(R) HD Graphics 3000" os="windows" disable="UniformBufferObject"/>
<card is="Intel(R) HD Graphics 3000" os="windows" disable="AdvancedPipeline"/>
<card is="Intel(R) HD Graphics 3000" os="windows" disable="FramebufferSRGBWorking"/>
<card is="Intel(R) HD Graphics" os="windows" disable="ForceLegacyDevice"/>
<card is="Intel(R) HD Graphics 3000" os="windows" disable="HighDefinitionTextures"/>
<card is="Intel(R) HD Graphics 4600" os="windows" disable="ComputeShader"/>
<card contains="Intel" os="osx" disable="GI"/>
<card contains="Intel" os="linux" version="<11.2" disable="ComputeShader"/>
<card contains="Intel" os="linux" version="<11.2" disable="GeometryShader"/>
@ -11,7 +18,6 @@
<card contains="Intel" os="linux" version="<11.2" disable="TextureCompressionS3TC"/>
<card contains="Intel" os="windows" disable="TextureCompressionS3TC"/>
<card contains="Intel" os="osx" disable="TextureCompressionS3TC"/>
<card contains="Intel" os="windows" disable="HighDefinitionTextures"/>
<card contains="NVIDIA" os="windows" version="<344.65" disable="BufferStorage"/>
<card contains="NVIDIA" os="linux" version="<343.22" disable="BufferStorage"/>
<card contains="NVIDIA" disable="ShaderAtomicCounters"/>
@ -31,5 +37,6 @@
<card contains="ATI" os="windows" version="<=3.1.8787" disable="ForceLegacyDevice"/>
<card os="android" disable="TextureFormatBGRA8888"/>
<card os="android" disable="ColorBufferFloat"/>
<card contains="Adreno" os="android" version="<=19" disable="VertexIdWorking"/>
<card contains="Android Emulator" os="android" disable="ForceLegacyDevice"/>
</graphical-restrictions>

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 KiB

BIN
data/gui/android/drift.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

View File

@ -0,0 +1,12 @@
# Licensing work
Icons firstly made for SuperTuxKart UI on Android.
Files: blur_bg_button ; blur_bg_button_focus ; directionnal_wheel ; drift ; nitro ; nitro_empty ; pause ; thunderbird_reset ; wing_mirror
- CC BY-SA 4.0 / author: Néd J. Édoire
# License information:
- Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
Visit the following link for detailed informations:
https://creativecommons.org/licenses/by-sa/4.0/

BIN
data/gui/android/nitro.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

BIN
data/gui/android/pause.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -147,16 +147,8 @@
<spacer width="10" height="10"/>
<label text="Texture compression" I18N="Video settings"/>
</div>
<spacer height="4" width="10" />
<div layout="horizontal-row" proportion="1" height="fit">
<checkbox id="hd-textures"/>
<spacer width="10" height="10"/>
<label text="Use high definition textures" I18N="Video settings"/>
</div>
</div>
<spacer height="20" width="10" />
<div layout="horizontal-row" width="100%" proportion="1">
@ -168,9 +160,9 @@
<spacer height="4" width="10" />
<div layout="horizontal-row" width="100%" proportion="1">
<label text="Texture filtering" I18N="Video settings" width="40%"/>
<label text="Rendered image quality" I18N="Video settings" width="40%"/>
<spacer width="10" height="10"/>
<gauge id="filtering" min_value="0" max_value="5" width="50%" />
<gauge id="image_quality" min_value="0" max_value="3" width="50%" />
</div>
<spacer height="4" width="10" />

View File

@ -20,7 +20,7 @@
<box proportion="1" width="100%" layout="vertical-row">
<spacer width="5" height="15"/>
<button id="startTutorial" text="Click here to play the tutorial" align="center"/>
<button id="startTutorial" text="Start the tutorial" align="center"/>
<spacer width="5" height="15"/>
<div width="100%" proportion="2" layout="horizontal-row">

View File

@ -3,60 +3,66 @@
<div x="2%" y="1%" width="96%" height="98%" layout="vertical-row" >
<header id="title" width="100%" height="fit" text_align="center" word_wrap="true" text="Touch Device Settings" />
<spacer height="30" width="10" />
<label width="100%" I18N="In the multitouch settings screen" text="General"/>
<spacer height="35" width="10" />
<spacer height="15" width="10"/>
<div width="75%" height="fit" layout="horizontal-row" >
<label proportion="1" height="100%" text_align="right" I18N="In the multitouch settings screen" text="Device enabled"/>
<div proportion="1" height="fit" layout="horizontal-row" >
<spacer width="40" height="100%" />
<checkbox id="buttons_enabled" width="40" height="40"/>
</div>
</div>
<label width="100%" I18N="In the multitouch settings screen" text="General"/>
<spacer height="15" width="10"/>
<div width="75%" height="fit" layout="horizontal-row" >
<label proportion="1" height="100%" text_align="right" I18N="In the multitouch settings screen" text="Buttons scale"/>
<div proportion="1" height="fit" layout="horizontal-row" >
<spacer width="40" height="100%" />
<gauge id="scale" proportion="1" min_value="50" max_value="150"/>
</div>
</div>
<spacer height="45" width="10"/>
<label width="100%" I18N="In the multitouch settings screen" text="Advanced"/>
<spacer height="15" width="10"/>
<div width="75%" layout="horizontal-row" proportion="1">
<label proportion="1" align="center" text_align="right" I18N="In the multitouch settings screen" text="Device enabled"/>
<div proportion="1" align="center" height="fit" layout="horizontal-row" >
<spacer width="40" height="10" />
<checkbox id="buttons_enabled"/>
</div>
</div>
<div width="75%" height="fit" layout="horizontal-row" >
<label proportion="1" height="100%" text_align="right" I18N="In the multitouch settings screen" text="Deadzone center"/>
<div proportion="1" height="fit" layout="horizontal-row" >
<spacer width="40" height="100%" />
<gauge id="deadzone_center" proportion="1" min_value="0" max_value="50"/>
</div>
</div>
<spacer height="15" width="10"/>
<div width="75%" layout="horizontal-row" proportion="1">
<label proportion="1" align="center" text_align="right" I18N="In the multitouch settings screen" text="Inverted buttons"/>
<div proportion="1" align="center" height="fit" layout="horizontal-row" >
<spacer width="40" height="10" />
<checkbox id="buttons_inverted"/>
</div>
</div>
<div width="75%" height="fit" layout="horizontal-row" >
<label proportion="1" height="100%" text_align="right" I18N="In the multitouch settings screen" text="Deadzone edge"/>
<div proportion="1" height="fit" layout="horizontal-row" >
<spacer width="40" height="100%" />
<gauge id="deadzone_edge" proportion="1" min_value="0" max_value="50"/>
</div>
</div>
<spacer height="45" width="10"/>
<div width="75%" layout="horizontal-row" proportion="1">
<label proportion="1" align="center" text_align="right" I18N="In the multitouch settings screen" text="Buttons scale"/>
<div proportion="1" align="center" height="fit" layout="horizontal-row" >
<spacer width="40" height="10" />
<gauge id="scale" proportion="1" min_value="50" max_value="150"/>
</div>
</div>
<button id="restore" text="Restore defaults" align="center"/>
<spacer height="15" width="10"/>
<button id="close" text="Apply" align="center"/>
<div width="75%" layout="horizontal-row" proportion="1">
<label proportion="1" align="center" text_align="right" I18N="In the multitouch settings screen" text="Accelerometer"/>
<div proportion="1" align="center" height="fit" layout="horizontal-row" >
<spacer width="40" height="10" />
<spinner id="accelerometer" proportion="1"/>
</div>
</div>
<label width="100%" I18N="In the multitouch settings screen" text="Advanced"/>
<div width="75%" layout="horizontal-row" proportion="1">
<label proportion="1" align="center" text_align="right" I18N="In the multitouch settings screen" text="Deadzone center"/>
<div proportion="1" align="center" height="fit" layout="horizontal-row" >
<spacer width="40" height="10" />
<gauge id="deadzone_center" proportion="1" min_value="0" max_value="50"/>
</div>
</div>
<div width="75%" layout="horizontal-row" proportion="1">
<label proportion="1" align="center" text_align="right" I18N="In the multitouch settings screen" text="Deadzone edge"/>
<div proportion="1" align="center" height="fit" layout="horizontal-row" >
<spacer width="40" height="10" />
<gauge id="deadzone_edge" proportion="1" min_value="0" max_value="50"/>
</div>
</div>
<spacer height="35" width="10"/>
<div width="fit" height="fit" layout="horizontal-row" align="center" proportion="1">
<button id="restore" text="Restore defaults"/>
<spacer width="40" height="10" />
<button id="close" text="Apply"/>
</div>
</div>
</stkgui>

View File

@ -34,7 +34,7 @@
http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?f=9&t=7369\&p=25236&hilit=vehicle#p25236
for details.
max-force: Maximum suspension force -->
<suspension stiffness="140" rest="0.3" travel="0.29"
<suspension stiffness="280" rest="0.3" travel="0.29"
exp-spring-response="false" max-force="12000" />
<!-- Values related to stability of the chassis: damping, and reduced
@ -45,6 +45,9 @@
the ground if its off ground. Reduces the affect if a kart loses
contact with the ground (i.e. it then can't steer or accelerate
anymore).
angular-factor: Factor to change angular impulses. X and Z rotations
are damped to avoid that karts in a collision are too easily pushed
into a roll or pitch, which makes them topple over
smooth-flying-impulse: apply a torque impulse to flying kart to keep
them parallel to the ground. -->
<stability roll-influence="0.3"
@ -52,6 +55,7 @@
chassis-angular-damping="0"
downward-impulse-factor="5"
track-connection-accel="2"
angular-factor="0.5 1.0 0.5"
smooth-flying-impulse="250" />
<!-- Turning
@ -120,6 +124,8 @@
<rear-left position="-0.38 0 -0.6" />
</wheels>
<!-- Friction of a kart when e.g. sliding along a wall. -->
<friction kart-friction="0.0" />
<!-- ********** Visuals ********** -->
@ -202,16 +208,21 @@
friction: The friction increase when a parachute is attached.
duration: The time an attached parachute is active
duration-other: The time a parachute attached from other kart works
duration-rank-mult: The multiplier applied to the duration of the
parachute on the 1st kart when affected by the item. Scale for
intermediary ranks to 1.0 for the last affected.
duration-speed-mult: Applied in all cases, multitplier to duration
of the parachute at max-speed. Scale to 1.0 at 0 speed.
lbound-fraction: The lower bound fraction of speed when lost will
detach parachute. E.g. at nearly 0 speed, only 5% of speed
detach parachute. E.g. at nearly 0 speed, only 20% of speed
need to be lost.
ubound-fraction: The upper bound fraction of speed when lost will
detach parachute. E.g. at max-speed 30% of speed must be lost.
detach parachute. E.g. at max-speed 50% of speed must be lost.
max-speed: A factor that decides the impact of rate of speed
(distance between bounds) -->
<parachute friction="2.0" duration="4.0" duration-other="8.0"
lbound-fraction="0.95" ubound-fraction="0.7" max-speed="23" />
<parachute friction="2.0" duration="2.0" duration-other="2.6"
duration-rank-mult="1.35" duration-speed-mult="2.0"
lbound-fraction="0.8" ubound-fraction="0.5" max-speed="23" />
<!-- Bubblegum
duration: How long the bubblegum lasts.
speed-fraction: To what fraction of top-speed the speed is reduced.

View File

@ -2,7 +2,7 @@ uniform mat4 ModelViewMatrix;
uniform vec3 Position;
uniform vec2 Size;
#if __VERSION__ >= 330
#ifdef Explicit_Attrib_Location_Usable
layout(location = 0) in vec2 Corner;
layout(location = 3) in vec2 Texcoord;
#else

View File

@ -1,7 +1,7 @@
uniform vec2 center;
uniform vec2 size;
#if __VERSION__ >= 330
#ifdef Explicit_Attrib_Location_Usable
layout(location = 0) in vec2 Position;
#else
in vec2 Position;
@ -11,4 +11,4 @@ in vec2 Position;
void main()
{
gl_Position = vec4(Position * size + center, 0., 1.);
}
}

View File

@ -3,14 +3,14 @@ uniform vec2 size;
uniform vec2 texcenter;
uniform vec2 texsize;
#if __VERSION__ >= 330
#ifdef Explicit_Attrib_Location_Usable
layout(location=0) in vec2 Position;
layout(location=3) in vec2 Texcoord;
layout(location=2) in uvec4 Color;
layout(location=2) in vec4 Color;
#else
in vec2 Position;
in vec2 Texcoord;
in uvec4 Color;
in vec4 Color;
#endif
out vec2 uv;
@ -18,7 +18,7 @@ out vec4 col;
void main()
{
col = vec4(Color) / 255.;
col = Color.zyxw;
uv = Texcoord * texsize + texcenter;
gl_Position = vec4(Position * size + center, 0., 1.);
}

View File

@ -23,7 +23,6 @@ void main(void)
#endif
#endif
vec4 detail = texture(Detail, uv_bis);
detail.xyz = pow(detail.xyz, vec3(2.2));
detail.rgb = detail.a * detail.rgb;
color.rgb = detail.rgb + color.rgb * (1. - detail.a);
float specmap = texture(SpecMap, uv).g;

View File

@ -1,6 +1,6 @@
uniform mat4 ModelMatrix;
#if __VERSION__ >= 330
#ifdef Explicit_Attrib_Location_Usable
layout(location = 0) in vec3 Position;
layout(location = 3) in vec2 Texcoord;
layout(location = 4) in vec2 SecondTexcoord;

View File

@ -1,4 +1,4 @@
#if __VERSION__ >= 330
#ifdef Explicit_Attrib_Location_Usable
layout(location=0) in vec3 Position;
layout(location = 1) in float lifetime;
layout(location = 2) in float size;

View File

@ -1,4 +1,4 @@
#if __VERSION__ >= 330
#ifdef Explicit_Attrib_Location_Usable
layout(location = 0) in vec3 Position;
layout(location = 7) in vec3 Origin;
layout(location = 8) in vec3 Orientation;

View File

@ -2,7 +2,7 @@ uniform vec3 windDir;
uniform mat4 ModelMatrix;
uniform mat4 InverseModelMatrix;
#if __VERSION__ >= 330
#ifdef Explicit_Attrib_Location_Usable
layout(location = 0) in vec3 Position;
layout(location = 1) in vec3 Normal;
layout(location = 2) in vec4 Color;
@ -20,13 +20,16 @@ out vec2 uv;
void main()
{
vec3 test = sin(windDir * (Position.y* 0.5)) * 0.5;
test += cos(windDir) * 0.7;
mat4 new_model_matrix = ModelMatrix;
mat4 new_inverse_model_matrix = InverseModelMatrix;
new_model_matrix[3].xyz += windDir * Color.r;
new_model_matrix[3].xyz += test * Color.r;
// FIXME doesn't seem to make too much difference in pass 2, because this
// affects "nor" which is later only * 0.1 by scattering
new_inverse_model_matrix[3].xyz -= windDir * Color.r;
new_inverse_model_matrix[3].xyz -= test * Color.r;
mat4 ModelViewProjectionMatrix = ProjectionViewMatrix * new_model_matrix;
mat4 TransposeInverseModelView = transpose(InverseViewMatrix * new_inverse_model_matrix);

View File

@ -29,7 +29,6 @@ void main(void)
vec4 detail = texture(Detail, uv_bis);
float specmap = texture(SpecMap, uv).g;
#endif
detail.xyz = pow(detail.xyz, vec3(2.2));
detail.rgb = detail.a * detail.rgb;
color.rgb = detail.rgb + color.rgb * (1. - detail.a);
FragColor = vec4(getLightFactor(color.xyz, vec3(1.), specmap, 0.), 1.);

View File

@ -1,6 +1,6 @@
uniform vec3 windDir;
#if __VERSION__ >= 330
#ifdef Explicit_Attrib_Location_Usable
layout(location = 0) in vec3 Position;
layout(location = 1) in vec3 Normal;
layout(location = 2) in vec4 Color;
@ -41,8 +41,10 @@ flat out sampler2D thirdhandle;
void main()
{
mat4 ModelMatrix = getWorldMatrix(Origin + windDir * Color.r, Orientation, Scale);
mat4 TransposeInverseModelView = transpose(getInverseWorldMatrix(Origin + windDir * Color.r, Orientation, Scale) * InverseViewMatrix);
vec3 test = sin(windDir * (Position.y* 0.5)) * 0.5;
test += cos(windDir) * 0.7;
mat4 ModelMatrix = getWorldMatrix(Origin + test * Color.r, Orientation, Scale);
mat4 TransposeInverseModelView = transpose(getInverseWorldMatrix(Origin + test * Color.r, Orientation, Scale) * InverseViewMatrix);
gl_Position = ProjectionViewMatrix * ModelMatrix * vec4(Position, 1.);
nor = (TransposeInverseModelView * vec4(Normal, 0.)).xyz;
uv = Texcoord;

View File

@ -1,7 +1,7 @@
uniform int layer;
uniform vec3 windDir;
#if __VERSION__ >= 330
#ifdef Explicit_Attrib_Location_Usable
layout(location = 0) in vec3 Position;
layout(location = 2) in vec4 Color;
layout(location = 3) in vec2 Texcoord;
@ -40,17 +40,20 @@ flat out uvec2 hdle;
void main(void)
{
vec3 test = sin(windDir * (Position.y* 0.5)) * 0.5;
test += cos(windDir) * 0.7;
mat4 ModelMatrix = getWorldMatrix(Origin, Orientation, Scale);
#ifdef VSLayer
gl_Layer = layer;
gl_Position = ShadowViewProjMatrixes[gl_Layer] * ModelMatrix * vec4(Position + windDir * Color.r, 1.);
gl_Position = ShadowViewProjMatrixes[gl_Layer] * ModelMatrix * vec4(Position + test * Color.r, 1.);
uv = Texcoord;
#ifdef Use_Bindless_Texture
handle = Handle;
#endif
#else
layerId = layer;
gl_Position = ShadowViewProjMatrixes[layerId] * ModelMatrix * vec4(Position + windDir * Color.r, 1.);
gl_Position = ShadowViewProjMatrixes[layerId] * ModelMatrix * vec4(Position + test * Color.r, 1.);
tc = Texcoord;
#ifdef Use_Bindless_Texture
hdle = Handle;

View File

@ -1,4 +1,4 @@
#if __VERSION__ >= 330
#ifdef Explicit_Attrib_Location_Usable
layout(location = 0) in vec3 Position;
layout(location = 1) in vec3 Normal;
layout(location = 2) in vec4 Color;

View File

@ -1,6 +1,6 @@
uniform int layer;
#if __VERSION__ >= 330
#ifdef Explicit_Attrib_Location_Usable
layout(location = 0) in vec3 Position;
layout(location = 3) in vec2 Texcoord;

View File

@ -1,4 +1,4 @@
#if __VERSION__ >= 330
#ifdef Explicit_Attrib_Location_Usable
layout(location = 0) in vec3 Position;
layout(location = 1) in vec3 Normal;
layout(location = 2) in vec4 Color;

View File

@ -1,6 +1,6 @@
uniform int layer;
#if __VERSION__ >= 330
#ifdef Explicit_Attrib_Location_Usable
layout(location = 0) in vec3 Position;
layout(location = 3) in vec4 Data1;
layout(location = 5) in ivec4 Joint;

View File

@ -18,15 +18,15 @@ precision mediump float;
uniform int uMaterialType;
uniform bool uTextureUsage0;
uniform bool uTextureUsage1;
//uniform bool uTextureUsage1;
uniform sampler2D uTextureUnit0;
uniform sampler2D uTextureUnit1;
//uniform sampler2D uTextureUnit1;
/* Varyings */
varying vec2 varTexCoord0;
varying vec2 varTexCoord1;
//varying vec2 varTexCoord1;
varying vec4 varVertexColor;
varying float varEyeDist;
@ -37,7 +37,7 @@ vec4 renderSolid()
if(uTextureUsage0)
Color *= texture2D(uTextureUnit0, varTexCoord0);
Color.a = 1.0;
//Color.a = 1.0;
return Color;
}
@ -47,9 +47,10 @@ vec4 render2LayerSolid()
float BlendFactor = varVertexColor.a;
vec4 Texel0 = texture2D(uTextureUnit0, varTexCoord0);
vec4 Texel1 = texture2D(uTextureUnit1, varTexCoord1);
//vec4 Texel1 = texture2D(uTextureUnit1, varTexCoord1);
vec4 Color = Texel0 * BlendFactor + Texel1 * (1.0 - BlendFactor);
vec4 Color = Texel0 * BlendFactor;
//vec4 Color += Texel1 * (1.0 - BlendFactor);
return Color;
}
@ -57,9 +58,10 @@ vec4 render2LayerSolid()
vec4 renderLightMap()
{
vec4 Texel0 = texture2D(uTextureUnit0, varTexCoord0);
vec4 Texel1 = texture2D(uTextureUnit1, varTexCoord1);
//vec4 Texel1 = texture2D(uTextureUnit1, varTexCoord1);
vec4 Color = Texel0 * Texel1 * 4.0;
vec4 Color = Texel0 * 4.0;
//Color *= Texel1;
Color.a = Texel0.a * Texel0.a;
return Color;
@ -68,10 +70,10 @@ vec4 renderLightMap()
vec4 renderDetailMap()
{
vec4 Texel0 = texture2D(uTextureUnit0, varTexCoord0);
vec4 Texel1 = texture2D(uTextureUnit1, varTexCoord1);
//vec4 Texel1 = texture2D(uTextureUnit1, varTexCoord1);
vec4 Color = Texel0;
Color += Texel1 - 0.5;
//Color += Texel1 - 0.5;
return Color;
}
@ -81,9 +83,10 @@ vec4 renderReflection2Layer()
vec4 Color = varVertexColor;
vec4 Texel0 = texture2D(uTextureUnit0, varTexCoord0);
vec4 Texel1 = texture2D(uTextureUnit1, varTexCoord1);
//vec4 Texel1 = texture2D(uTextureUnit1, varTexCoord1);
Color *= Texel0 * Texel1;
Color *= Texel0;
//Color *= Texel1;
return Color;
}
@ -105,7 +108,7 @@ void main ()
else if(uMaterialType == Solid2Layer)
gl_FragColor = render2LayerSolid();
else if(uMaterialType == LightMap)
gl_FragColor = renderLightMap();
gl_FragColor = renderSolid();
else if(uMaterialType == DetailMap)
gl_FragColor = renderDetailMap();
else if(uMaterialType == SphereMap)

View File

@ -4,33 +4,31 @@ attribute vec3 inVertexPosition;
attribute vec3 inVertexNormal;
attribute vec4 inVertexColor;
attribute vec2 inTexCoord0;
attribute vec2 inTexCoord1;
//attribute vec2 inTexCoord1;
/* Uniforms */
uniform int uMaterialType;
uniform mat4 uMvpMatrix;
uniform mat4 uTextureMatrix0;
uniform mat4 uTextureMatrix1;
//uniform mat4 uTextureMatrix1;
/* Varyings */
varying vec2 varTexCoord0;
varying vec2 varTexCoord1;
//varying vec2 varTexCoord1;
varying vec4 varVertexColor;
varying float varEyeDist;
void main(void)
{
gl_Position = uMvpMatrix * vec4(inVertexPosition,1.0);
vec4 TexCoord0 = vec4(inTexCoord0.x, inTexCoord0.y, 0.0, 0.0);
varTexCoord0 = vec4(uTextureMatrix0 * TexCoord0).xy;
vec4 TexCoord1 = vec4(inTexCoord1.x, inTexCoord1.y, 0.0, 0.0);
varTexCoord1 = vec4(uTextureMatrix1 * TexCoord1).xy;
//vec4 TexCoord1 = vec4(inTexCoord1.x, inTexCoord1.y, 0.0, 0.0);
//varTexCoord1 = vec4(uTextureMatrix1 * TexCoord1).xy;
varVertexColor = inVertexColor.zyxw;
}

View File

@ -17,7 +17,7 @@ uniform mat4 InverseModelMatrix =
uniform vec2 texture_trans = vec2(0., 0.);
#endif
#if __VERSION__ >= 330
#ifdef Explicit_Attrib_Location_Usable
layout(location = 0) in vec3 Position;
layout(location = 1) in vec3 Normal;
layout(location = 2) in vec4 Color;

View File

@ -40,7 +40,11 @@ void main(void)
col = vec4(new_color.r, new_color.g, new_color.b, col.a);
}
#if defined(GL_ES) && !defined(Advanced_Lighting_Enabled)
col.xyz *= color.xyz;
#else
col.xyz *= pow(color.xyz, vec3(2.2));
#endif
float specmap = texture(SpecMap, uv).g;
float emitmap = texture(SpecMap, uv).b;
FragColor = vec4(getLightFactor(col.xyz, vec3(1.), specmap, emitmap), 1.);

View File

@ -16,7 +16,13 @@ void main(void)
col.xyz = pow(col.xyz, vec3(2.2));
#endif
#endif
col.xyz *= pow(color.xyz, vec3(2.2));
if (col.a < 0.5) discard;
#if defined(GL_ES) && !defined(Advanced_Lighting_Enabled)
col.xyz *= color.xyz;
#else
col.xyz *= pow(color.xyz, vec3(2.2));
#endif
FragColor = vec4(col.xyz, 1.);
}

View File

@ -25,8 +25,13 @@ void main(void)
col.xyz = pow(col.xyz, vec3(2.2));
#endif
#endif
col.xyz *= pow(color.xyz, vec3(2.2));
if (col.a * color.a < 0.5) discard;
#if defined(GL_ES) && !defined(Advanced_Lighting_Enabled)
col.xyz *= color.xyz;
#else
col.xyz *= pow(color.xyz, vec3(2.2));
#endif
float mask = texture(colorization_mask, uv).a;
if (color_change.x > 0.0)

View File

@ -1,7 +1,7 @@
uniform vec3 color_from;
uniform vec3 color_to;
#if __VERSION__ >= 330
#ifdef Explicit_Attrib_Location_Usable
layout(location=0) in vec3 Position;
layout(location = 1) in float lifetime;
layout(location = 2) in float size;

View File

@ -9,7 +9,7 @@ uniform float track_x_len;
uniform float track_z_len;
uniform samplerBuffer heightmap;
#if __VERSION__ >= 330
#ifdef Explicit_Attrib_Location_Usable
layout (location = 4) in vec3 particle_position_initial;
layout (location = 5) in float lifetime_initial;
layout (location = 6) in vec3 particle_velocity_initial;

View File

@ -4,7 +4,7 @@ uniform mat4 sourcematrix;
uniform int level;
uniform float size_increase_factor;
#if __VERSION__ >= 330
#ifdef Explicit_Attrib_Location_Usable
layout (location = 4) in vec3 particle_position_initial;
layout (location = 5) in float lifetime_initial;
layout (location = 6) in vec3 particle_velocity_initial;
@ -14,6 +14,11 @@ layout (location = 0) in vec3 particle_position;
layout (location = 1) in float lifetime;
layout (location = 2) in vec3 particle_velocity;
layout (location = 3) in float size;
#ifdef Needs_Vertex_Id_Workaround
layout (location = 8) in int vertex_id;
#endif
#else
in vec3 particle_position_initial;
in float lifetime_initial;
@ -24,6 +29,11 @@ in vec3 particle_position;
in float lifetime;
in vec3 particle_velocity;
in float size;
#ifdef Needs_Vertex_Id_Workaround
in int vertex_id;
#endif
#endif
out vec3 new_particle_position;
@ -36,18 +46,22 @@ void main(void)
float updated_lifetime = lifetime + (float(dt)/lifetime_initial);
if (updated_lifetime > 1.)
{
#ifdef Needs_Vertex_Id_Workaround
if (vertex_id < level)
#else
if (gl_VertexID < level)
#endif
{
float dt_from_last_frame = fract(updated_lifetime) * lifetime_initial;
float coeff = dt_from_last_frame / float(dt);
vec4 previous_frame_position = previous_frame_sourcematrix * vec4(particle_position_initial, 1.0);
vec4 current_frame_position = sourcematrix * vec4(particle_position_initial, 1.0);
vec4 updated_initialposition = mix(current_frame_position,
previous_frame_position,
coeff);
vec4 updated_initial_velocity = mix(sourcematrix * vec4(particle_velocity_initial, 0.0),
previous_frame_sourcematrix * vec4(particle_velocity_initial, 0.0),
coeff);
@ -56,12 +70,12 @@ void main(void)
//But the simple formula ( (current_frame_position - previous_frame_position) / dt ) with a constant speed
//between 2 frames creates visual artifacts when the framerate is low, and a more accurate formula would need
//more complex computations.
new_particle_position = updated_initialposition.xyz + dt_from_last_frame * updated_initial_velocity.xyz;
new_particle_velocity = updated_initial_velocity.xyz;
new_lifetime = fract(updated_lifetime);
new_size = mix(size_initial, size_initial * size_increase_factor, fract(updated_lifetime));
new_size = mix(size_initial, size_initial * size_increase_factor, fract(updated_lifetime));
}
else
{

View File

@ -1,4 +1,4 @@
#if __VERSION__ >= 330
#ifdef Explicit_Attrib_Location_Usable
layout(location = 0) in vec3 Position;
layout(location = 1) in vec3 Normal;
layout(location = 2) in vec4 Color;

View File

@ -2,7 +2,7 @@ uniform mat4 ModelMatrix;
uniform mat4 RSMMatrix;
uniform vec2 texture_trans = vec2(0., 0.);
#if __VERSION__ >= 330
#ifdef Explicit_Attrib_Location_Usable
layout(location = 0) in vec3 Position;
layout(location = 1) in vec3 Normal;
layout(location = 2) in vec4 Color;

View File

@ -1,4 +1,4 @@
#if __VERSION__ >= 330
#ifdef Explicit_Attrib_Location_Usable
layout(location = 0) in vec2 Position;
layout(location = 3) in vec2 Texcoord;
#else

View File

@ -1,7 +1,7 @@
uniform int layer;
uniform mat4 ModelMatrix;
#if __VERSION__ >= 330
#ifdef Explicit_Attrib_Location_Usable
layout(location = 0) in vec3 Position;
layout(location = 3) in vec2 Texcoord;
#else

View File

@ -2,7 +2,7 @@ uniform int layer;
uniform mat4 ModelMatrix;
uniform vec3 windDir;
#if __VERSION__ >= 330
#ifdef Explicit_Attrib_Location_Usable
layout(location = 0) in vec3 Position;
layout(location = 2) in vec4 Color;
layout(location = 3) in vec2 Texcoord;
@ -21,13 +21,17 @@ out int layerId;
void main(void)
{
vec3 test = sin(windDir * (Position.y* 0.5)) * 0.5;
test += cos(windDir) * 0.7;
#ifdef VSLayer
gl_Layer = layer;
uv = Texcoord;
gl_Position = ShadowViewProjMatrixes[gl_Layer] * ModelMatrix * vec4(Position + windDir * Color.r, 1.);
gl_Position = ShadowViewProjMatrixes[gl_Layer] * ModelMatrix * vec4(Position + test * Color.r, 1.);
#else
layerId = layer;
tc = Texcoord;
gl_Position = ShadowViewProjMatrixes[layerId] * ModelMatrix * vec4(Position + windDir * Color.r, 1.);
gl_Position = ShadowViewProjMatrixes[layerId] * ModelMatrix * vec4(Position + test * Color.r, 1.);
#endif
}

View File

@ -18,7 +18,7 @@ uniform vec2 texture_trans = vec2(0., 0.);
#endif
uniform int skinning_offset;
#if __VERSION__ >= 330
#ifdef Explicit_Attrib_Location_Usable
layout(location = 0) in vec3 Position;
layout(location = 1) in vec3 Normal;
layout(location = 2) in vec4 Color;

View File

@ -2,7 +2,7 @@ uniform mat4 ModelMatrix;
uniform int skinning_offset;
uniform int layer;
#if __VERSION__ >= 330
#ifdef Explicit_Attrib_Location_Usable
layout(location = 0) in vec3 Position;
layout(location = 3) in vec4 Data1;
layout(location = 5) in ivec4 Joint;

View File

@ -1,4 +1,4 @@
#if __VERSION__ >= 330
#ifdef Explicit_Attrib_Location_Usable
layout(location = 0) in vec3 Position;
#else
in vec3 Position;

View File

@ -35,7 +35,11 @@ float getShadowFactor(vec3 pos, int index)
for (float i = -1.; i <= 1.; i += 1.)
{
for (float j = -1.; j <= 1.; j += 1.)
result += texture(shadowtex, vec4(shadowtexcoord + vec2(i,j) / shadow_res, float(index), d));
{
// result += texture(shadowtex, vec4(shadowtexcoord + vec2(i,j) / shadow_res, float(index), d));
// Added a hack with j+1. to avoid ugly lines
result += texture(shadowtex, vec4(shadowtexcoord + vec2(i,j+1.) / shadow_res, float(index), d));
}
}
return result / 9.;

View File

@ -3,7 +3,7 @@ uniform vec2 size;
uniform vec2 texcenter;
uniform vec2 texsize;
#if __VERSION__ >= 330
#ifdef Explicit_Attrib_Location_Usable
layout(location=0) in vec2 Position;
layout(location=3) in vec2 Texcoord;
#else
@ -17,4 +17,4 @@ void main()
{
uv = Texcoord * texsize + texcenter;
gl_Position = vec4(Position * size + center, 0., 1.);
}
}

View File

@ -13,7 +13,9 @@ void main()
// Uncharted2 tonemap with Auria's custom coefficients
vec4 perChannel = (col * (6.9 * col + .5)) / (col * (5.2 * col + 1.7) + 0.06);
#if !(defined(GL_ES) && defined(Advanced_Lighting_Enabled))
perChannel = pow(perChannel, vec4(2.2));
#endif
vec2 inside = uv - 0.5;
float vignette = 1. - dot(inside, inside) * vignette_weight;

View File

@ -16,12 +16,51 @@
<!-- Scores are the number of points given when the race ends. -->
<grand-prix>
<!-- Karts on position 1 and 2 will have 3 more points than the next kart;
a kart on position 3 and 4 will have two more points than the next;
and all remaining karts will have one more point than the next. -->
<points from="1" to="2" points="3"/>
<points from="3" to="4" points="2"/>
<points from="5" points="1"/>
<!-- Establish the distribution of points in GP.
For a race of N karts ; the N-first point values are taken.
Then, they are sorted. E.g. ; 0 1 2 1 3 2 becomes 0 1 1 2 2 3.
Then these numbers are used to establish the DIFFERENCE of points
between consecutive karts.
The smaller of the numbers is used to establish the score for the
last kart and not the difference between 2 karts.
In the above example, the last kart will have 0 point, the one before
before 1 (0+1) ; the one before 2 (0+1+1), the one before 4 (0+1+1+2),
etc. until the 1st which have 9 (0+1+1+2+2+3)
There shall be at least as much points nodes as max-numbers kart -->
<points points="0" /> <!-- added with 1 kart, score for the last kart -->
<points points="1" /> <!-- added with 2 karts -->
<points points="1" /> <!-- added with 3 karts -->
<points points="2" /> <!-- added with 4 karts -->
<points points="2" /> <!-- added with 5 karts -->
<points points="1" /> <!-- added with 6 karts -->
<points points="3" /> <!-- added with 7 karts -->
<points points="2" /> <!-- added with 8 karts -->
<points points="3" /> <!-- added with 9 karts -->
<points points="1" /> <!-- added with 10 karts -->
<points points="4" /> <!-- added with 11 karts -->
<points points="2" /> <!-- added with 12 karts -->
<points points="1" /> <!-- added with 13 karts -->
<points points="3" /> <!-- added with 14 karts -->
<points points="2" /> <!-- added with 15 karts -->
<points points="1" /> <!-- added with 16 karts -->
<points points="4" /> <!-- added with 17 karts -->
<points points="2" /> <!-- added with 18 karts -->
<points points="3" /> <!-- added with 19 karts -->
<points points="1" /> <!-- added with 20 karts -->
<points points="5" /> <!-- added with 21 karts -->
<points points="2" /> <!-- added with 22 karts -->
<points points="1" /> <!-- added with 23 karts -->
<points points="3" /> <!-- added with 24 karts -->
<points points="4" /> <!-- added with 25 karts -->
<points points="1" /> <!-- added with 26 karts -->
<points points="2" /> <!-- added with 27 karts -->
<points points="1" /> <!-- added with 28 karts -->
<points points="3" /> <!-- added with 29 karts -->
<points points="5" /> <!-- added with 30 karts -->
</grand-prix>
<!-- Time in follow-the-leader after which karts are removed.
@ -53,9 +92,15 @@
case (all three normals discarded, the interpolation will just
return the normal of the triangle (i.e. de facto no interpolation),
but it helps making smoothing much more useful without fixing tracks.
default-track-friction: Default friction to be used for the track and
any track/library pbject.
default-moveable-friction: Default friction to be used for any moveable,
e.g. karts, bowling balls, ...
-->
<physics smooth-normals="true"
smooth-angle-limit="0.65"/>
smooth-angle-limit="0.65"
default-track-friction="0.5"
default-moveable-friction="0.5" />
<!-- The title music. -->
<music title="main_theme.music"/>
@ -353,7 +398,7 @@
outside of the chassis and results in more stable physical
behaviour of the karts. -->
<collision impulse-type="normal"
impulse="3000" impulse-time="0.1" terrain-impulse="1600"
impulse="3000" impulse-time="0.1" terrain-impulse="160"
restitution="1.0" bevel-factor="0.5 0.0 0.7"
physical-wheel-position="-1" />

View File

@ -2,6 +2,7 @@
Name=SuperTuxKart
Icon=supertuxkart
GenericName=A kart racing game
GenericName[da]=Et kart racerspil
GenericName[de]=Ein Kart-Rennspiel
GenericName[fr]=Un jeu de karting
GenericName[gl]=Xogo de carreiras con karts

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

BIN
data/supertuxkart_48.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

View File

@ -18,6 +18,6 @@ add_library(glew STATIC
src/glew.c src/glewinfo.c
)
target_link_libraries(glew ${OPENGL_LIBRARIES})
target_link_libraries(glew ${OPENGL_gl_LIBRARY})
endif()

View File

@ -14064,6 +14064,9 @@ GLenum glxewContextInit (GLXEW_CONTEXT_ARG_DEF_LIST)
GLXEW_VERSION_1_2 = GL_TRUE;
GLXEW_VERSION_1_3 = GL_TRUE;
GLXEW_VERSION_1_4 = GL_TRUE;
/* Check if GLX display is available */
if (glXGetCurrentDisplay == NULL || glXGetCurrentDisplay() == NULL)
return GLEW_OK;
/* query GLX version */
glXQueryVersion(glXGetCurrentDisplay(), &major, &minor);
if (major == 1 && minor <= 3)

View File

@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 2.6)
if (UNIX OR MINGW)
add_definitions(-O3)
endif()
add_library(graphics_utils STATIC
mipmap/cpusimd.c
mipmap/imgresize.c
)

View File

@ -0,0 +1,571 @@
/* -----------------------------------------------------------------------------
*
* Copyright (c) 2008-2016 Alexis Naveros.
*
*
* The SIMD trigonometry functions are Copyright (C) 2007 Julien Pommier
* See copyright notice for simd4f_sin_ps(), simd4f_cos_ps(), simd4f_sincos_ps()
*
*
* Some functions are Copyright (C) 2008 José Fonseca
* See copyright notice for simd4f_exp2_ps(), simd4f_log2_ps(), simd4f_pow_ps()
*
*
* Portions developed under contract to the SURVICE Engineering Company.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
* -----------------------------------------------------------------------------
*/
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <math.h>
#include <float.h>
#include <limits.h>
#include "cpusimd.h"
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
////
#if CPU_SSE_SUPPORT
const uint32_t CPU_ALIGN16 simd4fSignMask[4] = { 0x80000000, 0x80000000, 0x80000000, 0x80000000 };
const uint32_t CPU_ALIGN16 simd4fSignMaskInv[4] = { 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff };
const float CPU_ALIGN16 simd4fHalf[4] = { 0.5, 0.5, 0.5, 0.5 };
const float CPU_ALIGN16 simd4fOne[4] = { 1.0, 1.0, 1.0, 1.0 };
const float CPU_ALIGN16 simd4fTwo[4] = { 2.0, 2.0, 2.0, 2.0 };
const float CPU_ALIGN16 simd4fThree[4] = { 3.0, 3.0, 3.0, 3.0 };
const uint32_t CPU_ALIGN16 simd4uOne[4] = { 1, 1, 1, 1 };
const uint32_t CPU_ALIGN16 simd4uOneInv[4] = { ~1, ~1, ~1, ~1 };
const uint32_t CPU_ALIGN16 simd4uTwo[4] = { 2, 2, 2, 2 };
const uint32_t CPU_ALIGN16 simd4uFour[4] = { 4, 4, 4, 4 };
const float CPU_ALIGN16 simd4fQuarter[4] = { 0.25, 0.25, 0.25, 0.25 };
const float CPU_ALIGN16 simd4fPi[4] = { M_PI, M_PI, M_PI, M_PI };
const float CPU_ALIGN16 simd4fZeroOneTwoThree[4] = { 0.0, 1.0, 2.0, 3.0 };
const uint32_t CPU_ALIGN16 simd4fAlphaMask[4] = { 0x00000000, 0x00000000, 0x00000000, 0xffffffff };
const float CPU_ALIGN16 simd4f255[4] = { 255.0f, 255.0f, 255.0f, 255.0f };
const float CPU_ALIGN16 simd4f255Inv[4] = { 1.0f/255.0f, 1.0f/255.0f, 1.0f/255.0f, 1.0f/255.0f };
#endif
////
#if CPU_SSE2_SUPPORT
/* Copyright (C) 2007 Julien Pommier
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
(this is the zlib license)
*/
static const float CPU_ALIGN16 simd4f_cephes_FOPI[4] = { 1.27323954473516, 1.27323954473516, 1.27323954473516, 1.27323954473516 };
static const float CPU_ALIGN16 simd4f_minus_cephes_DP1[4] = { -0.78515625, -0.78515625, -0.78515625, -0.78515625 };
static const float CPU_ALIGN16 simd4f_minus_cephes_DP2[4] = { -2.4187564849853515625e-4, -2.4187564849853515625e-4, -2.4187564849853515625e-4, -2.4187564849853515625e-4 };
static const float CPU_ALIGN16 simd4f_minus_cephes_DP3[4] = { -3.77489497744594108e-8, -3.77489497744594108e-8, -3.77489497744594108e-8, -3.77489497744594108e-8 };
static const float CPU_ALIGN16 simd4f_sincof_p0[4] = { -1.9515295891E-4, -1.9515295891E-4, -1.9515295891E-4, -1.9515295891E-4 };
static const float CPU_ALIGN16 simd4f_sincof_p1[4] = { 8.3321608736E-3, 8.3321608736E-3, 8.3321608736E-3, 8.3321608736E-3 };
static const float CPU_ALIGN16 simd4f_sincof_p2[4] = { -1.6666654611E-1, -1.6666654611E-1, -1.6666654611E-1, -1.6666654611E-1 };
static const float CPU_ALIGN16 simd4f_coscof_p0[4] = { 2.443315711809948E-005, 2.443315711809948E-005, 2.443315711809948E-005, 2.443315711809948E-005 };
static const float CPU_ALIGN16 simd4f_coscof_p1[4] = { -1.388731625493765E-003, -1.388731625493765E-003, -1.388731625493765E-003, -1.388731625493765E-003 };
static const float CPU_ALIGN16 simd4f_coscof_p2[4] = { 4.166664568298827E-002, 4.166664568298827E-002, 4.166664568298827E-002, 4.166664568298827E-002 };
__m128 simd4f_sin_ps( __m128 x )
{
__m128 xmm1, xmm2, xmm3, sign_bit, y;
__m128i emm0, emm2;
xmm2 = _mm_setzero_ps();
sign_bit = x;
/* take the absolute value */
x = _mm_and_ps( x, *(__m128 *)simd4fSignMaskInv );
/* extract the sign bit (upper one) */
sign_bit = _mm_and_ps(sign_bit, *(__m128 *)simd4fSignMask);
/* scale by 4/Pi */
y = _mm_mul_ps(x, *(__m128 *)simd4f_cephes_FOPI);
/* store the integer part of y in mm0 */
emm2 = _mm_cvttps_epi32(y);
/* j=(j+1) & (~1) (see the cephes sources) */
emm2 = _mm_add_epi32(emm2, *(__m128i*)simd4uOne);
emm2 = _mm_and_si128(emm2, *(__m128i*)simd4uOneInv);
y = _mm_cvtepi32_ps(emm2);
/* get the swap sign flag */
emm0 = _mm_and_si128(emm2, *(__m128i*)simd4uFour);
emm0 = _mm_slli_epi32(emm0, 29);
/* get the polynom selection mask
there is one polynom for 0 <= x <= Pi/4
and another one for Pi/4<x<=Pi/2
Both branches will be computed.
*/
emm2 = _mm_and_si128(emm2, *(__m128i*)simd4uTwo);
emm2 = _mm_cmpeq_epi32(emm2, _mm_setzero_si128());
__m128 swap_sign_bit = _mm_castsi128_ps(emm0);
__m128 poly_mask = _mm_castsi128_ps(emm2);
sign_bit = _mm_xor_ps(sign_bit, swap_sign_bit);
/* The magic pass: "Extended precision modular arithmetic"
x = ((x - y * DP1) - y * DP2) - y * DP3; */
xmm1 = *(__m128 *)simd4f_minus_cephes_DP1;
xmm2 = *(__m128 *)simd4f_minus_cephes_DP2;
xmm3 = *(__m128 *)simd4f_minus_cephes_DP3;
xmm1 = _mm_mul_ps(y, xmm1);
xmm2 = _mm_mul_ps(y, xmm2);
xmm3 = _mm_mul_ps(y, xmm3);
x = _mm_add_ps(x, xmm1);
x = _mm_add_ps(x, xmm2);
x = _mm_add_ps(x, xmm3);
/* Evaluate the first polynom (0 <= x <= Pi/4) */
y = *(__m128 *)simd4f_coscof_p0;
__m128 z = _mm_mul_ps(x,x);
y = _mm_mul_ps(y, z);
y = _mm_add_ps(y, *(__m128 *)simd4f_coscof_p1);
y = _mm_mul_ps(y, z);
y = _mm_add_ps(y, *(__m128 *)simd4f_coscof_p2);
y = _mm_mul_ps(y, z);
y = _mm_mul_ps(y, z);
__m128 tmp = _mm_mul_ps(z, *(__m128 *)simd4fHalf);
y = _mm_sub_ps(y, tmp);
y = _mm_add_ps(y, *(__m128 *)simd4fOne);
/* Evaluate the second polynom (Pi/4 <= x <= 0) */
__m128 y2 = *(__m128 *)simd4f_sincof_p0;
y2 = _mm_mul_ps(y2, z);
y2 = _mm_add_ps(y2, *(__m128 *)simd4f_sincof_p1);
y2 = _mm_mul_ps(y2, z);
y2 = _mm_add_ps(y2, *(__m128 *)simd4f_sincof_p2);
y2 = _mm_mul_ps(y2, z);
y2 = _mm_mul_ps(y2, x);
y2 = _mm_add_ps(y2, x);
/* select the correct result from the two polynoms */
xmm3 = poly_mask;
y2 = _mm_and_ps(xmm3, y2);
y = _mm_andnot_ps(xmm3, y);
y = _mm_add_ps(y,y2);
/* update the sign */
y = _mm_xor_ps(y, sign_bit);
return y;
}
/* almost the same as sin_ps */
__m128 simd4f_cos_ps( __m128 x )
{
__m128 xmm1, xmm2, xmm3, y;
__m128i emm0, emm2;
xmm2 = _mm_setzero_ps();
/* take the absolute value */
x = _mm_and_ps(x, *(__m128*)simd4fSignMaskInv);
/* scale by 4/Pi */
y = _mm_mul_ps(x, *(__m128*)simd4f_cephes_FOPI);
/* store the integer part of y in mm0 */
emm2 = _mm_cvttps_epi32(y);
/* j=(j+1) & (~1) (see the cephes sources) */
emm2 = _mm_add_epi32(emm2, *(__m128i*)simd4uOne);
emm2 = _mm_and_si128(emm2, *(__m128i*)simd4uOneInv);
y = _mm_cvtepi32_ps(emm2);
emm2 = _mm_sub_epi32(emm2, *(__m128i*)simd4uTwo);
/* get the swap sign flag */
emm0 = _mm_andnot_si128(emm2, *(__m128i*)simd4uFour);
emm0 = _mm_slli_epi32(emm0, 29);
/* get the polynom selection mask */
emm2 = _mm_and_si128(emm2, *(__m128i*)simd4uTwo);
emm2 = _mm_cmpeq_epi32(emm2, _mm_setzero_si128());
__m128 sign_bit = _mm_castsi128_ps(emm0);
__m128 poly_mask = _mm_castsi128_ps(emm2);
/* The magic pass: "Extended precision modular arithmetic"
x = ((x - y * DP1) - y * DP2) - y * DP3; */
xmm1 = *(__m128*)simd4f_minus_cephes_DP1;
xmm2 = *(__m128*)simd4f_minus_cephes_DP2;
xmm3 = *(__m128*)simd4f_minus_cephes_DP3;
xmm1 = _mm_mul_ps(y, xmm1);
xmm2 = _mm_mul_ps(y, xmm2);
xmm3 = _mm_mul_ps(y, xmm3);
x = _mm_add_ps(x, xmm1);
x = _mm_add_ps(x, xmm2);
x = _mm_add_ps(x, xmm3);
/* Evaluate the first polynom (0 <= x <= Pi/4) */
y = *(__m128*)simd4f_coscof_p0;
__m128 z = _mm_mul_ps(x,x);
y = _mm_mul_ps(y, z);
y = _mm_add_ps(y, *(__m128*)simd4f_coscof_p1);
y = _mm_mul_ps(y, z);
y = _mm_add_ps(y, *(__m128*)simd4f_coscof_p2);
y = _mm_mul_ps(y, z);
y = _mm_mul_ps(y, z);
__m128 tmp = _mm_mul_ps(z, *(__m128*)simd4fHalf);
y = _mm_sub_ps(y, tmp);
y = _mm_add_ps(y, *(__m128*)simd4fOne);
/* Evaluate the second polynom (Pi/4 <= x <= 0) */
__m128 y2 = *(__m128*)simd4f_sincof_p0;
y2 = _mm_mul_ps(y2, z);
y2 = _mm_add_ps(y2, *(__m128*)simd4f_sincof_p1);
y2 = _mm_mul_ps(y2, z);
y2 = _mm_add_ps(y2, *(__m128*)simd4f_sincof_p2);
y2 = _mm_mul_ps(y2, z);
y2 = _mm_mul_ps(y2, x);
y2 = _mm_add_ps(y2, x);
/* select the correct result from the two polynoms */
xmm3 = poly_mask;
y2 = _mm_and_ps(xmm3, y2); //, xmm3);
y = _mm_andnot_ps(xmm3, y);
y = _mm_add_ps(y,y2);
/* update the sign */
y = _mm_xor_ps(y, sign_bit);
return y;
}
/* since sin_ps and cos_ps are almost identical, sincos_ps could replace both of them..
it is almost as fast, and gives you a free cosine with your sine */
void simd4f_sincos_ps( __m128 x, __m128 *s, __m128 *c )
{
__m128 xmm1, xmm2, xmm3, sign_bit_sin, y;
__m128i emm0, emm2, emm4;
xmm3 = _mm_setzero_ps();
sign_bit_sin = x;
/* take the absolute value */
x = _mm_and_ps(x, *(__m128*)simd4fSignMaskInv);
/* extract the sign bit (upper one) */
sign_bit_sin = _mm_and_ps(sign_bit_sin, *(__m128*)simd4fSignMask);
/* scale by 4/Pi */
y = _mm_mul_ps(x, *(__m128*)simd4f_cephes_FOPI);
/* store the integer part of y in emm2 */
emm2 = _mm_cvttps_epi32(y);
/* j=(j+1) & (~1) (see the cephes sources) */
emm2 = _mm_add_epi32(emm2, *(__m128i*)simd4uOne);
emm2 = _mm_and_si128(emm2, *(__m128i*)simd4uOneInv);
y = _mm_cvtepi32_ps(emm2);
emm4 = emm2;
/* get the swap sign flag for the sine */
emm0 = _mm_and_si128(emm2, *(__m128i*)simd4uFour);
emm0 = _mm_slli_epi32(emm0, 29);
__m128 swap_sign_bit_sin = _mm_castsi128_ps(emm0);
/* get the polynom selection mask for the sine*/
emm2 = _mm_and_si128(emm2, *(__m128i*)simd4uTwo);
emm2 = _mm_cmpeq_epi32(emm2, _mm_setzero_si128());
__m128 poly_mask = _mm_castsi128_ps(emm2);
/* The magic pass: "Extended precision modular arithmetic"
x = ((x - y * DP1) - y * DP2) - y * DP3; */
xmm1 = *(__m128*)simd4f_minus_cephes_DP1;
xmm2 = *(__m128*)simd4f_minus_cephes_DP2;
xmm3 = *(__m128*)simd4f_minus_cephes_DP3;
xmm1 = _mm_mul_ps(y, xmm1);
xmm2 = _mm_mul_ps(y, xmm2);
xmm3 = _mm_mul_ps(y, xmm3);
x = _mm_add_ps(x, xmm1);
x = _mm_add_ps(x, xmm2);
x = _mm_add_ps(x, xmm3);
emm4 = _mm_sub_epi32(emm4, *(__m128i*)simd4uTwo);
emm4 = _mm_andnot_si128(emm4, *(__m128i*)simd4uFour);
emm4 = _mm_slli_epi32(emm4, 29);
__m128 sign_bit_cos = _mm_castsi128_ps(emm4);
sign_bit_sin = _mm_xor_ps(sign_bit_sin, swap_sign_bit_sin);
/* Evaluate the first polynom (0 <= x <= Pi/4) */
__m128 z = _mm_mul_ps(x,x);
y = *(__m128*)simd4f_coscof_p0;
y = _mm_mul_ps(y, z);
y = _mm_add_ps(y, *(__m128*)simd4f_coscof_p1);
y = _mm_mul_ps(y, z);
y = _mm_add_ps(y, *(__m128*)simd4f_coscof_p2);
y = _mm_mul_ps(y, z);
y = _mm_mul_ps(y, z);
__m128 tmp = _mm_mul_ps(z, *(__m128*)simd4fHalf);
y = _mm_sub_ps(y, tmp);
y = _mm_add_ps(y, *(__m128*)simd4fOne);
/* Evaluate the second polynom (Pi/4 <= x <= 0) */
__m128 y2 = *(__m128*)simd4f_sincof_p0;
y2 = _mm_mul_ps(y2, z);
y2 = _mm_add_ps(y2, *(__m128*)simd4f_sincof_p1);
y2 = _mm_mul_ps(y2, z);
y2 = _mm_add_ps(y2, *(__m128*)simd4f_sincof_p2);
y2 = _mm_mul_ps(y2, z);
y2 = _mm_mul_ps(y2, x);
y2 = _mm_add_ps(y2, x);
/* select the correct result from the two polynoms */
xmm3 = poly_mask;
__m128 ysin2 = _mm_and_ps(xmm3, y2);
__m128 ysin1 = _mm_andnot_ps(xmm3, y);
y2 = _mm_sub_ps(y2,ysin2);
y = _mm_sub_ps(y, ysin1);
xmm1 = _mm_add_ps(ysin1,ysin2);
xmm2 = _mm_add_ps(y,y2);
/* update the sign */
*s = _mm_xor_ps(xmm1, sign_bit_sin);
*c = _mm_xor_ps(xmm2, sign_bit_cos);
}
#endif
////
#if CPU_SSE2_SUPPORT
/* Copyright (C) 2008 José Fonseca
http://jrfonseca.blogspot.ca/2008/09/fast-sse2-pow-tables-or-polynomials.html
MIT license
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#define POLY0(x,c0) _mm_set1_ps(c0)
#define POLY1(x,c0,c1) _mm_add_ps(_mm_mul_ps(POLY0(x, c1), x), _mm_set1_ps(c0))
#define POLY2(x,c0,c1,c2) _mm_add_ps(_mm_mul_ps(POLY1(x, c1, c2), x), _mm_set1_ps(c0))
#define POLY3(x,c0,c1,c2,c3) _mm_add_ps(_mm_mul_ps(POLY2(x, c1, c2, c3), x), _mm_set1_ps(c0))
#define POLY4(x,c0,c1,c2,c3,c4) _mm_add_ps(_mm_mul_ps(POLY3(x, c1, c2, c3, c4), x), _mm_set1_ps(c0))
#define POLY5(x,c0,c1,c2,c3,c4,c5) _mm_add_ps(_mm_mul_ps(POLY4(x, c1, c2, c3, c4, c5), x), _mm_set1_ps(c0))
#define EXP_POLY_DEGREE 3
#define LOG_POLY_DEGREE 5
__m128 simd4f_exp2_ps( __m128 x )
{
__m128i ipart;
__m128 fpart, expipart, expfpart;
x = _mm_min_ps( x, _mm_set1_ps( 129.00000f ) );
x = _mm_max_ps( x, _mm_set1_ps( -126.99999f ) );
/* ipart = int(x - 0.5) */
ipart = _mm_cvtps_epi32( _mm_sub_ps( x, _mm_set1_ps( 0.5f ) ) );
/* fpart = x - ipart */
fpart = _mm_sub_ps( x, _mm_cvtepi32_ps( ipart ) );
/* expipart = (float) (1 << ipart) */
expipart = _mm_castsi128_ps( _mm_slli_epi32( _mm_add_epi32( ipart, _mm_set1_epi32( 127 ) ), 23 ) );
/* minimax polynomial fit of 2**x, in range [-0.5, 0.5[ */
#if EXP_POLY_DEGREE == 5
expfpart = POLY5( fpart, 9.9999994e-1f, 6.9315308e-1f, 2.4015361e-1f, 5.5826318e-2f, 8.9893397e-3f, 1.8775767e-3f );
#elif EXP_POLY_DEGREE == 4
expfpart = POLY4( fpart, 1.0000026f, 6.9300383e-1f, 2.4144275e-1f, 5.2011464e-2f, 1.3534167e-2f );
#elif EXP_POLY_DEGREE == 3
expfpart = POLY3( fpart, 9.9992520e-1f, 6.9583356e-1f, 2.2606716e-1f, 7.8024521e-2f );
#elif EXP_POLY_DEGREE == 2
expfpart = POLY2( fpart, 1.0017247f, 6.5763628e-1f, 3.3718944e-1f );
#else
#error
#endif
return _mm_mul_ps(expipart, expfpart);
}
__m128 simd4f_log2_ps( __m128 x )
{
__m128i expmask, mantmask, i;
__m128 one, vexp, mant, logmant;
expmask = _mm_set1_epi32( 0x7f800000 );
mantmask = _mm_set1_epi32( 0x007fffff );
one = _mm_set1_ps( 1.0f );
i = _mm_castps_si128( x );
/* exp = (float) exponent(x) */
vexp = _mm_cvtepi32_ps( _mm_sub_epi32( _mm_srli_epi32( _mm_and_si128( i, expmask ), 23 ), _mm_set1_epi32( 127 ) ) );
/* mant = (float) mantissa(x) */
mant = _mm_or_ps( _mm_castsi128_ps( _mm_and_si128( i, mantmask ) ), one );
/* Minimax polynomial fit of log2(x)/(x - 1), for x in range [1, 2[
* These coefficients can be generate with
* http://www.boost.org/doc/libs/1_36_0/libs/math/doc/sf_and_dist/html/math_toolkit/toolkit/internals2/minimax.html
*/
#if LOG_POLY_DEGREE == 6
logmant = POLY5( mant, 3.11578814719469302614f, -3.32419399085241980044f, 2.59883907202499966007f, -1.23152682416275988241f, 0.318212422185251071475f, -0.0344359067839062357313f );
#elif LOG_POLY_DEGREE == 5
logmant = POLY4( mant, 2.8882704548164776201f, -2.52074962577807006663f, 1.48116647521213171641f, -0.465725644288844778798f, 0.0596515482674574969533f );
#elif LOG_POLY_DEGREE == 4
logmant = POLY3( mant, 2.61761038894603480148f, -1.75647175389045657003f, 0.688243882994381274313f, -0.107254423828329604454f );
#elif LOG_POLY_DEGREE == 3
logmant = POLY2( mant, 2.28330284476918490682f, -1.04913055217340124191f, 0.204446009836232697516f );
#else
#error
#endif
/* This effectively increases the polynomial degree by one, but ensures that log2(1) == 0*/
logmant = _mm_mul_ps( logmant, _mm_sub_ps(mant, one ) );
return _mm_add_ps( logmant, vexp );
}
__m128 simd4f_pow_ps( __m128 x, __m128 y )
{
return simd4f_exp2_ps( _mm_mul_ps( simd4f_log2_ps( x ), y ) );
}
#endif
////
#if CPU_SSE2_SUPPORT
/*
By Potatoswatter
http://stackoverflow.com/questions/6475373/optimizations-for-pow-with-const-non-integer-exponent
*/
#ifndef CC_ALWAYSINLINE
#if defined(__GNUC__) || defined(__INTEL_COMPILER)
#define CC_ALWAYSINLINE __attribute__((always_inline))
#else
#define CC_ALWAYSINLINE
#endif
#endif
static inline CC_ALWAYSINLINE __m128 simd4f_fastpow_ps( __m128 arg, uint32_t expnum, uint32_t expden, uint32_t coeffnum, uint32_t coeffden )
{
__m128 ret = arg;
float corrfactor, powfactor;
/* Apply a constant pre-correction factor. */
corrfactor = exp2( 127.0 * expden / expnum - 127.0 ) * pow( 1.0 * coeffnum / coeffden, 1.0 * expden / expnum );
powfactor = 1.0 * expnum / expden;
ret = _mm_mul_ps( ret, _mm_set1_ps( corrfactor ) );
/* Reinterpret arg as integer to obtain logarithm. */
ret = _mm_cvtepi32_ps( _mm_castps_si128( ret ) );
/* Multiply logarithm by power. */
ret = _mm_mul_ps( ret, _mm_set1_ps( powfactor ) );
/* Convert back to "integer" to exponentiate. */
ret = _mm_castsi128_ps( _mm_cvtps_epi32( ret ) );
return ret;
}
__m128 simd4f_pow12d5_ps( __m128 arg )
{
/* Lower exponents provide lower initial error, but too low causes overflow. */
__m128 xf = simd4f_fastpow_ps( arg, 4, 5, (int)( 1.38316186f * (float)1e9 ), (int)1e9 );
/* Imprecise 4-cycle sqrt is still far better than fastpow, good enough. */
__m128 xfm4 = _mm_rsqrt_ps( xf );
__m128 xf4 = _mm_mul_ps( xf, xfm4 );
/* Precisely calculate x^2 and x^3 */
__m128 x2 = _mm_mul_ps( arg, arg );
__m128 x3 = _mm_mul_ps( x2, arg );
/* Overestimate of x^2 * x^0.4 */
x2 = _mm_mul_ps( x2, xf4 );
/* Get x^-0.2 from x^0.4, and square it for x^-0.4. Combine into x^-0.6. */
__m128 xfm2 = _mm_rsqrt_ps( xf4 );
x3 = _mm_mul_ps( x3, xfm4 );
x3 = _mm_mul_ps( x3, xfm2 );
return _mm_mul_ps( _mm_add_ps( x2, x3 ), _mm_set1_ps( 1.0f/1.960131704207789f * 0.9999f ) );
}
__m128 simd4f_pow5d12_ps( __m128 arg )
{
/* 5/12 is too small, so compute the 4th root of 20/12 instead. */
/* 20/12 = 5/3 = 1 + 2/3 = 2 - 1/3. 2/3 is a suitable argument for fastpow. */
/* weighting coefficient: a^-1/2 = 2 a; a = 2^-2/3 */
__m128 xf = simd4f_fastpow_ps( arg, 2, 3, (int)( 0.629960524947437f * (float)1e9 ), (int)1e9 );
__m128 xover = _mm_mul_ps( arg, xf );
__m128 xfm1 = _mm_rsqrt_ps( xf );
__m128 x2 = _mm_mul_ps( arg, arg );
__m128 xunder = _mm_mul_ps( x2, xfm1 );
/* sqrt2 * over + 2 * sqrt2 * under */
__m128 xavg = _mm_mul_ps( _mm_set1_ps( 1.0f/( 3.0f * 0.629960524947437f ) * 0.999852f ), _mm_add_ps( xover, xunder ) );
xavg = _mm_mul_ps( xavg, _mm_rsqrt_ps( xavg ) );
xavg = _mm_mul_ps( xavg, _mm_rsqrt_ps( xavg ) );
return xavg;
}
#endif
////

View File

@ -0,0 +1,410 @@
/* -----------------------------------------------------------------------------
*
* Copyright (c) 2008-2016 Alexis Naveros.
*
* The SIMD trigonometry functions are Copyright (C) 2007 Julien Pommier
* See copyright notice for simd4f_sin_ps(), simd4f_cos_ps(), simd4f_sincos_ps()
*
* Portions developed under contract to the SURVICE Engineering Company.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
* -----------------------------------------------------------------------------
*/
#ifndef CPUSIMD_H
#define CPUSIMD_H
////
#if __MMX__ || CPU_ENABLE_MMX
#include <mmintrin.h>
#define CPU_MMX_SUPPORT (1)
#endif
#if __SSE__ || _M_X64 || _M_IX86_FP >= 1 || CPU_ENABLE_SSE
#include <xmmintrin.h>
#define CPU_SSE_SUPPORT (1)
#endif
#if __SSE2__ || _M_X64 || _M_IX86_FP >= 2 || CPU_ENABLE_SSE2
#include <emmintrin.h>
#define CPU_SSE2_SUPPORT (1)
#endif
#if __SSE3__ || __AVX__ || CPU_ENABLE_SSE3
#include <pmmintrin.h>
#define CPU_SSE3_SUPPORT (1)
#endif
#if __SSSE3__ || __AVX__ || CPU_ENABLE_SSSE3
#include <tmmintrin.h>
#define CPU_SSSE3_SUPPORT (1)
#endif
#if __SSE4_1__ || __AVX__ || CPU_ENABLE_SSE4_1
#include <smmintrin.h>
#define CPU_SSE4_1_SUPPORT (1)
#endif
#if __SSE4_2__ || CPU_ENABLE_SSE4_2
#include <nmmintrin.h>
#define CPU_SSE4_2_SUPPORT (1)
#endif
#if __SSE4A__ || CPU_ENABLE_SSE4A
#include <ammintrin.h>
#define CPU_SSE4A_SUPPORT (1)
#endif
#if __AVX__ || CPU_ENABLE_AVX
#include <immintrin.h>
#define CPU_AVX_SUPPORT (1)
#endif
#if __AVX2__ || CPU_ENABLE_AVX2
#include <immintrin.h>
#define CPU_AVX2_SUPPORT (1)
#endif
#if __XOP__ || CPU_ENABLE_XOP
#include <immintrin.h>
#define CPU_XOP_SUPPORT (1)
#endif
#if __FMA3__ || CPU_ENABLE_FMA3
#include <immintrin.h>
#define CPU_FMA3_SUPPORT (1)
#endif
#if __FMA4__ || CPU_ENABLE_FMA4
#include <immintrin.h>
#define CPU_FMA4_SUPPORT (1)
#endif
#if __RDRND__ || CPU_ENABLE_RDRND
#include <immintrin.h>
#define CPU_RDRND_SUPPORT (1)
#endif
#if __POPCNT__ || CPU_ENABLE_POPCNT
#include <popcntintrin.h>
#define CPU_POPCNT_SUPPORT (1)
#endif
#if __LZCNT__ || CPU_ENABLE_LZCNT
#include <lzcntintrin.h>
#define CPU_LZCNT_SUPPORT (1)
#endif
#if __F16C__ || CPU_ENABLE_F16C
#include <f16cintrin.h>
#define CPU_F16C_SUPPORT (1)
#endif
#if __BMI__ || CPU_ENABLE_BMI
#include <bmiintrin.h>
#define CPU_BMI_SUPPORT (1)
#endif
#if __BMI2__ || CPU_ENABLE_BMI2
#include <bmi2intrin.h>
#define CPU_BMI2_SUPPORT (1)
#endif
#if __TBM__ || CPU_ENABLE_TBM
#include <tbmintrin.h>
#define CPU_TBM_SUPPORT (1)
#endif
#if defined(__GNUC__) || defined(__INTEL_COMPILER)
#define CPU_ALIGN16 __attribute__((aligned(16)))
#define CPU_ALIGN32 __attribute__((aligned(32)))
#define CPU_ALIGN64 __attribute__((aligned(64)))
#elif defined(_MSC_VER)
#define CPU_ALIGN16 __declspec(align(16))
#define CPU_ALIGN64 __declspec(align(64))
#else
#define CPU_ALIGN16
#define CPU_ALIGN32
#define CPU_ALIGN64
#warning "SSE/AVX Disabled: Unsupported Compiler."
#undef CPU_SSE_SUPPORT
#undef CPU_SSE2_SUPPORT
#undef CPU_SSE3_SUPPORT
#undef CPU_SSSE3_SUPPORT
#undef CPU_SSE4_1_SUPPORT
#undef CPU_SSE4_2_SUPPORT
#undef CPU_AVX_SUPPORT
#undef CPU_AVX2_SUPPORT
#undef CPU_XOP_SUPPORT
#undef CPU_FMA3_SUPPORT
#undef CPU_FMA4_SUPPORT
#endif
////
#if CPU_SSE_SUPPORT
#define CPU_APPROX_DIV_FLOAT(z,w) _mm_cvtss_f32(_mm_mul_ss(_mm_set_ss(z),_mm_rcp_ss(_mm_set_ss(w))))
#define CPU_APPROX_SQRT_FLOAT(z) _mm_cvtss_f32(_mm_mul_ss(_mm_set_ss(z),_mm_rsqrt_ss(_mm_set_ss(z))))
#define CPU_APPROX_RSQRT_FLOAT(z) _mm_cvtss_f32(_mm_rsqrt_ss(_mm_set_ss(z)))
#define CPU_APPROX_DIVSQRT_FLOAT(z,w) _mm_cvtss_f32(_mm_mul_ss(_mm_set_ss(z),_mm_rsqrt_ss(_mm_set_ss(w))))
#else
#define CPU_APPROX_DIV_FLOAT(z,w) ((z)/(w))
#define CPU_APPROX_SQRT_FLOAT(z) (sqrtf(z))
#define CPU_APPROX_RSQRT_FLOAT(z) (1.0/sqrtf(z))
#define CPU_APPROX_DIVSQRT_FLOAT(z,w) ((z)/sqrtf(w))
#endif
#if CPU_SSE3_SUPPORT
#define CPU_HADD_PS(vx,vy) _mm_hadd_ps(vx,vy)
#define CPU_HADD_PD(vx,vy) _mm_hadd_pd(vx,vy)
#elif CPU_SSE_SUPPORT
static inline __m128 CPU_HADD_PS( __m128 vx, __m128 vy )
{
__m128 vh, vl;
vh = _mm_shuffle_ps( vx, vy, _MM_SHUFFLE(3,1,3,1) );
vl = _mm_shuffle_ps( vx, vy, _MM_SHUFFLE(2,0,2,0) );
return _mm_add_ps( vh, vl );
}
#define CPU_HADD_PD(vx,vy) _mm_add_sd(vx,_mm_unpackhi_pd(vy,vy))
#endif
#if CPU_SSE4_1_SUPPORT
#define CPU_CVT_U8_TO_I32(x,vzero) _mm_cvtepu8_epi32(x)
#define CPU_CVT_S8_TO_I32(x,vzero) _mm_cvtepi8_epi32(x)
#elif CPU_SSE2_SUPPORT
#define CPU_CVT_U8_TO_I32(x,vzero) _mm_unpacklo_epi16(_mm_unpacklo_epi8((x),(vzero)),(vzero))
static inline __m128i CPU_CVT_S8_TO_I32( __m128i vx, __m128i vzero )
{
__m128i vsign;
vsign = _mm_cmpgt_epi8( vzero, vx );
return _mm_unpacklo_epi16( _mm_unpacklo_epi8( vx, vsign ), _mm_unpacklo_epi8( vsign, vsign ) );
}
#endif
#if CPU_SSE4_1_SUPPORT
#define CPU_BLENDV_PS(x,y,mask) _mm_blendv_ps(x,y,mask)
#define CPU_BLENDV_PD(x,y,mask) _mm_blendv_pd(x,y,mask)
#elif CPU_SSE2_SUPPORT
#define CPU_BLENDV_PS(x,y,mask) _mm_or_ps(_mm_andnot_ps(mask,x),_mm_and_ps(y,mask))
#define CPU_BLENDV_PD(x,y,mask) _mm_or_pd(_mm_andnot_pd(mask,x),_mm_and_pd(y,mask))
#endif
/*
CPU_FMADD = ((f0*f1)+t0)
CPU_FMSUB = ((f0*f1)-t0)
*/
#if CPU_FMA3_SUPPORT
#define CPU_FMADD_SS(f0,f1,t0) _mm_fmadd_ss(f0,f1,t0)
#define CPU_FMADD_PS(f0,f1,t0) _mm_fmadd_ps(f0,f1,t0)
#define CPU_FMADD_SD(f0,f1,t0) _mm_fmadd_sd(f0,f1,t0)
#define CPU_FMADD_PD(f0,f1,t0) _mm_fmadd_pd(f0,f1,t0)
#define CPU_FMSUB_SS(f0,f1,t0) _mm_fmsub_ss(f0,f1,t0)
#define CPU_FMSUB_PS(f0,f1,t0) _mm_fmsub_ps(f0,f1,t0)
#define CPU_FMSUB_SD(f0,f1,t0) _mm_fmsub_sd(f0,f1,t0)
#define CPU_FMSUB_PD(f0,f1,t0) _mm_fmsub_pd(f0,f1,t0)
#define CPU_FMADD256_SS(f0,f1,t0) _mm256_fmadd_ss(f0,f1,t0)
#define CPU_FMADD256_PS(f0,f1,t0) _mm256_fmadd_ps(f0,f1,t0)
#define CPU_FMADD256_SD(f0,f1,t0) _mm256_fmadd_sd(f0,f1,t0)
#define CPU_FMADD256_PD(f0,f1,t0) _mm256_fmadd_pd(f0,f1,t0)
#define CPU_FMSUB256_SS(f0,f1,t0) _mm256_fmsub_ss(f0,f1,t0)
#define CPU_FMSUB256_PS(f0,f1,t0) _mm256_fmsub_ps(f0,f1,t0)
#define CPU_FMSUB256_SD(f0,f1,t0) _mm256_fmsub_sd(f0,f1,t0)
#define CPU_FMSUB256_PD(f0,f1,t0) _mm256_fmsub_pd(f0,f1,t0)
#elif CPU_FMA4_SUPPORT
#define CPU_FMADD_SS(f0,f1,t0) _mm_macc_ss(f0,f1,t0)
#define CPU_FMADD_PS(f0,f1,t0) _mm_macc_ps(f0,f1,t0)
#define CPU_FMADD_SD(f0,f1,t0) _mm_macc_sd(f0,f1,t0)
#define CPU_FMADD_PD(f0,f1,t0) _mm_macc_pd(f0,f1,t0)
#define CPU_FMSUB_SS(f0,f1,t0) _mm_msub_ss(f0,f1,t0)
#define CPU_FMSUB_PS(f0,f1,t0) _mm_msub_ps(f0,f1,t0)
#define CPU_FMSUB_SD(f0,f1,t0) _mm_msub_sd(f0,f1,t0)
#define CPU_FMSUB_PD(f0,f1,t0) _mm_msub_pd(f0,f1,t0)
#define CPU_FMADD256_SS(f0,f1,t0) _mm256_macc_ss(f0,f1,t0)
#define CPU_FMADD256_PS(f0,f1,t0) _mm256_macc_ps(f0,f1,t0)
#define CPU_FMADD256_SD(f0,f1,t0) _mm256_macc_sd(f0,f1,t0)
#define CPU_FMADD256_PD(f0,f1,t0) _mm256_macc_pd(f0,f1,t0)
#define CPU_FMSUB256_SS(f0,f1,t0) _mm256_msub_ss(f0,f1,t0)
#define CPU_FMSUB256_PS(f0,f1,t0) _mm256_msub_ps(f0,f1,t0)
#define CPU_FMSUB256_SD(f0,f1,t0) _mm256_msub_sd(f0,f1,t0)
#define CPU_FMSUB256_PD(f0,f1,t0) _mm256_msub_pd(f0,f1,t0)
#else
#define CPU_FMADD_SS(f0,f1,t0) _mm_add_ss(_mm_mul_ss(f0,f1),t0)
#define CPU_FMADD_PS(f0,f1,t0) _mm_add_ps(_mm_mul_ps(f0,f1),t0)
#define CPU_FMADD_SD(f0,f1,t0) _mm_add_sd(_mm_mul_sd(f0,f1),t0)
#define CPU_FMADD_PD(f0,f1,t0) _mm_add_pd(_mm_mul_pd(f0,f1),t0)
#define CPU_FMSUB_SS(f0,f1,t0) _mm_sub_ss(_mm_mul_ss(f0,f1),t0)
#define CPU_FMSUB_PS(f0,f1,t0) _mm_sub_ps(_mm_mul_ps(f0,f1),t0)
#define CPU_FMSUB_SD(f0,f1,t0) _mm_sub_sd(_mm_mul_sd(f0,f1),t0)
#define CPU_FMSUB_PD(f0,f1,t0) _mm_sub_pd(_mm_mul_pd(f0,f1),t0)
#define CPU_FMADD256_SS(f0,f1,t0) _mm256_add_ss(_mm256_mul_ss(f0,f1),t0)
#define CPU_FMADD256_PS(f0,f1,t0) _mm256_add_ps(_mm256_mul_ps(f0,f1),t0)
#define CPU_FMADD256_SD(f0,f1,t0) _mm256_add_sd(_mm256_mul_sd(f0,f1),t0)
#define CPU_FMADD256_PD(f0,f1,t0) _mm256_add_pd(_mm256_mul_pd(f0,f1),t0)
#define CPU_FMSUB256_SS(f0,f1,t0) _mm256_sub_ss(_mm256_mul_ss(f0,f1),t0)
#define CPU_FMSUB256_PS(f0,f1,t0) _mm256_sub_ps(_mm256_mul_ps(f0,f1),t0)
#define CPU_FMSUB256_SD(f0,f1,t0) _mm256_sub_sd(_mm256_mul_sd(f0,f1),t0)
#define CPU_FMSUB256_PD(f0,f1,t0) _mm256_sub_pd(_mm256_mul_pd(f0,f1),t0)
#endif
////
#if CPU_SSE_SUPPORT
extern const uint32_t simd4fSignMask[4];
extern const uint32_t simd4fSignMaskInv[4];
extern const float simd4fHalf[4];
extern const float simd4fOne[4];
extern const float simd4fTwo[4];
extern const float simd4fThree[4];
extern const uint32_t simd4uOne[4];
extern const uint32_t simd4uOneInv[4];
extern const uint32_t simd4uTwo[4];
extern const uint32_t simd4uFour[4];
extern const float simd4fQuarter[4];
extern const float simd4fPi[4];
extern const float simd4fZeroOneTwoThree[4];
extern const uint32_t simd4fAlphaMask[4];
extern const float simd4f255[4];
extern const float simd4f255Inv[4];
#endif
#if CPU_SSE2_SUPPORT
/* Input range between -8192 and 8192 */
__m128 simd4f_sin_ps( __m128 x );
__m128 simd4f_cos_ps( __m128 x );
void simd4f_sincos_ps( __m128 x, __m128 *s, __m128 *c );
#endif
#if CPU_SSE2_SUPPORT
__m128 simd4f_exp2_ps( __m128 x );
__m128 simd4f_log2_ps( __m128 x );
__m128 simd4f_pow_ps( __m128 x, __m128 y );
#endif
#if CPU_SSE2_SUPPORT
__m128 simd4f_pow12d5_ps( __m128 arg );
__m128 simd4f_pow5d12_ps( __m128 arg );
#endif
////
#if CPU_SSE2_SUPPORT
#ifndef CC_ALWAYSINLINE
#if defined(__GNUC__) || defined(__INTEL_COMPILER)
#define CC_ALWAYSINLINE __attribute__((always_inline))
#else
#define CC_ALWAYSINLINE
#endif
#endif
static inline CC_ALWAYSINLINE __m128 simd4f_pow12d5_inline_ps( __m128 vx )
{
__m128 vpow, vpwsqrtinv, vpwsqrt, vx2;
vx2 = _mm_mul_ps( vx, vx );
vpow = _mm_castsi128_ps( _mm_cvtps_epi32( _mm_mul_ps( _mm_cvtepi32_ps( _mm_castps_si128( _mm_mul_ps( vx, _mm_set1_ps( 5417434112.0f ) ) ) ), _mm_set1_ps( 0.8f ) ) ) );
vpwsqrtinv = _mm_rsqrt_ps( vpow );
vpwsqrt = _mm_mul_ps( vpow, vpwsqrtinv );
return _mm_mul_ps( _mm_add_ps( _mm_mul_ps( vx2, vpwsqrt ), _mm_mul_ps( _mm_mul_ps( _mm_mul_ps( vx2, vx ), vpwsqrtinv ), _mm_rsqrt_ps( vpwsqrt ) ) ), _mm_set1_ps( 0.51011878327f ) );
}
static inline CC_ALWAYSINLINE __m128 simd4f_pow5d12_inline_ps( __m128 vx )
{
__m128 vpow;
vpow = _mm_castsi128_ps( _mm_cvtps_epi32( _mm_mul_ps( _mm_cvtepi32_ps( _mm_castps_si128( _mm_mul_ps( vx, _mm_set1_ps( 6521909350804488192.0f ) ) ) ), _mm_set1_ps( 0.666666666666f ) ) ) );
vx = _mm_mul_ps( _mm_add_ps( _mm_mul_ps( vx, vpow ), _mm_mul_ps( _mm_mul_ps( vx, vx ), _mm_rsqrt_ps( vpow ) ) ), _mm_set1_ps( 0.5290553722f ) );
#if 0
vx = _mm_mul_ps( vx, _mm_rsqrt_ps( vx ) );
vx = _mm_mul_ps( vx, _mm_rsqrt_ps( vx ) );
#else
vx = _mm_sqrt_ps( vx );
vx = _mm_sqrt_ps( vx );
#endif
return vx;
}
#endif
////
#if CPU_SSE_SUPPORT
static inline void simdPrintDebugSSE4f( char *str, __m128 v )
{
float CPU_ALIGN16 store[4];
_mm_store_ps( (void *)store, v );
printf( "%s %f %f %f %f\n", str, (double)store[0], (double)store[1], (double)store[2], (double)store[3] );
return;
}
static inline void simdPrintDebugSSE2d( char *str, __m128d v )
{
double CPU_ALIGN16 store[2];
_mm_store_pd( (void *)store, v );
printf( "%s %f %f\n", str, store[0], store[1] );
return;
}
static inline void simdPrintDebugSSE16u8( char *str, __m128i v )
{
uint8_t CPU_ALIGN16 store[16];
_mm_store_si128( (void *)store, v );
printf( "%s %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n", str, store[0], store[1], store[2], store[3], store[4], store[5], store[6], store[7], store[8], store[9], store[10], store[11], store[12], store[13], store[14], store[15] );
return;
}
static inline void simdPrintDebugSSE8u16( char *str, __m128i v )
{
uint16_t CPU_ALIGN16 store[8];
_mm_store_si128( (void *)store, v );
printf( "%s %d %d %d %d %d %d %d %d\n", str, store[0], store[1], store[2], store[3], store[4], store[5], store[6], store[7] );
return;
}
static inline void simdPrintDebugSSE4u32( char *str, __m128i v )
{
uint32_t CPU_ALIGN16 store[4];
_mm_store_si128( (void *)store, v );
printf( "%s %d %d %d %d\n", str, store[0], store[1], store[2], store[3] );
return;
}
static inline void simdPrintDebugSSE2u64( char *str, __m128i v )
{
uint64_t CPU_ALIGN16 store[2];
_mm_store_si128( (void *)store, v );
printf( "%s %lld %lld\n", str, (long long)store[0], (long long)store[1] );
return;
}
#endif
////
#endif

View File

@ -0,0 +1,77 @@
/* -----------------------------------------------------------------------------
*
* Copyright (c) 2007-2017 Alexis Naveros.
* Portions developed under contract to the SURVICE Engineering Company.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
* -----------------------------------------------------------------------------
*/
#ifndef IMG_H
#define IMG_H
typedef struct
{
int width;
int height;
int type;
int bytesperpixel;
int bytesperline;
} imgFormat;
enum
{
IMG_FORMAT_TYPE_ANY,
IMG_FORMAT_TYPE_RGB24,
IMG_FORMAT_TYPE_BGR24,
IMG_FORMAT_TYPE_RGBX32,
IMG_FORMAT_TYPE_BGRX32,
IMG_FORMAT_TYPE_RGBA32,
IMG_FORMAT_TYPE_BGRA32,
IMG_FORMAT_TYPE_GRAYSCALE,
IMG_FORMAT_TYPE_GRAYALPHA
};
typedef struct
{
imgFormat format;
void *data;
} imgImage;
////
void imgCopyRect( imgImage *image, int dstx, int dsty, int srcx, int srcy, int sizex, int sizey );
void (*imgBlendGetFunction( imgImage *dstimage, imgImage *srcimage ))( imgImage *dstimage, int dstx, int dsty, imgImage *srcimage );
int imgBlendImage( imgImage *dstimage, int dstx, int dsty, imgImage *srcimage );
void imgAllocCopy( imgImage *dst, imgImage *src );
void imgAllocCopyExtendBorder( imgImage *dstimage, imgImage *srcimage, int extendsize );
void imgAllocExtractChannel( imgImage *dst, imgImage *src, int channelindex );
void imgAllocExtractChannelExtendBorder( imgImage *dstimage, imgImage *srcimage, int channelindex, int extendsize );
void imgAllocCopyChannelToAlpha( imgImage *dstimage, imgImage *srcimage, int channelindex, unsigned char r, unsigned char g, unsigned char b );
void imgAllocAdjustBrightnessContrast( imgImage *dstimage, imgImage *srcimage, float brightness, float contrast );
void imgFree( imgImage *image );
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,150 @@
/* -----------------------------------------------------------------------------
*
* Copyright (c) 2014-2017 Alexis Naveros.
* Portions developed under contract to the SURVICE Engineering Company.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
* -----------------------------------------------------------------------------
*/
#ifndef IMGRESIZE_H
#define IMGRESIZE_H
typedef struct
{
/* Specify filter type, from the IM_REDUCE_FILTER_* list */
int filter;
/* High quality, a little slow: hopcount=3; */
/* Good quality, much faster: hopcount=2; */
int hopcount;
/* Strong preservation/amplification of details: alpha=2.0f; */
/* Mild preservation/amplification of details: alpha=6.0f; */
float alpha;
/* NORMALMAP filters: factor to amyplify normals on X and Y before normalization */
float amplifynormal;
/* NORMALMAP_SUSTAIN filters: Preserve a factor of deviation "energy" as calculated by sqrtf(x*x+y*y) */
float normalsustainfactor;
} imReduceOptions;
static inline void imReduceSetOptions( imReduceOptions *options, int filter, int hopcount, float alpha, float amplifynormal, float normalsustainfactor )
{
options->filter = filter;
options->hopcount = hopcount;
options->alpha = alpha;
options->amplifynormal = amplifynormal;
options->normalsustainfactor = normalsustainfactor;
return;
}
/* Reduce the image's dimensions by an integer divisor ~ this is fairly fast */
int imReduceImageKaiserDataDivisor( unsigned char *dstdata, unsigned char *srcdata, int width, int height, int bytesperpixel, int bytesperline, int sizedivisor, imReduceOptions *options );
/* Same as imReduceImageKaiserDataDivisor(), but imgdst is allocated */
int imReduceImageKaiserDivisor( imgImage *imgdst, imgImage *imgsrc, int sizedivisor, imReduceOptions *options );
/* Reduce the image's dimensions to match the newwidth and newheight ~ this is a little slower */
int imReduceImageKaiserData( unsigned char *dstdata, unsigned char *srcdata, int width, int height, int bytesperpixel, int bytesperline, int newwidth, int newheight, imReduceOptions *options );
/* Same as imReduceImageKaiserData(), but imgdst is allocated */
int imReduceImageKaiser( imgImage *imgdst, imgImage *imgsrc, int newwidth, int newheight, imReduceOptions *options );
/* Resize by half with a dumb box filter ~ don't use that except for the smallest mipmaps */
/* Filters with ALPHANORM and/or SUSTAIN keywords are processed as the regular base filter only */
int imReduceImageHalfBoxData( unsigned char *dstdata, unsigned char *srcdata, int width, int height, int bytesperpixel, int bytesperline, imReduceOptions *options );
int imReduceImageHalfBox( imgImage *imgdst, imgImage *imgsrc, imReduceOptions *options );
/*
Keywords for image reduction filters
LINEAR: Data is linear, note that this is *not* the format of typical diffuse textures
SRGB: Color is in sRGB space, any alpha is presumed linear
NORMALMAP: RGB represents a XYZ vector as (2.0*RGB)-1.0f, any alpha is presumed linear
ALPHANORM: Alpha normalization, the weight of pixels is proportional to their alpha values
(do you have "black" fully transparent pixels? please use an ALPHANORM filter)
SUSTAIN: The "energy" of the normal map is sustained, amplified to preserve the level of details
Note that this filter is rather slow (set options->normalsustainfactor to 0.75 or so)
*/
enum
{
/* Linear space */
IM_REDUCE_FILTER_LINEAR,
IM_REDUCE_FILTER_LINEAR_ALPHANORM,
/* sRGB space (probably what you want for diffuse textures) */
IM_REDUCE_FILTER_SRGB,
IM_REDUCE_FILTER_SRGB_ALPHANORM,
/* RGB represents a XYZ vector as (2.0*RGB)-1.0f, any alpha is presumed linear */
IM_REDUCE_FILTER_NORMALMAP,
IM_REDUCE_FILTER_NORMALMAP_ALPHANORM,
IM_REDUCE_FILTER_NORMALMAP_SUSTAIN,
IM_REDUCE_FILTER_NORMALMAP_SUSTAIN_ALPHANORM,
/* Custom specialized filters */
IM_REDUCE_FILTER_WATERMAP,
IM_REDUCE_FILTER_PLANTMAP,
IM_REDUCE_FILTER_FOLLIAGE,
IM_REDUCE_FILTER_SKY,
IM_REDUCE_FILTER_FOG
};
////
#define IM_MIPMAP_CASCADE_MAX (16)
typedef struct
{
int width;
int height;
int layercount;
int bytesperpixel;
int bytesperline;
imReduceOptions *options;
void *mipmap[IM_MIPMAP_CASCADE_MAX];
} imMipmapCascade;
int imBuildMipmapCascade( imMipmapCascade *cascade, void *imagedata, int width, int height, int layercount, int bytesperpixel, int bytesperline, imReduceOptions *options, int cascadeflags );
void imFreeMipmapCascade( imMipmapCascade *cascade );
/* For base texture, propagate RGB channels to neighbors if they are fully transparent (ignored if bytesperpixel != 4 ) */
#define IM_CASCADE_FLAGS_COLOR_BORDER_BASE (0x1)
/* For generated mipmaps, propagate RGB channels to neighbors if they are fully transparent (ignored if bytesperpixel != 4 ) */
#define IM_CASCADE_FLAGS_COLOR_BORDER_MIPMAPS (0x2)
////
void imPropagateAlphaBorder( unsigned char *imagedata, int width, int height, int bytesperpixel, int bytesperline );
////
#endif

View File

@ -5,12 +5,17 @@ find_package(JPEG REQUIRED)
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include/"
"${JPEG_INCLUDE_DIR}"
"${PNG_INCLUDE_DIRS}"
"${ZLIB_INCLUDE_DIR}"
"${CMAKE_CURRENT_BINARY_DIR}/../zlib/") # For zconf.h on WIN32
"${ZLIB_INCLUDE_DIR}")
if(MSVC OR APPLE)
include_directories("${CMAKE_CURRENT_BINARY_DIR}/../zlib/" # For zconf.h on WIN32
"${CMAKE_CURRENT_BINARY_DIR}/../libpng/")
endif()
if (SERVER_ONLY)
add_definitions(-DNO_IRR_COMPILE_WITH_OPENGL_)
add_definitions(-DNO_IRR_COMPILE_WITH_X11_)
add_definitions(-DNO_IRR_COMPILE_WITH_WAYLAND_DEVICE_)
else()
if(NOT USE_GLES2)
find_package(OpenGL REQUIRED)
@ -23,6 +28,10 @@ if (UNIX AND NOT APPLE)
include_directories(${X11_INCLUDE_DIR})
endif()
if(ENABLE_WAYLAND_DEVICE)
add_definitions(-D_IRR_COMPILE_WITH_WAYLAND_DEVICE_)
endif()
if(APPLE)
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/source/Irrlicht/MacOSX" "${CMAKE_CURRENT_SOURCE_DIR}/source/Irrlicht")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -arch x86_64")
@ -53,7 +62,7 @@ else()
endif()
if(USE_GLES2)
add_definitions(-D_IRR_COMPILE_WITH_OGLES2_ -DNO_IRR_COMPILE_WITH_SOFTWARE_ -DNO_IRR_COMPILE_WITH_BURNINGSVIDEO_ -DNO_IRR_COMPILE_WITH_OGLES1_ -DNO_IRR_COMPILE_WITH_OPENGL_ -DNO_IRR_USE_NON_SYSTEM_JPEG_LIB_ -DNO_IRR_USE_NON_SYSTEM_LIB_PNG_ -DNO_IRR_USE_NON_SYSTEM_ZLIB_)
add_definitions(-D_IRR_COMPILE_WITH_OGLES2_ -DNO_IRR_COMPILE_WITH_OPENGL_)
endif()
if(CYGWIN)
@ -67,6 +76,7 @@ source/Irrlicht/CAttributes.cpp
source/Irrlicht/CBillboardSceneNode.cpp
source/Irrlicht/CBoneSceneNode.cpp
source/Irrlicht/CCameraSceneNode.cpp
source/Irrlicht/CContextEGL.cpp
source/Irrlicht/CColorConverter.cpp
source/Irrlicht/CCubeSceneNode.cpp
source/Irrlicht/CDefaultGUIElementFactory.cpp
@ -112,11 +122,13 @@ source/Irrlicht/CImageLoaderPNG.cpp
source/Irrlicht/CImageWriterBMP.cpp
source/Irrlicht/CImageWriterJPG.cpp
source/Irrlicht/CImageWriterPNG.cpp
source/Irrlicht/CIrrDeviceAndroid.cpp
source/Irrlicht/CIrrDeviceConsole.cpp
source/Irrlicht/CIrrDeviceFB.cpp
source/Irrlicht/CIrrDeviceLinux.cpp
source/Irrlicht/CIrrDeviceSDL.cpp
source/Irrlicht/CIrrDeviceStub.cpp
source/Irrlicht/CIrrDeviceWayland.cpp
source/Irrlicht/CIrrDeviceWin32.cpp
source/Irrlicht/CLightSceneNode.cpp
source/Irrlicht/CLimitReadFile.cpp
@ -198,6 +210,7 @@ source/Irrlicht/CBillboardSceneNode.h
source/Irrlicht/CBlit.h
source/Irrlicht/CBoneSceneNode.h
source/Irrlicht/CCameraSceneNode.h
source/Irrlicht/CContextEGL.h
source/Irrlicht/CColorConverter.h
source/Irrlicht/CCubeSceneNode.h
source/Irrlicht/CDefaultGUIElementFactory.h
@ -243,11 +256,13 @@ source/Irrlicht/CImageLoaderPNG.h
source/Irrlicht/CImageWriterBMP.h
source/Irrlicht/CImageWriterJPG.h
source/Irrlicht/CImageWriterPNG.h
source/Irrlicht/CIrrDeviceAndroid.h
source/Irrlicht/CIrrDeviceConsole.h
source/Irrlicht/CIrrDeviceFB.h
source/Irrlicht/CIrrDeviceLinux.h
source/Irrlicht/CIrrDeviceSDL.h
source/Irrlicht/CIrrDeviceStub.h
source/Irrlicht/CIrrDeviceWayland.h
source/Irrlicht/CIrrDeviceWin32.h
source/Irrlicht/CLightSceneNode.h
source/Irrlicht/CLimitReadFile.h
@ -546,6 +561,14 @@ endif()
add_library(stkirrlicht STATIC ${IRRLICHT_SOURCES})
target_link_libraries(stkirrlicht ${PNG_LIBRARY} ${JPEG_LIBRARY} ${ZLIB_LIBRARY})
if(USE_GLES2 OR ENABLE_WAYLAND_DEVICE)
target_link_libraries(stkirrlicht EGL)
endif()
if(ENABLE_WAYLAND_DEVICE)
target_link_libraries(stkirrlicht wayland-client wayland-egl wayland-cursor xkbcommon)
endif()
if(WIN32)
target_link_libraries(stkirrlicht imm32)
endif()

View File

@ -20,6 +20,9 @@ namespace irr
/** This device works on Windows Mobile, Pocket PC and Microsoft SmartPhone devices */
EIDT_WINCE,
//! A device native to Linux
EIDT_WAYLAND,
//! A device native to Unix style operating systems.
/** This device uses the X11 windowing system and works in Linux, Solaris, FreeBSD, OSX and
other operating systems which support X11. */

View File

@ -52,9 +52,6 @@ namespace video
primitives. */
EDT_OPENGL,
//! OpenGL-ES 1.x driver, for embedded and mobile systems
EDT_OGLES1,
//! OpenGL-ES 2.x driver, for embedded and mobile systems
/** Supports shaders etc. */
EDT_OGLES2,

View File

@ -98,6 +98,8 @@ public:
//! fills the surface with given color
virtual void fill(const SColor &color) =0;
virtual void setDeleteMemory(bool val) = 0;
//! get the amount of Bits per Pixel of the given color format
static u32 getBitsPerPixelFromFormat(const ECOLOR_FORMAT format)
{

View File

@ -42,7 +42,9 @@ public:
//! Creates a surface from the file
/** \param file File handle to check.
\return Pointer to newly created image, or 0 upon error. */
virtual IImage* loadImage(io::IReadFile* file) const = 0;
virtual IImage* loadImage(io::IReadFile* file, bool skip_checking = false) const = 0;
virtual core::dimension2du getImageSize(io::IReadFile* file) const { return core::dimension2du(0, 0); }
virtual bool supportThreadedLoading() const { return false; }
};

View File

@ -624,24 +624,24 @@ namespace scene
\code
SKeyMap keyMap[8];
keyMap[0].Action = EKA_MOVE_FORWARD;
keyMap[0].KeyCode = KEY_UP;
keyMap[0].KeyCode = IRR_KEY_UP;
keyMap[1].Action = EKA_MOVE_FORWARD;
keyMap[1].KeyCode = KEY_KEY_W;
keyMap[1].KeyCode = IRR_KEY_W;
keyMap[2].Action = EKA_MOVE_BACKWARD;
keyMap[2].KeyCode = KEY_DOWN;
keyMap[2].KeyCode = IRR_KEY_DOWN;
keyMap[3].Action = EKA_MOVE_BACKWARD;
keyMap[3].KeyCode = KEY_KEY_S;
keyMap[3].KeyCode = IRR_KEY_S;
keyMap[4].Action = EKA_STRAFE_LEFT;
keyMap[4].KeyCode = KEY_LEFT;
keyMap[4].KeyCode = IRR_KEY_LEFT;
keyMap[5].Action = EKA_STRAFE_LEFT;
keyMap[5].KeyCode = KEY_KEY_A;
keyMap[5].KeyCode = IRR_KEY_A;
keyMap[6].Action = EKA_STRAFE_RIGHT;
keyMap[6].KeyCode = KEY_RIGHT;
keyMap[6].KeyCode = IRR_KEY_RIGHT;
keyMap[7].Action = EKA_STRAFE_RIGHT;
keyMap[7].KeyCode = KEY_KEY_D;
keyMap[7].KeyCode = IRR_KEY_D;
camera = sceneManager->addCameraSceneNodeFPS(0, 100, 500, -1, keyMap, 8);
\endcode

View File

@ -198,6 +198,16 @@ public:
virtual u64 getHandle() = 0;
virtual void unloadHandle() {}
virtual u32 getTextureSize() const { return 0; }
virtual void threadedReload(void* ptr, void* param) const {}
virtual void threadedSubImage(void* ptr) const {}
virtual void cleanThreadedLoader() {}
virtual int getThreadedLoadTextureCounter() const { return 0; }
protected:
//! Helper function, helps to get the desired texture creation format from the flags.

View File

@ -1186,7 +1186,7 @@ namespace video
\return The created image.
If you no longer need the image, you should call IImage::drop().
See IReferenceCounted::drop() for more information. */
virtual IImage* createImageFromFile(io::IReadFile* file) =0;
virtual IImage* createImageFromFile(io::IReadFile* file, video::IImageLoader** loader = NULL) =0;
//! Writes the provided image to a file.
/** Requires that there is a suitable image writer registered

Some files were not shown because too many files have changed in this diff Show More