From 00274f070f1297adb468104fc9745a288cf449d1 Mon Sep 17 00:00:00 2001 From: Ray Date: Sat, 23 Sep 2017 00:25:31 +0200 Subject: Working on Android APK building with Makefile --- templates/android_project/AndroidManifest.xml | 2 +- templates/android_project/Makefile | 127 ++++++++++++++++++++++++++ templates/android_project/jni/basic_game.c | 2 + 3 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 templates/android_project/Makefile (limited to 'templates') diff --git a/templates/android_project/AndroidManifest.xml b/templates/android_project/AndroidManifest.xml index 1d30ab17..a740a727 100644 --- a/templates/android_project/AndroidManifest.xml +++ b/templates/android_project/AndroidManifest.xml @@ -14,7 +14,7 @@ android:versionCode="1" android:versionName="1.0" > - + diff --git a/templates/android_project/Makefile b/templates/android_project/Makefile new file mode 100644 index 00000000..caccc847 --- /dev/null +++ b/templates/android_project/Makefile @@ -0,0 +1,127 @@ +#************************************************************************************************** +# +# raylib makefile for Android project (APK building) +# +# Copyright (c) 2017 Ramon Santamaria (@raysan5) +# +# 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. +# +#************************************************************************************************** + +# Android project name (.apk) +PROJECT_NAME = NativeActivity +PROJECT_DIR = ./ + +# define raylib platform to compile for +PLATFORM ?= PLATFORM_ANDROID + + +# Required path variables +# NOTE: JAVA_HOME must be set to JDK +ANDROID_HOME = C:/android-sdk +ANDROID_NDK = C:/android-ndk +ANDROID_TOOLCHAIN = C:/android_toolchain_arm_api16 +ANDROID_BUILD_TOOLS = C:/android-sdk/build-tools/25.0.3 + +# Compilers +CC = $(ANDROID_TOOLCHAIN)/bin/arm-linux-androideabi-gcc +AR = $(ANDROID_TOOLCHAIN)/bin/arm-linux-androideabi-ar + +# define compiler flags +CFLAGS = -O2 -s -Wall -std=c99 -DPLATFORM_ANDROID -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 + +# define any directories containing required header files +INCLUDES = -I. -Ijni/include -I$(ANDROID_NDK)/sources/android/native_app_glue + +# define library paths containing required libs +LFLAGS = -L. -Ljni/libs -Ljni + +# define any libraries to link into executable +# if you want to link libraries (libname.so or libname.a), use the -lname +LIBS = -lraylib -lopenal -llog -landroid -lEGL -lGLESv2 -lOpenSLES + +# Building APK +#----------------- +# typing 'make' will invoke the default target entry called 'all', +all: native_app_glue \ + project_code \ + gen_keystore \ + project_package \ + project_class \ + project_class_dex \ + project_apk \ + apk_signing \ + apk_zip_align + +# compile native_app_glue static library +# OUTPUT $(PROJECT_DIR)/jni/libnative_app_glue.a +native_app_glue: + $(CC) -c $(ANDROID_NDK)/sources/android/native_app_glue/android_native_app_glue.c -o jni/native_app_glue.o $(CFLAGS) + $(AR) rcs $(PROJECT_DIR)/jni/libnative_app_glue.a jni/native_app_glue.o + +# compile project code as shared libraries +# OUTPUT $(PROJECT_DIR)/lib/arm64-v8a/libnative-activity.so +project_code: + $(CC) -c jni/basic_game.c -o jni/basic_game.o $(INCLUDES) -I$(ANDROID_NDK)/sources/android/native_app_glue $(CFLAGS) --sysroot=$(ANDROID_TOOLCHAIN)/sysroot -fPIC + $(CC) -o lib/libnative-activity.so jni/basic_game.o -shared $(INCLUDES) $(LFLAGS) $(LIBS) -lnative_app_glue + +# Generate key for APK +# OUTPUT $(PROJECT_DIR)/ToyKey.keystore +gen_keystore: +# $(JAVA_HOME)/bin/keytool -genkeypair -validity 1000 -dname "CN=raylib,O=Android,C=JPN" -keystore ToyKey.keystore -storepass raylib -keypass raylib -alias $(PROJECT_NAME)Key -keyalg RSA + +# Creating src/com/example/native_activity/R.java +# OUTPUT $(PROJECT_DIR)/src/com/example/native_activity/R.java +# NOTE: DEPENDS on res/values/strings.xml +project_package: + $(ANDROID_BUILD_TOOLS)/aapt package -f -m -S res -J src -M AndroidManifest.xml -I $(ANDROID_HOME)/platforms/android-16/android.jar + +# Creating obj/com/example/native_activity/R.class +# OUTPUT $(PROJECT_DIR)/obj/com/example/native_activity/R.class +project_class: + $(JAVA_HOME)/bin/javac -source 1.7 -target 1.7 -d obj -classpath $(ANDROID_HOME)/platforms/android-16/android.jar -sourcepath src src/com/raylib/game_sample/R.java + +# Creating bin/classes/dex +# OUTPUT $(PROJECT_DIR)/bin/classes.dex +# NOTE: DEPENDS on obj/com/example/native_activity/R.class +project_class_dex: + $(ANDROID_BUILD_TOOLS)/dx --dex --output=bin/classes.dex obj + +# Creating bin/$(PROJECT_NAME).unsigned.apk +# NOTE: DEPENDS on bin/classes.dex lib/arm64-v8a/libnative-activity.so +# Use -A resources to define additional directory in which to find raw asset files +project_apk: + $(ANDROID_BUILD_TOOLS)/aapt package -f -m -M AndroidManifest.xml -S res -A assets -I $(ANDROID_HOME)/platforms/android-16/android.jar -F bin/$(PROJECT_NAME).unsigned.apk -J bin + $(ANDROID_BUILD_TOOLS)/aapt add $(PROJECT_DIR)/bin/$(PROJECT_NAME).unsigned.apk lib/libnative-activity.so + +# Creating bin/$(PROJECT_NAME).signed.apk +apk_signing: + $(JAVA_HOME)/bin/jarsigner -keystore ToyKey.keystore -storepass raylib -keypass raylib -signedjar $(PROJECT_DIR)/bin/$(PROJECT_NAME).signed.apk bin/$(PROJECT_NAME).unsigned.apk $(PROJECT_NAME)Key + +# Creating bin/$(PROJECT_NAME).apk +apk_zip_align: + $(ANDROID_BUILD_TOOLS)/zipalign -f 4 bin/$(PROJECT_NAME).signed.apk bin/$(PROJECT_NAME).apk + +# Deploy to device +deploy: + $(ANDROID_HOME)/platform-tools/adb install -r bin/$(PROJECT_NAME).apk + $(ANDROID_HOME)/platform-tools/adb logcat -c + $(ANDROID_HOME)/platform-tools/adb logcat *:W + +# clean everything +clean: + del bin\* lib\* obj\* src\* /f/s/q + @echo Cleaning done diff --git a/templates/android_project/jni/basic_game.c b/templates/android_project/jni/basic_game.c index 1109f9e8..94fbc6cd 100644 --- a/templates/android_project/jni/basic_game.c +++ b/templates/android_project/jni/basic_game.c @@ -14,6 +14,8 @@ #include "raylib.h" +#include "android_native_app_glue.h" + //---------------------------------------------------------------------------------- // Types and Structures Definition //---------------------------------------------------------------------------------- -- cgit v1.2.3 From 86ebb877fe56579685299b610aab48d40a104d6d Mon Sep 17 00:00:00 2001 From: Ray Date: Sat, 23 Sep 2017 18:08:19 +0200 Subject: Working on project Makefile for Android --- templates/android_project/Makefile | 57 +++++++++++------ templates/android_project/build.xml | 92 ---------------------------- templates/android_project/project.properties | 14 ----- 3 files changed, 37 insertions(+), 126 deletions(-) delete mode 100644 templates/android_project/build.xml delete mode 100644 templates/android_project/project.properties (limited to 'templates') diff --git a/templates/android_project/Makefile b/templates/android_project/Makefile index caccc847..5e4f12ec 100644 --- a/templates/android_project/Makefile +++ b/templates/android_project/Makefile @@ -25,10 +25,16 @@ PROJECT_NAME = NativeActivity PROJECT_DIR = ./ +# Generated shared library name +# NOTE: It should match the name defined in the AndroidManifest.xml +LIBRARY_NAME = raylib_game + +KEYSTORE_USER = raylib +KEYSTORE_PASS = raylib + # define raylib platform to compile for PLATFORM ?= PLATFORM_ANDROID - # Required path variables # NOTE: JAVA_HOME must be set to JDK ANDROID_HOME = C:/android-sdk @@ -56,7 +62,8 @@ LIBS = -lraylib -lopenal -llog -landroid -lEGL -lGLESv2 -lOpenSLES # Building APK #----------------- # typing 'make' will invoke the default target entry called 'all', -all: native_app_glue \ +all: project_dirs \ + native_app_glue \ project_code \ gen_keystore \ project_package \ @@ -66,62 +73,72 @@ all: native_app_glue \ apk_signing \ apk_zip_align +# create required temp directories for APK building +project_dirs: + if not exist temp mkdir temp + if not exist temp\obj mkdir temp\obj + if not exist temp\src mkdir temp\src + if not exist temp\lib mkdir temp\lib + if not exist temp\bin mkdir temp\bin + # compile native_app_glue static library -# OUTPUT $(PROJECT_DIR)/jni/libnative_app_glue.a +# OUTPUT: $(PROJECT_DIR)/jni/libnative_app_glue.a native_app_glue: $(CC) -c $(ANDROID_NDK)/sources/android/native_app_glue/android_native_app_glue.c -o jni/native_app_glue.o $(CFLAGS) $(AR) rcs $(PROJECT_DIR)/jni/libnative_app_glue.a jni/native_app_glue.o # compile project code as shared libraries -# OUTPUT $(PROJECT_DIR)/lib/arm64-v8a/libnative-activity.so +# OUTPUT: $(PROJECT_DIR)/temp/lib/lib$(LIBRARY_NAME).so project_code: $(CC) -c jni/basic_game.c -o jni/basic_game.o $(INCLUDES) -I$(ANDROID_NDK)/sources/android/native_app_glue $(CFLAGS) --sysroot=$(ANDROID_TOOLCHAIN)/sysroot -fPIC - $(CC) -o lib/libnative-activity.so jni/basic_game.o -shared $(INCLUDES) $(LFLAGS) $(LIBS) -lnative_app_glue + $(CC) -o temp/lib/lib$(LIBRARY_NAME).so jni/basic_game.o -shared $(INCLUDES) $(LFLAGS) $(LIBS) -lnative_app_glue # Generate key for APK -# OUTPUT $(PROJECT_DIR)/ToyKey.keystore +# OUTPUT: $(PROJECT_DIR)/temp/$(PROJECT_NAME).keystore gen_keystore: -# $(JAVA_HOME)/bin/keytool -genkeypair -validity 1000 -dname "CN=raylib,O=Android,C=JPN" -keystore ToyKey.keystore -storepass raylib -keypass raylib -alias $(PROJECT_NAME)Key -keyalg RSA + $(JAVA_HOME)/bin/keytool -genkeypair -validity 1000 -dname "CN=raylib,O=Android,C=JPN" -keystore temp/$(PROJECT_NAME).keystore -storepass $(KEYSTORE_USER) -keypass $(KEYSTORE_PASS) -alias $(PROJECT_NAME)Key -keyalg RSA -# Creating src/com/example/native_activity/R.java -# OUTPUT $(PROJECT_DIR)/src/com/example/native_activity/R.java +# Creating src/com/example/$(LIBRARY_NAME)/R.java +# OUTPUT: $(PROJECT_DIR)/temp/src/com/example/$(LIBRARY_NAME)/R.java # NOTE: DEPENDS on res/values/strings.xml project_package: - $(ANDROID_BUILD_TOOLS)/aapt package -f -m -S res -J src -M AndroidManifest.xml -I $(ANDROID_HOME)/platforms/android-16/android.jar + $(ANDROID_BUILD_TOOLS)/aapt package -f -m -S res -J temp/src -M AndroidManifest.xml -I $(ANDROID_HOME)/platforms/android-16/android.jar -# Creating obj/com/example/native_activity/R.class -# OUTPUT $(PROJECT_DIR)/obj/com/example/native_activity/R.class +# Creating obj/com/example/$(LIBRARY_NAME)/R.class +# OUTPUT: $(PROJECT_DIR)/temp/obj/com/example/$(LIBRARY_NAME)/R.class project_class: - $(JAVA_HOME)/bin/javac -source 1.7 -target 1.7 -d obj -classpath $(ANDROID_HOME)/platforms/android-16/android.jar -sourcepath src src/com/raylib/game_sample/R.java + $(JAVA_HOME)/bin/javac -source 1.7 -target 1.7 -d temp/obj -classpath $(ANDROID_HOME)/platforms/android-16/android.jar -sourcepath temp/src temp/src/com/raylib/game_sample/R.java # Creating bin/classes/dex # OUTPUT $(PROJECT_DIR)/bin/classes.dex # NOTE: DEPENDS on obj/com/example/native_activity/R.class project_class_dex: - $(ANDROID_BUILD_TOOLS)/dx --dex --output=bin/classes.dex obj + $(ANDROID_BUILD_TOOLS)/dx --dex --output=temp/bin/classes.dex temp/obj # Creating bin/$(PROJECT_NAME).unsigned.apk # NOTE: DEPENDS on bin/classes.dex lib/arm64-v8a/libnative-activity.so # Use -A resources to define additional directory in which to find raw asset files project_apk: - $(ANDROID_BUILD_TOOLS)/aapt package -f -m -M AndroidManifest.xml -S res -A assets -I $(ANDROID_HOME)/platforms/android-16/android.jar -F bin/$(PROJECT_NAME).unsigned.apk -J bin - $(ANDROID_BUILD_TOOLS)/aapt add $(PROJECT_DIR)/bin/$(PROJECT_NAME).unsigned.apk lib/libnative-activity.so + $(ANDROID_BUILD_TOOLS)/aapt package -f -m -M AndroidManifest.xml -S res -A assets -I $(ANDROID_HOME)/platforms/android-16/android.jar -F temp/bin/$(PROJECT_NAME).unsigned.apk -J temp/bin + $(ANDROID_BUILD_TOOLS)/aapt add $(PROJECT_DIR)/temp/bin/$(PROJECT_NAME).unsigned.apk temp/lib/lib$(LIBRARY_NAME).so # Creating bin/$(PROJECT_NAME).signed.apk apk_signing: - $(JAVA_HOME)/bin/jarsigner -keystore ToyKey.keystore -storepass raylib -keypass raylib -signedjar $(PROJECT_DIR)/bin/$(PROJECT_NAME).signed.apk bin/$(PROJECT_NAME).unsigned.apk $(PROJECT_NAME)Key + $(JAVA_HOME)/bin/jarsigner -keystore temp/$(PROJECT_NAME).keystore -storepass $(KEYSTORE_USER) -keypass $(KEYSTORE_PASS) -signedjar $(PROJECT_DIR)/temp/bin/$(PROJECT_NAME).signed.apk temp/bin/$(PROJECT_NAME).unsigned.apk $(PROJECT_NAME)Key # Creating bin/$(PROJECT_NAME).apk apk_zip_align: - $(ANDROID_BUILD_TOOLS)/zipalign -f 4 bin/$(PROJECT_NAME).signed.apk bin/$(PROJECT_NAME).apk + $(ANDROID_BUILD_TOOLS)/zipalign -f 4 temp/bin/$(PROJECT_NAME).signed.apk $(PROJECT_NAME).apk # Deploy to device deploy: - $(ANDROID_HOME)/platform-tools/adb install -r bin/$(PROJECT_NAME).apk + $(ANDROID_HOME)/platform-tools/adb install -r $(PROJECT_NAME).apk $(ANDROID_HOME)/platform-tools/adb logcat -c $(ANDROID_HOME)/platform-tools/adb logcat *:W # clean everything clean: - del bin\* lib\* obj\* src\* /f/s/q + del temp\bin\* temp\lib\* temp\obj\* temp\src\* /f/s/q + del temp\*.keystore + rmdir temp /s /q @echo Cleaning done diff --git a/templates/android_project/build.xml b/templates/android_project/build.xml deleted file mode 100644 index 6eab44e1..00000000 --- a/templates/android_project/build.xml +++ /dev/null @@ -1,92 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/templates/android_project/project.properties b/templates/android_project/project.properties deleted file mode 100644 index 4ab12569..00000000 --- a/templates/android_project/project.properties +++ /dev/null @@ -1,14 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system edit -# "ant.properties", and override values to adapt the script to your -# project structure. -# -# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): -#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt - -# Project target. -target=android-19 -- cgit v1.2.3 From c317ffeca697315c5582015a79706c95b277300a Mon Sep 17 00:00:00 2001 From: Ray Date: Sat, 23 Sep 2017 18:24:58 +0200 Subject: Updated comments and paths --- templates/android_project/Makefile | 71 +++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 36 deletions(-) (limited to 'templates') diff --git a/templates/android_project/Makefile b/templates/android_project/Makefile index 5e4f12ec..f493a72c 100644 --- a/templates/android_project/Makefile +++ b/templates/android_project/Makefile @@ -21,6 +21,9 @@ # #************************************************************************************************** +# Define raylib platform to compile for +PLATFORM ?= PLATFORM_ANDROID + # Android project name (.apk) PROJECT_NAME = NativeActivity PROJECT_DIR = ./ @@ -29,12 +32,9 @@ PROJECT_DIR = ./ # NOTE: It should match the name defined in the AndroidManifest.xml LIBRARY_NAME = raylib_game -KEYSTORE_USER = raylib +# Generated key pass KEYSTORE_PASS = raylib -# define raylib platform to compile for -PLATFORM ?= PLATFORM_ANDROID - # Required path variables # NOTE: JAVA_HOME must be set to JDK ANDROID_HOME = C:/android-sdk @@ -46,22 +46,21 @@ ANDROID_BUILD_TOOLS = C:/android-sdk/build-tools/25.0.3 CC = $(ANDROID_TOOLCHAIN)/bin/arm-linux-androideabi-gcc AR = $(ANDROID_TOOLCHAIN)/bin/arm-linux-androideabi-ar -# define compiler flags +# Define compiler flags CFLAGS = -O2 -s -Wall -std=c99 -DPLATFORM_ANDROID -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -# define any directories containing required header files +# Define any directories containing required header files INCLUDES = -I. -Ijni/include -I$(ANDROID_NDK)/sources/android/native_app_glue -# define library paths containing required libs -LFLAGS = -L. -Ljni/libs -Ljni +# Define library paths containing required libs +LFLAGS = -L. -Ljni/libs -Ljni -Ltemp/lib -# define any libraries to link into executable +# Define any libraries to link into executable # if you want to link libraries (libname.so or libname.a), use the -lname LIBS = -lraylib -lopenal -llog -landroid -lEGL -lGLESv2 -lOpenSLES # Building APK -#----------------- -# typing 'make' will invoke the default target entry called 'all', +# NOTE: typing 'make' will invoke the default target entry called 'all', all: project_dirs \ native_app_glue \ project_code \ @@ -73,7 +72,7 @@ all: project_dirs \ apk_signing \ apk_zip_align -# create required temp directories for APK building +# Create required temp directories for APK building project_dirs: if not exist temp mkdir temp if not exist temp\obj mkdir temp\obj @@ -81,62 +80,62 @@ project_dirs: if not exist temp\lib mkdir temp\lib if not exist temp\bin mkdir temp\bin -# compile native_app_glue static library -# OUTPUT: $(PROJECT_DIR)/jni/libnative_app_glue.a +# Compile native_app_glue as static library +# OUTPUT: $(PROJECT_DIR)/temp/obj/libnative_app_glue.a native_app_glue: - $(CC) -c $(ANDROID_NDK)/sources/android/native_app_glue/android_native_app_glue.c -o jni/native_app_glue.o $(CFLAGS) - $(AR) rcs $(PROJECT_DIR)/jni/libnative_app_glue.a jni/native_app_glue.o + $(CC) -c $(ANDROID_NDK)/sources/android/native_app_glue/android_native_app_glue.c -o temp/obj/native_app_glue.o $(CFLAGS) + $(AR) rcs $(PROJECT_DIR)/temp/lib/libnative_app_glue.a temp/obj/native_app_glue.o -# compile project code as shared libraries +# Compile project code as shared libraries # OUTPUT: $(PROJECT_DIR)/temp/lib/lib$(LIBRARY_NAME).so project_code: - $(CC) -c jni/basic_game.c -o jni/basic_game.o $(INCLUDES) -I$(ANDROID_NDK)/sources/android/native_app_glue $(CFLAGS) --sysroot=$(ANDROID_TOOLCHAIN)/sysroot -fPIC - $(CC) -o temp/lib/lib$(LIBRARY_NAME).so jni/basic_game.o -shared $(INCLUDES) $(LFLAGS) $(LIBS) -lnative_app_glue + $(CC) -c jni/basic_game.c -o temp/obj/basic_game.o $(INCLUDES) $(CFLAGS) --sysroot=$(ANDROID_TOOLCHAIN)/sysroot -fPIC + $(CC) -o temp/lib/lib$(LIBRARY_NAME).so temp/obj/basic_game.o -shared $(INCLUDES) $(LFLAGS) $(LIBS) -lnative_app_glue -# Generate key for APK +# Generate key for APK signing # OUTPUT: $(PROJECT_DIR)/temp/$(PROJECT_NAME).keystore gen_keystore: - $(JAVA_HOME)/bin/keytool -genkeypair -validity 1000 -dname "CN=raylib,O=Android,C=JPN" -keystore temp/$(PROJECT_NAME).keystore -storepass $(KEYSTORE_USER) -keypass $(KEYSTORE_PASS) -alias $(PROJECT_NAME)Key -keyalg RSA + $(JAVA_HOME)/bin/keytool -genkeypair -validity 1000 -dname "CN=raylib,O=Android,C=JPN" -keystore temp/$(PROJECT_NAME).keystore -storepass $(KEYSTORE_PASS) -keypass $(KEYSTORE_PASS) -alias $(PROJECT_NAME)Key -keyalg RSA -# Creating src/com/example/$(LIBRARY_NAME)/R.java -# OUTPUT: $(PROJECT_DIR)/temp/src/com/example/$(LIBRARY_NAME)/R.java +# Create temp/src/com/raylib/$(LIBRARY_NAME)/R.java +# OUTPUT: $(PROJECT_DIR)/temp/src/com/raylib/$(LIBRARY_NAME)/R.java # NOTE: DEPENDS on res/values/strings.xml project_package: $(ANDROID_BUILD_TOOLS)/aapt package -f -m -S res -J temp/src -M AndroidManifest.xml -I $(ANDROID_HOME)/platforms/android-16/android.jar -# Creating obj/com/example/$(LIBRARY_NAME)/R.class -# OUTPUT: $(PROJECT_DIR)/temp/obj/com/example/$(LIBRARY_NAME)/R.class +# Create temp/obj/com/raylib/$(LIBRARY_NAME)/R.class +# OUTPUT: $(PROJECT_DIR)/temp/obj/com/raylib/$(LIBRARY_NAME)/R.class project_class: $(JAVA_HOME)/bin/javac -source 1.7 -target 1.7 -d temp/obj -classpath $(ANDROID_HOME)/platforms/android-16/android.jar -sourcepath temp/src temp/src/com/raylib/game_sample/R.java -# Creating bin/classes/dex -# OUTPUT $(PROJECT_DIR)/bin/classes.dex -# NOTE: DEPENDS on obj/com/example/native_activity/R.class +# Create temp/bin/classes.dex +# OUTPUT: $(PROJECT_DIR)/bin/classes.dex +# NOTE: DEPENDS on temp/obj/com/raylib/$(LIBRARY_NAME)/R.class project_class_dex: $(ANDROID_BUILD_TOOLS)/dx --dex --output=temp/bin/classes.dex temp/obj -# Creating bin/$(PROJECT_NAME).unsigned.apk -# NOTE: DEPENDS on bin/classes.dex lib/arm64-v8a/libnative-activity.so -# Use -A resources to define additional directory in which to find raw asset files +# Create temp/bin/$(PROJECT_NAME).unsigned.apk +# NOTE: DEPENDS on temp/bin/classes.dex and temp/lib/lib$(LIBRARY_NAME).so +# NOTE: Use -A resources to define additional directory in which to find raw asset files project_apk: $(ANDROID_BUILD_TOOLS)/aapt package -f -m -M AndroidManifest.xml -S res -A assets -I $(ANDROID_HOME)/platforms/android-16/android.jar -F temp/bin/$(PROJECT_NAME).unsigned.apk -J temp/bin $(ANDROID_BUILD_TOOLS)/aapt add $(PROJECT_DIR)/temp/bin/$(PROJECT_NAME).unsigned.apk temp/lib/lib$(LIBRARY_NAME).so -# Creating bin/$(PROJECT_NAME).signed.apk +# Create temp/bin/$(PROJECT_NAME).signed.apk apk_signing: - $(JAVA_HOME)/bin/jarsigner -keystore temp/$(PROJECT_NAME).keystore -storepass $(KEYSTORE_USER) -keypass $(KEYSTORE_PASS) -signedjar $(PROJECT_DIR)/temp/bin/$(PROJECT_NAME).signed.apk temp/bin/$(PROJECT_NAME).unsigned.apk $(PROJECT_NAME)Key + $(JAVA_HOME)/bin/jarsigner -keystore temp/$(PROJECT_NAME).keystore -storepass $(KEYSTORE_PASS) -keypass $(KEYSTORE_PASS) -signedjar $(PROJECT_DIR)/temp/bin/$(PROJECT_NAME).signed.apk temp/bin/$(PROJECT_NAME).unsigned.apk $(PROJECT_NAME)Key -# Creating bin/$(PROJECT_NAME).apk +# Create temp/bin/$(PROJECT_NAME).apk apk_zip_align: $(ANDROID_BUILD_TOOLS)/zipalign -f 4 temp/bin/$(PROJECT_NAME).signed.apk $(PROJECT_NAME).apk -# Deploy to device +# Deploy $(PROJECT_NAME).apk to device deploy: $(ANDROID_HOME)/platform-tools/adb install -r $(PROJECT_NAME).apk $(ANDROID_HOME)/platform-tools/adb logcat -c $(ANDROID_HOME)/platform-tools/adb logcat *:W -# clean everything +# Clean everything clean: del temp\bin\* temp\lib\* temp\obj\* temp\src\* /f/s/q del temp\*.keystore -- cgit v1.2.3 From 4a8644e999698189ffaf68f01398c092a76a6828 Mon Sep 17 00:00:00 2001 From: Ray Date: Sat, 23 Sep 2017 18:40:30 +0200 Subject: Update Android libs and building --- release/android/armeabi-v7a/libraylib.a | Bin 450664 -> 440310 bytes src/Makefile | 15 +- templates/android_project/jni/include/raylib.h | 277 +++++++++++++++++-------- templates/android_project/jni/libs/libraylib.a | Bin 442938 -> 440310 bytes 4 files changed, 201 insertions(+), 91 deletions(-) (limited to 'templates') diff --git a/release/android/armeabi-v7a/libraylib.a b/release/android/armeabi-v7a/libraylib.a index cbfa908d..6c1991be 100644 Binary files a/release/android/armeabi-v7a/libraylib.a and b/release/android/armeabi-v7a/libraylib.a differ diff --git a/src/Makefile b/src/Makefile index 06b67a04..72f37b09 100644 --- a/src/Makefile +++ b/src/Makefile @@ -97,14 +97,9 @@ ifeq ($(PLATFORM),PLATFORM_WEB) endif ifeq ($(PLATFORM),PLATFORM_ANDROID) - # Android NDK path - # NOTE: Required for standalone toolchain generation - ANDROID_NDK = $(ANDROID_NDK_HOME) - - # Android standalone toolchain path - # NOTE: This path is also used if toolchain generation - #ANDROID_TOOLCHAIN = $(CURDIR)/toolchain - ANDROID_TOOLCHAIN = $(RAYLIB_PATH)/android-toolchain + # Android required path variables + ANDROID_NDK = C:/android-ndk + ANDROID_TOOLCHAIN = C:/android_toolchain_arm_api16 # Android architecture: ARM or ARM64 ANDROID_ARCH ?= ARM @@ -217,6 +212,10 @@ ifeq ($(PLATFORM),PLATFORM_WEB) # -s USE_PTHREADS=1 # multithreading support endif +ifeq ($(PLATFORM),PLATFORM_ANDROID) + CFLAGS += -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 +endif + #CFLAGSEXTRA = -Wextra -Wmissing-prototypes -Wstrict-prototypes # if shared library required, make sure code is compiled as position independent diff --git a/templates/android_project/jni/include/raylib.h b/templates/android_project/jni/include/raylib.h index 429c26ca..07674531 100644 --- a/templates/android_project/jni/include/raylib.h +++ b/templates/android_project/jni/include/raylib.h @@ -1,6 +1,6 @@ -/********************************************************************************************** +/********************************************************************************************** * -* raylib v1.7.0 +* raylib v1.8.0 * * A simple and easy-to-use library to learn videogames programming (www.raylib.com) * @@ -291,14 +291,17 @@ #define MAGENTA CLITERAL{ 255, 0, 255, 255 } // Magenta #define RAYWHITE CLITERAL{ 245, 245, 245, 255 } // My own White (raylib logo) +// Shader and material limits +#define MAX_SHADER_LOCATIONS 32 // Maximum number of predefined locations stored in shader struct +#define MAX_MATERIAL_MAPS 12 // Maximum number of texture maps stored in shader struct + //---------------------------------------------------------------------------------- // Structures Definition //---------------------------------------------------------------------------------- #ifndef __cplusplus // Boolean type - #if !defined(_STDBOOL_H) + #if !defined(_STDBOOL_H) || !defined(__STDBOOL_H) // CLang uses second form typedef enum { false, true } bool; - #define _STDBOOL_H #endif #endif @@ -401,63 +404,46 @@ typedef struct Camera2D { // Bounding box type typedef struct BoundingBox { - Vector3 min; // minimum vertex box-corner - Vector3 max; // maximum vertex box-corner + Vector3 min; // Minimum vertex box-corner + Vector3 max; // Maximum vertex box-corner } BoundingBox; // Vertex data definning a mesh +// NOTE: Data stored in CPU memory (and GPU) typedef struct Mesh { - int vertexCount; // number of vertices stored in arrays - int triangleCount; // number of triangles stored (indexed or not) - float *vertices; // vertex position (XYZ - 3 components per vertex) (shader-location = 0) - float *texcoords; // vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1) - float *texcoords2; // vertex second texture coordinates (useful for lightmaps) (shader-location = 5) - float *normals; // vertex normals (XYZ - 3 components per vertex) (shader-location = 2) - float *tangents; // vertex tangents (XYZ - 3 components per vertex) (shader-location = 4) - unsigned char *colors; // vertex colors (RGBA - 4 components per vertex) (shader-location = 3) - unsigned short *indices;// vertex indices (in case vertex data comes indexed) + int vertexCount; // Number of vertices stored in arrays + int triangleCount; // Number of triangles stored (indexed or not) + + float *vertices; // Vertex position (XYZ - 3 components per vertex) (shader-location = 0) + float *texcoords; // Vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1) + float *texcoords2; // Vertex second texture coordinates (useful for lightmaps) (shader-location = 5) + float *normals; // Vertex normals (XYZ - 3 components per vertex) (shader-location = 2) + float *tangents; // Vertex tangents (XYZ - 3 components per vertex) (shader-location = 4) + unsigned char *colors; // Vertex colors (RGBA - 4 components per vertex) (shader-location = 3) + unsigned short *indices;// Vertex indices (in case vertex data comes indexed) unsigned int vaoId; // OpenGL Vertex Array Object id unsigned int vboId[7]; // OpenGL Vertex Buffer Objects id (7 types of vertex data) } Mesh; -// Shader type (generic shader) +// Shader type (generic) typedef struct Shader { - unsigned int id; // Shader program id - - // Vertex attributes locations (default locations) - int vertexLoc; // Vertex attribute location point (default-location = 0) - int texcoordLoc; // Texcoord attribute location point (default-location = 1) - int texcoord2Loc; // Texcoord2 attribute location point (default-location = 5) - int normalLoc; // Normal attribute location point (default-location = 2) - int tangentLoc; // Tangent attribute location point (default-location = 4) - int colorLoc; // Color attibute location point (default-location = 3) - - // Uniform locations - int mvpLoc; // ModelView-Projection matrix uniform location point (vertex shader) - int colDiffuseLoc; // Diffuse color uniform location point (fragment shader) - int colAmbientLoc; // Ambient color uniform location point (fragment shader) - int colSpecularLoc; // Specular color uniform location point (fragment shader) - - // Texture map locations (generic for any kind of map) - int mapTexture0Loc; // Map texture uniform location point (default-texture-unit = 0) - int mapTexture1Loc; // Map texture uniform location point (default-texture-unit = 1) - int mapTexture2Loc; // Map texture uniform location point (default-texture-unit = 2) + unsigned int id; // Shader program id + int locs[MAX_SHADER_LOCATIONS]; // Shader locations array } Shader; -// Material type -typedef struct Material { - Shader shader; // Standard shader (supports 3 map textures) - - Texture2D texDiffuse; // Diffuse texture (binded to shader mapTexture0Loc) - Texture2D texNormal; // Normal texture (binded to shader mapTexture1Loc) - Texture2D texSpecular; // Specular texture (binded to shader mapTexture2Loc) - - Color colDiffuse; // Diffuse color - Color colAmbient; // Ambient color - Color colSpecular; // Specular color +// Material texture map +typedef struct MaterialMap { + Texture2D texture; // Material map texture + Color color; // Material map color + float value; // Material map value +} MaterialMap; - float glossiness; // Glossiness level (Ranges from 0 to 1000) +// Material type (generic) +typedef struct Material { + Shader shader; // Material shader + MaterialMap maps[MAX_MATERIAL_MAPS]; // Material maps + float *params; // Material generic parameters (if required) } Material; // Model type @@ -473,7 +459,7 @@ typedef struct Ray { Vector3 direction; // Ray direction } Ray; -// Information returned from a raycast +// Raycast hit information typedef struct RayHitInfo { bool hit; // Did the ray hit something? float distance; // Distance to nearest hit @@ -534,13 +520,63 @@ typedef struct RRESData *RRES; //---------------------------------------------------------------------------------- // Trace log type typedef enum { - INFO = 0, - WARNING, - ERROR, - DEBUG, - OTHER + LOG_INFO = 0, + LOG_WARNING, + LOG_ERROR, + LOG_DEBUG, + LOG_OTHER } LogType; +// Shader location point type +typedef enum { + LOC_VERTEX_POSITION = 0, + LOC_VERTEX_TEXCOORD01, + LOC_VERTEX_TEXCOORD02, + LOC_VERTEX_NORMAL, + LOC_VERTEX_TANGENT, + LOC_VERTEX_COLOR, + LOC_MATRIX_MVP, + LOC_MATRIX_MODEL, + LOC_MATRIX_VIEW, + LOC_MATRIX_PROJECTION, + LOC_VECTOR_VIEW, + LOC_COLOR_DIFFUSE, + LOC_COLOR_SPECULAR, + LOC_COLOR_AMBIENT, + LOC_MAP_ALBEDO, // LOC_MAP_DIFFUSE + LOC_MAP_METALNESS, // LOC_MAP_SPECULAR + LOC_MAP_NORMAL, + LOC_MAP_ROUGHNESS, + LOC_MAP_OCCUSION, + LOC_MAP_EMISSION, + LOC_MAP_HEIGHT, + LOC_MAP_CUBEMAP, + LOC_MAP_IRRADIANCE, + LOC_MAP_PREFILTER, + LOC_MAP_BRDF +} ShaderLocationIndex; + +#define LOC_MAP_DIFFUSE LOC_MAP_ALBEDO +#define LOC_MAP_SPECULAR LOC_MAP_METALNESS + +// Material map type +typedef enum { + MAP_ALBEDO = 0, // MAP_DIFFUSE + MAP_METALNESS = 1, // MAP_SPECULAR + MAP_NORMAL = 2, + MAP_ROUGHNESS = 3, + MAP_OCCLUSION, + MAP_EMISSION, + MAP_HEIGHT, + MAP_CUBEMAP, // NOTE: Uses GL_TEXTURE_CUBE_MAP + MAP_IRRADIANCE, // NOTE: Uses GL_TEXTURE_CUBE_MAP + MAP_PREFILTER, // NOTE: Uses GL_TEXTURE_CUBE_MAP + MAP_BRDF +} TexmapIndex; + +#define MAP_DIFFUSE MAP_ALBEDO +#define MAP_SPECULAR MAP_METALNESS + // Texture formats // NOTE: Support depends on OpenGL version and platform typedef enum { @@ -653,17 +689,19 @@ extern "C" { // Prevents name mangling of functions //------------------------------------------------------------------------------------ // Window and Graphics Device Functions (Module: core) //------------------------------------------------------------------------------------ + +// Window-related functions #if defined(PLATFORM_ANDROID) RLAPI void InitWindow(int width, int height, void *state); // Initialize Android activity #elif defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI) || defined(PLATFORM_WEB) RLAPI void InitWindow(int width, int height, const char *title); // Initialize window and OpenGL context #endif - RLAPI void CloseWindow(void); // Close window and unload OpenGL context RLAPI bool WindowShouldClose(void); // Check if KEY_ESCAPE pressed or Close icon pressed RLAPI bool IsWindowMinimized(void); // Check if window has been minimized (or lost focus) RLAPI void ToggleFullscreen(void); // Toggle fullscreen mode (only PLATFORM_DESKTOP) RLAPI void SetWindowIcon(Image image); // Set icon for window (only PLATFORM_DESKTOP) +RLAPI void SetWindowTitle(const char *title); // Set title for window (only PLATFORM_DESKTOP) RLAPI void SetWindowPosition(int x, int y); // Set window position on screen (only PLATFORM_DESKTOP) RLAPI void SetWindowMonitor(int monitor); // Set monitor for the current window (fullscreen mode) RLAPI void SetWindowMinSize(int width, int height); // Set window minimum dimensions (for FLAG_WINDOW_RESIZABLE) @@ -671,6 +709,7 @@ RLAPI int GetScreenWidth(void); // Get current RLAPI int GetScreenHeight(void); // Get current screen height #if !defined(PLATFORM_ANDROID) +// Cursor-related functions RLAPI void ShowCursor(void); // Shows cursor RLAPI void HideCursor(void); // Hides cursor RLAPI bool IsCursorHidden(void); // Check if cursor is not visible @@ -678,10 +717,10 @@ RLAPI void EnableCursor(void); // Enables cur RLAPI void DisableCursor(void); // Disables cursor (lock cursor) #endif +// Drawing-related functions RLAPI void ClearBackground(Color color); // Set background color (framebuffer clear color) RLAPI void BeginDrawing(void); // Setup canvas (framebuffer) to start drawing RLAPI void EndDrawing(void); // End canvas drawing and swap buffers (double buffering) - RLAPI void Begin2dMode(Camera2D camera); // Initialize 2D mode with custom camera (2D) RLAPI void End2dMode(void); // Ends 2D mode with custom camera RLAPI void Begin3dMode(Camera camera); // Initializes 3D mode with custom camera (3D) @@ -689,29 +728,39 @@ RLAPI void End3dMode(void); // Ends 3D mod RLAPI void BeginTextureMode(RenderTexture2D target); // Initializes render texture for drawing RLAPI void EndTextureMode(void); // Ends drawing to render texture +// Screen-space-related functions RLAPI Ray GetMouseRay(Vector2 mousePosition, Camera camera); // Returns a ray trace from mouse position RLAPI Vector2 GetWorldToScreen(Vector3 position, Camera camera); // Returns the screen space position for a 3d world space position RLAPI Matrix GetCameraMatrix(Camera camera); // Returns camera transform matrix (view matrix) +// Timming-related functions RLAPI void SetTargetFPS(int fps); // Set target FPS (maximum) RLAPI int GetFPS(void); // Returns current FPS RLAPI float GetFrameTime(void); // Returns time in seconds for last frame drawn -RLAPI Color GetColor(int hexValue); // Returns a Color struct from hexadecimal value +// Color-related functions RLAPI int GetHexValue(Color color); // Returns hexadecimal value for a Color +RLAPI Color GetColor(int hexValue); // Returns a Color struct from hexadecimal value +RLAPI Color Fade(Color color, float alpha); // Color fade-in or fade-out, alpha goes from 0.0f to 1.0f RLAPI float *ColorToFloat(Color color); // Converts Color to float array and normalizes -RLAPI float *VectorToFloat(Vector3 vec); // Converts Vector3 to float array -RLAPI float *MatrixToFloat(Matrix mat); // Converts Matrix to float array -RLAPI int GetRandomValue(int min, int max); // Returns a random value between min and max (both included) -RLAPI Color Fade(Color color, float alpha); // Color fade-in or fade-out, alpha goes from 0.0f to 1.0f +// Math useful functions (available from raymath.h) +RLAPI float *VectorToFloat(Vector3 vec); // Returns Vector3 as float array +RLAPI float *MatrixToFloat(Matrix mat); // Returns Matrix as float array +RLAPI Vector3 Vector3Zero(void); // Vector with components value 0.0f +RLAPI Vector3 Vector3One(void); // Vector with components value 1.0f +RLAPI Matrix MatrixIdentity(void); // Returns identity matrix +// Misc. functions RLAPI void ShowLogo(void); // Activate raylib logo at startup (can be done with flags) RLAPI void SetConfigFlags(char flags); // Setup window configuration flags (view FLAGS) -RLAPI void TraceLog(int logType, const char *text, ...); // Show trace log messages (INFO, WARNING, ERROR, DEBUG) +RLAPI void TraceLog(int logType, const char *text, ...); // Show trace log messages (LOG_INFO, LOG_WARNING, LOG_ERROR, LOG_DEBUG) RLAPI void TakeScreenshot(const char *fileName); // Takes a screenshot of current screen (saved a .png) +RLAPI int GetRandomValue(int min, int max); // Returns a random value between min and max (both included) +// Files management functions RLAPI bool IsFileExtension(const char *fileName, const char *ext);// Check file extension +RLAPI const char *GetExtension(const char *fileName); // Get file extension RLAPI const char *GetDirectoryPath(const char *fileName); // Get directory for a given fileName (with path) RLAPI const char *GetWorkingDirectory(void); // Get current working directory RLAPI bool ChangeDirectory(const char *dir); // Change working directory, returns true if success @@ -719,12 +768,15 @@ RLAPI bool IsFileDropped(void); // Check if a RLAPI char **GetDroppedFiles(int *count); // Get dropped files names RLAPI void ClearDroppedFiles(void); // Clear dropped files paths buffer +// Persistent storage management RLAPI void StorageSaveValue(int position, int value); // Save integer value to storage file (to defined position) RLAPI int StorageLoadValue(int position); // Load integer value from storage file (from defined position) //------------------------------------------------------------------------------------ // Input Handling Functions (Module: core) //------------------------------------------------------------------------------------ + +// Input-related functions: keyboard RLAPI bool IsKeyPressed(int key); // Detect if a key has been pressed once RLAPI bool IsKeyDown(int key); // Detect if a key is being pressed RLAPI bool IsKeyReleased(int key); // Detect if a key has been released once @@ -732,6 +784,7 @@ RLAPI bool IsKeyUp(int key); // Detect if a key RLAPI int GetKeyPressed(void); // Get latest key pressed RLAPI void SetExitKey(int key); // Set a custom key to exit program (default is ESC) +// Input-related functions: gamepads RLAPI bool IsGamepadAvailable(int gamepad); // Detect if a gamepad is available RLAPI bool IsGamepadName(int gamepad, const char *name); // Check gamepad name (if available) RLAPI const char *GetGamepadName(int gamepad); // Return gamepad internal name id @@ -743,6 +796,7 @@ RLAPI int GetGamepadButtonPressed(void); // Get the last ga RLAPI int GetGamepadAxisCount(int gamepad); // Return gamepad axis count for a gamepad RLAPI float GetGamepadAxisMovement(int gamepad, int axis); // Return axis movement value for a gamepad axis +// Input-related functions: mouse RLAPI bool IsMouseButtonPressed(int button); // Detect if a mouse button has been pressed once RLAPI bool IsMouseButtonDown(int button); // Detect if a mouse button is being pressed RLAPI bool IsMouseButtonReleased(int button); // Detect if a mouse button has been released once @@ -753,6 +807,7 @@ RLAPI Vector2 GetMousePosition(void); // Returns mouse p RLAPI void SetMousePosition(Vector2 position); // Set mouse position XY RLAPI int GetMouseWheelMove(void); // Returns mouse wheel movement Y +// Input-related functions: touch RLAPI int GetTouchX(void); // Returns touch position X for touch point 0 (relative to screen size) RLAPI int GetTouchY(void); // Returns touch position Y for touch point 0 (relative to screen size) RLAPI Vector2 GetTouchPosition(int index); // Returns touch position XY for a touch point index (relative to screen size) @@ -786,6 +841,8 @@ RLAPI void SetCameraMoveControls(int frontKey, int backKey, //------------------------------------------------------------------------------------ // Basic Shapes Drawing Functions (Module: shapes) //------------------------------------------------------------------------------------ + +// Basic shapes drawing functions RLAPI void DrawPixel(int posX, int posY, Color color); // Draw a pixel RLAPI void DrawPixelV(Vector2 position, Color color); // Draw a pixel (Vector version) RLAPI void DrawLine(int startPosX, int startPosY, int endPosX, int endPosY, Color color); // Draw a line @@ -800,14 +857,17 @@ RLAPI void DrawRectangle(int posX, int posY, int width, int height, Color color) RLAPI void DrawRectangleRec(Rectangle rec, Color color); // Draw a color-filled rectangle RLAPI void DrawRectanglePro(Rectangle rec, Vector2 origin, float rotation, Color color); // Draw a color-filled rectangle with pro parameters RLAPI void DrawRectangleGradient(int posX, int posY, int width, int height, Color color1, Color color2); // Draw a gradient-filled rectangle +RLAPI void DrawRectangleGradientEx(Rectangle rec, Color col1, Color col2, Color col3, Color col4); // Draw a gradient-filled rectangle with custom vertex colors RLAPI void DrawRectangleV(Vector2 position, Vector2 size, Color color); // Draw a color-filled rectangle (Vector version) RLAPI void DrawRectangleLines(int posX, int posY, int width, int height, Color color); // Draw rectangle outline +RLAPI void DrawRectangleT(int posX, int posY, int width, int height, Color color); // Draw rectangle using text character RLAPI void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color); // Draw a color-filled triangle RLAPI void DrawTriangleLines(Vector2 v1, Vector2 v2, Vector2 v3, Color color); // Draw triangle outline RLAPI void DrawPoly(Vector2 center, int sides, float radius, float rotation, Color color); // Draw a regular polygon (Vector version) RLAPI void DrawPolyEx(Vector2 *points, int numPoints, Color color); // Draw a closed polygon defined by points RLAPI void DrawPolyExLines(Vector2 *points, int numPoints, Color color); // Draw polygon lines +// Basic shapes collision detection functions RLAPI bool CheckCollisionRecs(Rectangle rec1, Rectangle rec2); // Check collision between two rectangles RLAPI bool CheckCollisionCircles(Vector2 center1, float radius1, Vector2 center2, float radius2); // Check collision between two circles RLAPI bool CheckCollisionCircleRec(Vector2 center, float radius, Rectangle rec); // Check collision between circle and rectangle @@ -819,6 +879,8 @@ RLAPI bool CheckCollisionPointTriangle(Vector2 point, Vector2 p1, Vector2 p2, Ve //------------------------------------------------------------------------------------ // Texture Loading and Drawing Functions (Module: textures) //------------------------------------------------------------------------------------ + +// Image/Texture2D data loading/unloading/saving functions RLAPI Image LoadImage(const char *fileName); // Load image from file into CPU memory (RAM) RLAPI Image LoadImageEx(Color *pixels, int width, int height); // Load image from Color array data (RGBA - 32bit) RLAPI Image LoadImagePro(void *data, int width, int height, int format); // Load image from raw data with parameters @@ -832,6 +894,9 @@ RLAPI void UnloadRenderTexture(RenderTexture2D target); RLAPI Color *GetImageData(Image image); // Get pixel data from image as a Color struct array RLAPI Image GetTextureData(Texture2D texture); // Get pixel data from GPU texture and return an Image RLAPI void UpdateTexture(Texture2D texture, const void *pixels); // Update GPU texture with new data +RLAPI void SaveImageAs(const char *fileName, Image image); // Save image to a PNG file + +// Image manipulation functions RLAPI void ImageToPOT(Image *image, Color fillColor); // Convert image to POT (power-of-two) RLAPI void ImageFormat(Image *image, int newFormat); // Convert image data to desired format RLAPI void ImageAlphaMask(Image *image, Image alphaMask); // Apply alpha mask to image @@ -853,10 +918,22 @@ RLAPI void ImageColorInvert(Image *image); RLAPI void ImageColorGrayscale(Image *image); // Modify image color: grayscale RLAPI void ImageColorContrast(Image *image, float contrast); // Modify image color: contrast (-100 to 100) RLAPI void ImageColorBrightness(Image *image, int brightness); // Modify image color: brightness (-255 to 255) + +// Image generation functions +RLAPI Image GenImageGradientV(int width, int height, Color top, Color bottom); // Generate image: vertical gradient +RLAPI Image GenImageGradientH(int width, int height, Color left, Color right); // Generate image: horizontal gradient +RLAPI Image GenImageGradientRadial(int width, int height, float density, Color inner, Color outer); // Generate image: radial gradient +RLAPI Image GenImageChecked(int width, int height, int checksX, int checksY, Color col1, Color col2); // Generate image: checked +RLAPI Image GenImageWhiteNoise(int width, int height, float factor); // Generate image: white noise +RLAPI Image GenImagePerlinNoise(int width, int height, float scale); // Generate image: perlin noise +RLAPI Image GenImageCellular(int width, int height, int tileSize); // Generate image: cellular algorithm. Bigger tileSize means bigger cells + +// Texture2D configuration functions RLAPI void GenTextureMipmaps(Texture2D *texture); // Generate GPU mipmaps for a texture RLAPI void SetTextureFilter(Texture2D texture, int filterMode); // Set texture scaling filter mode RLAPI void SetTextureWrap(Texture2D texture, int wrapMode); // Set texture wrapping mode +// Texture2D drawing functions RLAPI void DrawTexture(Texture2D texture, int posX, int posY, Color tint); // Draw a Texture2D RLAPI void DrawTextureV(Texture2D texture, Vector2 position, Color tint); // Draw a Texture2D with position defined as Vector2 RLAPI void DrawTextureEx(Texture2D texture, Vector2 position, float rotation, float scale, Color tint); // Draw a Texture2D with extended parameters @@ -867,24 +944,30 @@ RLAPI void DrawTexturePro(Texture2D texture, Rectangle sourceRec, Rectangle dest //------------------------------------------------------------------------------------ // Font Loading and Text Drawing Functions (Module: text) //------------------------------------------------------------------------------------ + +// SpriteFont loading/unloading functions RLAPI SpriteFont GetDefaultFont(void); // Get the default SpriteFont RLAPI SpriteFont LoadSpriteFont(const char *fileName); // Load SpriteFont from file into GPU memory (VRAM) RLAPI SpriteFont LoadSpriteFontEx(const char *fileName, int fontSize, int charsCount, int *fontChars); // Load SpriteFont from file with extended parameters RLAPI void UnloadSpriteFont(SpriteFont spriteFont); // Unload SpriteFont from GPU memory (VRAM) +// Text drawing functions +RLAPI void DrawFPS(int posX, int posY); // Shows current FPS RLAPI void DrawText(const char *text, int posX, int posY, int fontSize, Color color); // Draw text (using default font) RLAPI void DrawTextEx(SpriteFont spriteFont, const char* text, Vector2 position, // Draw text using SpriteFont and additional parameters float fontSize, int spacing, Color tint); + +// Text misc. functions RLAPI int MeasureText(const char *text, int fontSize); // Measure string width for default font RLAPI Vector2 MeasureTextEx(SpriteFont spriteFont, const char *text, float fontSize, int spacing); // Measure string size for SpriteFont - -RLAPI void DrawFPS(int posX, int posY); // Shows current FPS RLAPI const char *FormatText(const char *text, ...); // Formatting of text with variables to 'embed' RLAPI const char *SubText(const char *text, int position, int length); // Get a piece of a text string //------------------------------------------------------------------------------------ // Basic 3d Shapes Drawing Functions (Module: models) //------------------------------------------------------------------------------------ + +// Basic geometric 3D shapes drawing functions RLAPI void DrawLine3D(Vector3 startPos, Vector3 endPos, Color color); // Draw a line in 3D world space RLAPI void DrawCircle3D(Vector3 center, float radius, Vector3 rotationAxis, float rotationAngle, Color color); // Draw a circle in 3D world space RLAPI void DrawCube(Vector3 position, float width, float height, float length, Color color); // Draw cube @@ -905,19 +988,33 @@ RLAPI void DrawGizmo(Vector3 position); //------------------------------------------------------------------------------------ // Model 3d Loading and Drawing Functions (Module: models) //------------------------------------------------------------------------------------ + +// Model loading/unloading functions +RLAPI Model LoadModel(const char *fileName); // Load model from files (mesh and material) +RLAPI Model LoadModelFromMesh(Mesh mesh); // Load model from generated mesh +RLAPI void UnloadModel(Model model); // Unload model from memory (RAM and/or VRAM) + +// Mesh loading/unloading functions RLAPI Mesh LoadMesh(const char *fileName); // Load mesh from file -RLAPI Mesh LoadMeshEx(int numVertex, float *vData, float *vtData, float *vnData, Color *cData); // Load mesh from vertex data -RLAPI Model LoadModel(const char *fileName); // Load model from file -RLAPI Model LoadModelFromMesh(Mesh data, bool dynamic); // Load model from mesh data -RLAPI Model LoadHeightmap(Image heightmap, Vector3 size); // Load heightmap model from image data -RLAPI Model LoadCubicmap(Image cubicmap); // Load cubes-based map model from image data RLAPI void UnloadMesh(Mesh *mesh); // Unload mesh from memory (RAM and/or VRAM) -RLAPI void UnloadModel(Model model); // Unload model from memory (RAM and/or VRAM) +// Mesh generation functions +RLAPI Mesh GenMeshPlane(float width, float length, int resX, int resZ); // Generate plane mesh (with subdivisions) +RLAPI Mesh GenMeshCube(float width, float height, float length); // Generate cuboid mesh +RLAPI Mesh GenMeshSphere(float radius, int rings, int slices); // Generate sphere mesh (standard sphere) +RLAPI Mesh GenMeshHemiSphere(float radius, int rings, int slices); // Generate half-sphere mesh (no bottom cap) +RLAPI Mesh GenMeshCylinder(float radius, float height, int slices); // Generate cylinder mesh +RLAPI Mesh GenMeshTorus(float radius, float size, int radSeg, int sides); // Generate torus mesh +RLAPI Mesh GenMeshKnot(float radius, float size, int radSeg, int sides); // Generate trefoil knot mesh +RLAPI Mesh GenMeshHeightmap(Image heightmap, Vector3 size); // Generate heightmap mesh from image data +RLAPI Mesh GenMeshCubicmap(Image cubicmap, Vector3 cubeSize); // Generate cubes-based map mesh from image data + +// Material loading/unloading functions RLAPI Material LoadMaterial(const char *fileName); // Load material from file -RLAPI Material LoadDefaultMaterial(void); // Load default material (uses default models shader) +RLAPI Material LoadMaterialDefault(void); // Load default material (Supports: DIFFUSE, SPECULAR, NORMAL maps) RLAPI void UnloadMaterial(Material material); // Unload material from GPU memory (VRAM) +// Model drawing functions RLAPI void DrawModel(Model model, Vector3 position, float scale, Color tint); // Draw a model (with texture if set) RLAPI void DrawModelEx(Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint); // Draw a model with extended parameters @@ -925,11 +1022,11 @@ RLAPI void DrawModelWires(Model model, Vector3 position, float scale, Color tint RLAPI void DrawModelWiresEx(Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint); // Draw a model wires (with texture if set) with extended parameters RLAPI void DrawBoundingBox(BoundingBox box, Color color); // Draw bounding box (wires) - RLAPI void DrawBillboard(Camera camera, Texture2D texture, Vector3 center, float size, Color tint); // Draw a billboard texture RLAPI void DrawBillboardRec(Camera camera, Texture2D texture, Rectangle sourceRec, Vector3 center, float size, Color tint); // Draw a billboard texture defined by sourceRec +// Collision detection functions RLAPI BoundingBox CalculateBoundingBox(Mesh mesh); // Calculate mesh bounding box limits RLAPI bool CheckCollisionSpheres(Vector3 centerA, float radiusA, Vector3 centerB, float radiusB); // Detect collision between two spheres RLAPI bool CheckCollisionBoxes(BoundingBox box1, BoundingBox box2); // Detect collision between two bounding boxes @@ -946,46 +1043,56 @@ RLAPI RayHitInfo GetCollisionRayGround(Ray ray, float groundHeight); // Shaders System Functions (Module: rlgl) // NOTE: This functions are useless when using OpenGL 1.1 //------------------------------------------------------------------------------------ + +// Shader loading/unloading functions RLAPI char *LoadText(const char *fileName); // Load chars array from text file RLAPI Shader LoadShader(char *vsFileName, char *fsFileName); // Load shader from files and bind default locations RLAPI void UnloadShader(Shader shader); // Unload shader from GPU memory (VRAM) -RLAPI Shader GetDefaultShader(void); // Get default shader -RLAPI Texture2D GetDefaultTexture(void); // Get default texture +RLAPI Shader GetShaderDefault(void); // Get default shader +RLAPI Texture2D GetTextureDefault(void); // Get default texture +// Shader configuration functions RLAPI int GetShaderLocation(Shader shader, const char *uniformName); // Get shader uniform location RLAPI void SetShaderValue(Shader shader, int uniformLoc, float *value, int size); // Set shader uniform value (float) RLAPI void SetShaderValuei(Shader shader, int uniformLoc, int *value, int size); // Set shader uniform value (int) RLAPI void SetShaderValueMatrix(Shader shader, int uniformLoc, Matrix mat); // Set shader uniform value (matrix 4x4) - RLAPI void SetMatrixProjection(Matrix proj); // Set a custom projection matrix (replaces internal projection matrix) RLAPI void SetMatrixModelview(Matrix view); // Set a custom modelview matrix (replaces internal modelview matrix) +// Texture maps generation (PBR) +// NOTE: Required shaders should be provided +RLAPI Texture2D GenTextureCubemap(Shader shader, Texture2D skyHDR, int size); // Generate cubemap texture from HDR texture +RLAPI Texture2D GenTextureIrradiance(Shader shader, Texture2D cubemap, int size); // Generate irradiance texture using cubemap data +RLAPI Texture2D GenTexturePrefilter(Shader shader, Texture2D cubemap, int size); // Generate prefilter texture using cubemap data +RLAPI Texture2D GenTextureBRDF(Shader shader, Texture2D cubemap, int size); // Generate BRDF texture using cubemap data + +// Shading begin/end functions RLAPI void BeginShaderMode(Shader shader); // Begin custom shader drawing RLAPI void EndShaderMode(void); // End custom shader drawing (use default shader) RLAPI void BeginBlendMode(int mode); // Begin blending mode (alpha, additive, multiplied) RLAPI void EndBlendMode(void); // End blending mode (reset to default: alpha blending) -//------------------------------------------------------------------------------------ -// VR experience Functions (Module: rlgl) -// NOTE: This functions are useless when using OpenGL 1.1 -//------------------------------------------------------------------------------------ +// VR control functions RLAPI void InitVrSimulator(int vrDevice); // Init VR simulator for selected device RLAPI void CloseVrSimulator(void); // Close VR simulator for current device -RLAPI bool IsVrSimulatorReady(void); // Detect if VR device is ready +RLAPI bool IsVrSimulatorReady(void); // Detect if VR simulator is ready RLAPI void UpdateVrTracking(Camera *camera); // Update VR tracking (position and orientation) and camera -RLAPI void ToggleVrMode(void); // Enable/Disable VR experience (device or simulator) +RLAPI void ToggleVrMode(void); // Enable/Disable VR experience RLAPI void BeginVrDrawing(void); // Begin VR simulator stereo rendering RLAPI void EndVrDrawing(void); // End VR simulator stereo rendering //------------------------------------------------------------------------------------ // Audio Loading and Playing Functions (Module: audio) //------------------------------------------------------------------------------------ + +// Audio device management functions RLAPI void InitAudioDevice(void); // Initialize audio device and context RLAPI void CloseAudioDevice(void); // Close the audio device and context RLAPI bool IsAudioDeviceReady(void); // Check if audio device has been initialized successfully RLAPI void SetMasterVolume(float volume); // Set master volume (listener) +// Wave/Sound loading/unloading functions RLAPI Wave LoadWave(const char *fileName); // Load wave data from file RLAPI Wave LoadWaveEx(void *data, int sampleCount, int sampleRate, int sampleSize, int channels); // Load wave data from raw array data RLAPI Sound LoadSound(const char *fileName); // Load sound from file @@ -993,6 +1100,8 @@ RLAPI Sound LoadSoundFromWave(Wave wave); // Load so RLAPI void UpdateSound(Sound sound, const void *data, int samplesCount);// Update sound buffer with new data RLAPI void UnloadWave(Wave wave); // Unload wave data RLAPI void UnloadSound(Sound sound); // Unload sound + +// Wave/Sound management functions RLAPI void PlaySound(Sound sound); // Play a sound RLAPI void PauseSound(Sound sound); // Pause a sound RLAPI void ResumeSound(Sound sound); // Resume a paused sound @@ -1004,6 +1113,8 @@ RLAPI void WaveFormat(Wave *wave, int sampleRate, int sampleSize, int channels); RLAPI Wave WaveCopy(Wave wave); // Copy a wave to a new wave RLAPI void WaveCrop(Wave *wave, int initSample, int finalSample); // Crop a wave to defined samples range RLAPI float *GetWaveData(Wave wave); // Get samples data from wave as a floats array + +// Music management functions RLAPI Music LoadMusicStream(const char *fileName); // Load music stream from file RLAPI void UnloadMusicStream(Music music); // Unload music stream RLAPI void PlayMusicStream(Music music); // Start music playing @@ -1018,8 +1129,8 @@ RLAPI void SetMusicLoopCount(Music music, float count); // Set mus RLAPI float GetMusicTimeLength(Music music); // Get music time length (in seconds) RLAPI float GetMusicTimePlayed(Music music); // Get current music time played (in seconds) -RLAPI AudioStream InitAudioStream(unsigned int sampleRate, - unsigned int sampleSize, +// AudioStream management functions +RLAPI AudioStream InitAudioStream(unsigned int sampleRate, unsigned int sampleSize, unsigned int channels); // Init audio stream (to stream raw audio pcm data) RLAPI void UpdateAudioStream(AudioStream stream, const void *data, int samplesCount); // Update audio stream buffers with data RLAPI void CloseAudioStream(AudioStream stream); // Close audio stream and free memory diff --git a/templates/android_project/jni/libs/libraylib.a b/templates/android_project/jni/libs/libraylib.a index 5a958019..6c1991be 100644 Binary files a/templates/android_project/jni/libs/libraylib.a and b/templates/android_project/jni/libs/libraylib.a differ -- cgit v1.2.3 From 8462ed73fe594f1e53365a3b7f619be9d62eb0f5 Mon Sep 17 00:00:00 2001 From: raysan5 Date: Sat, 23 Sep 2017 19:41:02 +0200 Subject: Added JAVA_HOME --- templates/android_project/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'templates') diff --git a/templates/android_project/Makefile b/templates/android_project/Makefile index f493a72c..991843ae 100644 --- a/templates/android_project/Makefile +++ b/templates/android_project/Makefile @@ -40,7 +40,8 @@ KEYSTORE_PASS = raylib ANDROID_HOME = C:/android-sdk ANDROID_NDK = C:/android-ndk ANDROID_TOOLCHAIN = C:/android_toolchain_arm_api16 -ANDROID_BUILD_TOOLS = C:/android-sdk/build-tools/25.0.3 +ANDROID_BUILD_TOOLS = C:/android-sdk/build-tools/26.0.1 +JAVA_HOME = C:/PROGRA~1/Java/jdk1.8.0_25 # Compilers CC = $(ANDROID_TOOLCHAIN)/bin/arm-linux-androideabi-gcc -- cgit v1.2.3