From 28f509d9f48d165bb38e956eb8a8805c405115c4 Mon Sep 17 00:00:00 2001 From: joliver82 <39382046+joliver82@users.noreply.github.com> Date: Thu, 17 May 2018 23:07:23 +0200 Subject: [PATCH 1/8] Update GLImageFormats.java --- .../src/main/java/com/jme3/renderer/opengl/GLImageFormats.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jme3-core/src/main/java/com/jme3/renderer/opengl/GLImageFormats.java b/jme3-core/src/main/java/com/jme3/renderer/opengl/GLImageFormats.java index 21070227b1..fb46b0805e 100644 --- a/jme3-core/src/main/java/com/jme3/renderer/opengl/GLImageFormats.java +++ b/jme3-core/src/main/java/com/jme3/renderer/opengl/GLImageFormats.java @@ -220,7 +220,7 @@ public static GLImageFormat[][] getFormatsForCaps(EnumSet caps) { // NOTE: OpenGL ES 2.0 does not support DEPTH_COMPONENT as internal format -- fallback to 16-bit depth. if (caps.contains(Caps.OpenGLES20)) { - format(formatToGL, Format.Depth, GL.GL_DEPTH_COMPONENT16, GL.GL_DEPTH_COMPONENT, GL.GL_UNSIGNED_BYTE); + format(formatToGL, Format.Depth, GL.GL_DEPTH_COMPONENT16, GL.GL_DEPTH_COMPONENT, GL.GL_UNSIGNED_SHORT); } else { format(formatToGL, Format.Depth, GL.GL_DEPTH_COMPONENT, GL.GL_DEPTH_COMPONENT, GL.GL_UNSIGNED_BYTE); } From 18b431f64739d9b049323659aa8e7986a56fbf77 Mon Sep 17 00:00:00 2001 From: joliver82 Date: Tue, 19 Nov 2019 19:45:02 +0100 Subject: [PATCH 2/8] Modified JmeBatchRenderBackend to clear the inner buffer of the image in the atlases instead of setting a predefined byte buffer on disposal that made all atlases in the backend use the same buffer and generated rendering issues. --- .../jme3/niftygui/JmeBatchRenderBackend.java | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/jme3-niftygui/src/main/java/com/jme3/niftygui/JmeBatchRenderBackend.java b/jme3-niftygui/src/main/java/com/jme3/niftygui/JmeBatchRenderBackend.java index a8947fdea6..845ef594a7 100644 --- a/jme3-niftygui/src/main/java/com/jme3/niftygui/JmeBatchRenderBackend.java +++ b/jme3-niftygui/src/main/java/com/jme3/niftygui/JmeBatchRenderBackend.java @@ -89,7 +89,6 @@ public class JmeBatchRenderBackend implements BatchRenderBackend { private int textureAtlasId = 1; private Batch currentBatch; private Matrix4f tempMat = new Matrix4f(); - private ByteBuffer initialData; // this is only used for debugging purpose and will make the removed textures filled with a color // please note: the old way to init this via a system property has been @@ -184,15 +183,6 @@ public void disableMouseCursor() { public int createTextureAtlas(final int width, final int height) { try { int atlasId = addTexture(createAtlasTextureInternal(width, height)); - - // we just initialize a second buffer here that will replace the texture atlas image - initialData = BufferUtils.createByteBuffer(width*height*4); - for (int i=0; i Date: Thu, 19 Dec 2019 02:59:33 +0100 Subject: [PATCH 3/8] First impl of testcasefor multiple atlases issue. Still missing to add more images to the screens so it really uses more atlases --- .../TestNiftyBatchMultipleAtlases.java | 107 ++++++++++++++++++ .../Nifty/NiftyBatchMultipleAtlases.xml | 58 ++++++++++ 2 files changed, 165 insertions(+) create mode 100644 jme3-examples/src/main/java/jme3test/niftygui/TestNiftyBatchMultipleAtlases.java create mode 100644 jme3-examples/src/main/resources/Interface/Nifty/NiftyBatchMultipleAtlases.xml diff --git a/jme3-examples/src/main/java/jme3test/niftygui/TestNiftyBatchMultipleAtlases.java b/jme3-examples/src/main/java/jme3test/niftygui/TestNiftyBatchMultipleAtlases.java new file mode 100644 index 0000000000..6de8c4b235 --- /dev/null +++ b/jme3-examples/src/main/java/jme3test/niftygui/TestNiftyBatchMultipleAtlases.java @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2009-2019 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package jme3test.niftygui; + +import com.jme3.app.SimpleApplication; +import com.jme3.niftygui.NiftyJmeDisplay; +import de.lessvoid.nifty.Nifty; +import de.lessvoid.nifty.render.batch.BatchRenderConfiguration; +import de.lessvoid.nifty.screen.Screen; +import de.lessvoid.nifty.screen.ScreenController; + +public class TestNiftyBatchMultipleAtlases extends SimpleApplication implements ScreenController { + + private Nifty nifty; + + public static void main(String[] args){ + TestNiftyBatchMultipleAtlases app = new TestNiftyBatchMultipleAtlases(); + app.setPauseOnLostFocus(false); + app.start(); + } + + @Override + public void simpleInitApp() { + + BatchRenderConfiguration batchConfig = new BatchRenderConfiguration(); + batchConfig.atlasWidth = 256; + batchConfig.atlasHeight = 256; + batchConfig.atlasPadding = 2; + batchConfig.atlasTolerance = 0.5f; + batchConfig.fillRemovedImagesInAtlas = false; + batchConfig.disposeImagesBetweenScreens = true; + batchConfig.initialAtlasCount = 3; + + NiftyJmeDisplay niftyDisplay = NiftyJmeDisplay.newNiftyJmeDisplay( + assetManager, + inputManager, + audioRenderer, + guiViewPort, + batchConfig); + nifty = niftyDisplay.getNifty(); + nifty.loadControlFile("nifty-default-controls.xml"); + nifty.loadStyleFile("nifty-default-styles.xml"); + nifty.fromXml("Interface/Nifty/NiftyBatchMultipleAtlases.xml", "screen1", this); + + // attach the nifty display to the gui view port as a processor + guiViewPort.addProcessor(niftyDisplay); + + // disable the fly cam + flyCam.setEnabled(false); + flyCam.setDragToRotate(true); + inputManager.setCursorVisible(true); + } + + @Override + public void bind(Nifty nifty, Screen screen) { + System.out.println("bind(" + screen.getScreenId() + ")"); + } + + @Override + public void onStartScreen() { + System.out.println("onStartScreen"); + } + + @Override + public void onEndScreen() { + System.out.println("onEndScreen"); + } + + public void quit(){ + nifty.gotoScreen("end"); + } + + public void gotoScreen(String screen) { + nifty.gotoScreen(screen); + } + +} diff --git a/jme3-examples/src/main/resources/Interface/Nifty/NiftyBatchMultipleAtlases.xml b/jme3-examples/src/main/resources/Interface/Nifty/NiftyBatchMultipleAtlases.xml new file mode 100644 index 0000000000..e32550d8d7 --- /dev/null +++ b/jme3-examples/src/main/resources/Interface/Nifty/NiftyBatchMultipleAtlases.xml @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 8a90e91ea86764c8913104c8389a61b014596ce8 Mon Sep 17 00:00:00 2001 From: Jesus Oliver Date: Mon, 25 Jan 2021 19:23:39 +0100 Subject: [PATCH 4/8] Manual merge pending stuff from jme3 base --- .../com/jme3/niftygui/JmeBatchRenderBackend.java | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/jme3-niftygui/src/main/java/com/jme3/niftygui/JmeBatchRenderBackend.java b/jme3-niftygui/src/main/java/com/jme3/niftygui/JmeBatchRenderBackend.java index 49165df640..429a21c896 100644 --- a/jme3-niftygui/src/main/java/com/jme3/niftygui/JmeBatchRenderBackend.java +++ b/jme3-niftygui/src/main/java/com/jme3/niftygui/JmeBatchRenderBackend.java @@ -209,17 +209,8 @@ public int createTextureAtlas(final int width, final int height) { @Override public void clearTextureAtlas(final int atlasId) { - com.jme3.texture.Image atlasImage=getTextureAtlas(atlasId).getImage(); - ByteBuffer atlasBuffer=atlasImage.getData(0); - atlasBuffer.rewind(); - for (int i=0; i Date: Mon, 25 Jan 2021 19:24:39 +0100 Subject: [PATCH 5/8] Manual merge --- .../TestNiftyBatchMultipleAtlases.java | 107 ------------------ .../Nifty/NiftyBatchMultipleAtlases.xml | 58 ---------- 2 files changed, 165 deletions(-) delete mode 100644 jme3-examples/src/main/java/jme3test/niftygui/TestNiftyBatchMultipleAtlases.java delete mode 100644 jme3-examples/src/main/resources/Interface/Nifty/NiftyBatchMultipleAtlases.xml diff --git a/jme3-examples/src/main/java/jme3test/niftygui/TestNiftyBatchMultipleAtlases.java b/jme3-examples/src/main/java/jme3test/niftygui/TestNiftyBatchMultipleAtlases.java deleted file mode 100644 index 6de8c4b235..0000000000 --- a/jme3-examples/src/main/java/jme3test/niftygui/TestNiftyBatchMultipleAtlases.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2009-2019 jMonkeyEngine - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'jMonkeyEngine' nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package jme3test.niftygui; - -import com.jme3.app.SimpleApplication; -import com.jme3.niftygui.NiftyJmeDisplay; -import de.lessvoid.nifty.Nifty; -import de.lessvoid.nifty.render.batch.BatchRenderConfiguration; -import de.lessvoid.nifty.screen.Screen; -import de.lessvoid.nifty.screen.ScreenController; - -public class TestNiftyBatchMultipleAtlases extends SimpleApplication implements ScreenController { - - private Nifty nifty; - - public static void main(String[] args){ - TestNiftyBatchMultipleAtlases app = new TestNiftyBatchMultipleAtlases(); - app.setPauseOnLostFocus(false); - app.start(); - } - - @Override - public void simpleInitApp() { - - BatchRenderConfiguration batchConfig = new BatchRenderConfiguration(); - batchConfig.atlasWidth = 256; - batchConfig.atlasHeight = 256; - batchConfig.atlasPadding = 2; - batchConfig.atlasTolerance = 0.5f; - batchConfig.fillRemovedImagesInAtlas = false; - batchConfig.disposeImagesBetweenScreens = true; - batchConfig.initialAtlasCount = 3; - - NiftyJmeDisplay niftyDisplay = NiftyJmeDisplay.newNiftyJmeDisplay( - assetManager, - inputManager, - audioRenderer, - guiViewPort, - batchConfig); - nifty = niftyDisplay.getNifty(); - nifty.loadControlFile("nifty-default-controls.xml"); - nifty.loadStyleFile("nifty-default-styles.xml"); - nifty.fromXml("Interface/Nifty/NiftyBatchMultipleAtlases.xml", "screen1", this); - - // attach the nifty display to the gui view port as a processor - guiViewPort.addProcessor(niftyDisplay); - - // disable the fly cam - flyCam.setEnabled(false); - flyCam.setDragToRotate(true); - inputManager.setCursorVisible(true); - } - - @Override - public void bind(Nifty nifty, Screen screen) { - System.out.println("bind(" + screen.getScreenId() + ")"); - } - - @Override - public void onStartScreen() { - System.out.println("onStartScreen"); - } - - @Override - public void onEndScreen() { - System.out.println("onEndScreen"); - } - - public void quit(){ - nifty.gotoScreen("end"); - } - - public void gotoScreen(String screen) { - nifty.gotoScreen(screen); - } - -} diff --git a/jme3-examples/src/main/resources/Interface/Nifty/NiftyBatchMultipleAtlases.xml b/jme3-examples/src/main/resources/Interface/Nifty/NiftyBatchMultipleAtlases.xml deleted file mode 100644 index e32550d8d7..0000000000 --- a/jme3-examples/src/main/resources/Interface/Nifty/NiftyBatchMultipleAtlases.xml +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From d95b31aa6505391b2783aa35c54043edb7fcd90c Mon Sep 17 00:00:00 2001 From: Jesus Oliver Date: Sat, 30 Aug 2025 02:53:10 +0200 Subject: [PATCH 6/8] Updated openalsoft based on NGEngine and set ANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES to all android native libraries --- jme3-android-native/openalsoft.gradle | 102 ++++++++++++- .../src/native/jme_bufferallocator/Android.mk | 1 + .../src/native/jme_decode/Android.mk | 2 +- .../com_jme3_audio_plugins_NativeVorbisFile.c | 1 + .../src/native/jme_openalsoft/Android.mk | 134 ++++++------------ 5 files changed, 139 insertions(+), 101 deletions(-) diff --git a/jme3-android-native/openalsoft.gradle b/jme3-android-native/openalsoft.gradle index 3cff49b073..d2a174f3d7 100644 --- a/jme3-android-native/openalsoft.gradle +++ b/jme3-android-native/openalsoft.gradle @@ -1,12 +1,12 @@ // OpenAL Soft r1.21.1 // TODO: update URL to jMonkeyEngine fork once it's updated with latest kcat's changes -String openALSoftUrl = 'https://github.com/kcat/openal-soft/archive/1.21.1.zip' +String openALSoftUrl = 'https://github.com/kcat/openal-soft/archive/1.24.3.zip' String openALSoftZipFile = 'OpenALSoft.zip' // OpenAL Soft directory the download is extracted into // Typically, the downloaded OpenAL Soft zip file will extract to a directory // called "openal-soft" -String openALSoftFolder = 'openal-soft-1.21.1' +String openALSoftFolder = 'openal-soft-1.24.3' //Working directories for the ndk build. String openalsoftBuildDir = "${buildDir}" + File.separator + 'openalsoft' @@ -81,13 +81,102 @@ task copyJmeOpenALSoft(type: Copy, dependsOn: [copyOpenALSoft, copyJmeHeadersOpe from sourceDir into outputDir } +// rootProject.ndkCommandPath must be set to your ndk-build wrapper or full ndk path +def ndkPath = new File(rootProject.ndkCommandPath).getParent() +def cmakeToolchain = "${ndkPath}/build/cmake/android.toolchain.cmake" + +// 1) list your ABIs here +def openalAbis = [ + "armeabi-v7a", + "arm64-v8a", + "x86", + "x86_64" +] + +// 2) for each ABI, register a configure/build pair +openalAbis.each { abi -> + + // configure task + tasks.register("configureOpenAlSoft_${abi}", Exec) { + group = "external-native" + description = "Generate CMake build files for OpenAL-Soft [$abi]" + + workingDir file("$openalsoftBuildDir/$openALSoftFolder") + commandLine = [ + "cmake", + "-S", ".", + "-B", "cmake-build-${abi}", + "-G", "Unix Makefiles", // or Ninja + "-DCMAKE_TOOLCHAIN_FILE=${cmakeToolchain}", + "-DANDROID_PLATFORM=android-21", + "-DANDROID_ABI=${abi}", + "-DCMAKE_BUILD_TYPE=Release", + "-DALSOFT_UTILS=OFF", + "-DALSOFT_EXAMPLES=OFF", + "-DALSOFT_TESTS=OFF", + "-DALSOFT_BACKEND_OPENSL=ON", + '-DALSOFT_SHARED=OFF', + '-DBUILD_SHARED_LIBS=OFF', + '-DALSOFT_STATIC=ON', + '-DLIBTYPE=STATIC' + ] + + dependsOn copyOpenALSoft + } + + // build task + tasks.register("buildOpenAlSoft_${abi}", Exec) { + group = "external-native" + description = "Compile OpenAL-Soft into libopenalsoft.a for [$abi]" + + dependsOn "configureOpenAlSoft_${abi}" + workingDir file("$openalsoftBuildDir/$openALSoftFolder") + commandLine = [ + "cmake", + "--build", "cmake-build-${abi}", + "--config", "Release" + ] + } +} + +// 3) optional: aggregate tasks +tasks.register("configureOpenAlSoftAll") { + group = "external-native" + description = "Configure OpenAL-Soft for all ABIs" + dependsOn openalAbis.collect { "configureOpenAlSoft_${it}" } +} + +tasks.register("buildOpenAlSoftAll") { + group = "external-native" + description = "Build OpenAL-Soft for all ABIs" + dependsOn openalAbis.collect { "buildOpenAlSoft_${it}" } +} -task buildOpenAlSoftNativeLib(type: Exec, dependsOn: copyJmeOpenALSoft) { -// println "openalsoft build dir: " + openalsoftBuildDir -// println "ndkCommandPath: " + project.ndkCommandPath +task buildOpenAlSoftNativeLib(type: Exec) { + group = "external-native" + description = "Runs ndk-build on your JNI code, linking in the prebuilt OpenAL-Soft .a files" + + dependsOn copyJmeOpenALSoft, buildOpenAlSoftAll + + // where your Android.mk lives workingDir openalsoftBuildDir + + // call the NDK build script executable rootProject.ndkCommandPath - args "-j" + Runtime.runtime.availableProcessors() + + // pass in all ABIs (so ndk-build will rebuild your shared .so for each one), + // and pass in a custom var OPENALSOFT_BUILD_DIR so your Android.mk can find + // the cmake-build- folders. + args( + // let ndk-build know which ABIs to build for + "APP_ABI=armeabi-v7a,arm64-v8a,x86,x86_64", + + // pass in the path to the CMake output root + "OPENALSOFT_BUILD_ROOT=${openalsoftBuildDir}/${openALSoftFolder}", + + // parallel jobs + "-j${Runtime.runtime.availableProcessors()}" + ) } task updatePreCompiledOpenAlSoftLibs(type: Copy, dependsOn: buildOpenAlSoftNativeLib) { @@ -140,3 +229,4 @@ class MyDownload extends DefaultTask { ant.get(src: sourceUrl, dest: target) } } + diff --git a/jme3-android-native/src/native/jme_bufferallocator/Android.mk b/jme3-android-native/src/native/jme_bufferallocator/Android.mk index d735478fb6..e5aaf78864 100644 --- a/jme3-android-native/src/native/jme_bufferallocator/Android.mk +++ b/jme3-android-native/src/native/jme_bufferallocator/Android.mk @@ -39,6 +39,7 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) +LOCAL_CFLAGS := -DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=true LOCAL_LDLIBS := -llog -Wl,-s LOCAL_MODULE := bufferallocatorjme diff --git a/jme3-android-native/src/native/jme_decode/Android.mk b/jme3-android-native/src/native/jme_decode/Android.mk index 1f2a2dca2d..72f8a860eb 100644 --- a/jme3-android-native/src/native/jme_decode/Android.mk +++ b/jme3-android-native/src/native/jme_decode/Android.mk @@ -10,7 +10,7 @@ LOCAL_C_INCLUDES:= \ $(LOCAL_PATH) \ $(LOCAL_PATH)/Tremor -LOCAL_CFLAGS := -std=gnu99 -DLIMIT_TO_64kHz -O0 +LOCAL_CFLAGS := -std=gnu99 -DLIMIT_TO_64kHz -O0 -DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=true LOCAL_LDLIBS := -lz -llog -Wl,-s ifeq ($(TARGET_ARCH),arm) diff --git a/jme3-android-native/src/native/jme_decode/com_jme3_audio_plugins_NativeVorbisFile.c b/jme3-android-native/src/native/jme_decode/com_jme3_audio_plugins_NativeVorbisFile.c index 25a15f5b8a..b00ff9a7cc 100644 --- a/jme3-android-native/src/native/jme_decode/com_jme3_audio_plugins_NativeVorbisFile.c +++ b/jme3-android-native/src/native/jme_decode/com_jme3_audio_plugins_NativeVorbisFile.c @@ -1,6 +1,7 @@ #include #include #include +#include #include "Tremor/ivorbisfile.h" diff --git a/jme3-android-native/src/native/jme_openalsoft/Android.mk b/jme3-android-native/src/native/jme_openalsoft/Android.mk index 13e1547aad..c7df858735 100644 --- a/jme3-android-native/src/native/jme_openalsoft/Android.mk +++ b/jme3-android-native/src/native/jme_openalsoft/Android.mk @@ -1,103 +1,49 @@ -TARGET_PLATFORM := android-19 +# jni/Android.mk LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_MODULE := openalsoftjme - -LOCAL_C_INCLUDES += $(LOCAL_PATH) $(LOCAL_PATH)/include \ - $(LOCAL_PATH)/alc $(LOCAL_PATH)/common +# require the path to cmake-build- +ifndef OPENALSOFT_BUILD_ROOT +$(error OPENALSOFT_BUILD_ROOT not set! pass it via ndk-build OPENALSOFT_BUILD_ROOT=/path/to/cmake-build-root) +endif -LOCAL_CPP_FEATURES += exceptions +# assemble the path to this ABI's .a +OPENAL_PREBUILT_DIR := $(OPENALSOFT_BUILD_ROOT)/cmake-build-$(TARGET_ARCH_ABI) -LOCAL_CFLAGS := -ffast-math -DAL_BUILD_LIBRARY -DAL_ALEXT_PROTOTYPES -fcommon -O0 -DRESTRICT="" -LOCAL_LDLIBS := -lOpenSLES -llog -Wl,-s +# ----------------------------------------------------------------------------- +# 1) prebuilt static library +include $(CLEAR_VARS) +LOCAL_MODULE := openalsoft_prebuilt +LOCAL_SRC_FILES := $(OPENAL_PREBUILT_DIR)/libopenal.a +LOCAL_EXPORT_C_INCLUDES := $(OPENALSOFT_BUILD_ROOT)/include +include $(PREBUILT_STATIC_LIBRARY) -LOCAL_SRC_FILES := al/auxeffectslot.cpp \ - al/buffer.cpp \ - al/effect.cpp \ - al/effects/autowah.cpp \ - al/effects/chorus.cpp \ - al/effects/compressor.cpp \ - al/effects/convolution.cpp \ - al/effects/dedicated.cpp \ - al/effects/distortion.cpp \ - al/effects/echo.cpp \ - al/effects/equalizer.cpp \ - al/effects/fshifter.cpp \ - al/effects/modulator.cpp \ - al/effects/null.cpp \ - al/effects/pshifter.cpp \ - al/effects/reverb.cpp \ - al/effects/vmorpher.cpp \ - al/error.cpp \ - al/event.cpp \ - al/extension.cpp \ - al/filter.cpp \ - al/listener.cpp \ - al/source.cpp \ - al/state.cpp \ - alc/alc.cpp \ - alc/alconfig.cpp \ - alc/alu.cpp \ - alc/backends/base.cpp \ - alc/backends/loopback.cpp \ - alc/backends/null.cpp \ - alc/backends/opensl.cpp \ - alc/backends/wave.cpp \ - alc/bformatdec.cpp \ - alc/buffer_storage.cpp \ - alc/converter.cpp \ - alc/effects/autowah.cpp \ - alc/effects/chorus.cpp \ - alc/effects/compressor.cpp \ - alc/effects/convolution.cpp \ - alc/effects/dedicated.cpp \ - alc/effects/distortion.cpp \ - alc/effects/echo.cpp \ - alc/effects/equalizer.cpp \ - alc/effects/fshifter.cpp \ - alc/effects/modulator.cpp \ - alc/effects/null.cpp \ - alc/effects/pshifter.cpp \ - alc/effects/reverb.cpp \ - alc/effects/vmorpher.cpp \ - alc/effectslot.cpp \ - alc/helpers.cpp \ - alc/hrtf.cpp \ - alc/panning.cpp \ - alc/uiddefs.cpp \ - alc/voice.cpp \ - common/alcomplex.cpp \ - common/alfstream.cpp \ - common/almalloc.cpp \ - common/alstring.cpp \ - common/dynload.cpp \ - common/polyphase_resampler.cpp \ - common/ringbuffer.cpp \ - common/strutils.cpp \ - common/threads.cpp \ - core/ambdec.cpp \ - core/bs2b.cpp \ - core/bsinc_tables.cpp \ - core/cpu_caps.cpp \ - core/devformat.cpp \ - core/except.cpp \ - core/filters/biquad.cpp \ - core/filters/nfc.cpp \ - core/filters/splitter.cpp \ - core/fmt_traits.cpp \ - core/fpu_ctrl.cpp \ - core/logging.cpp \ - core/mastering.cpp \ - core/mixer/mixer_c.cpp \ - core/uhjfilter.cpp \ - com_jme3_audio_android_AndroidAL.c \ - com_jme3_audio_android_AndroidALC.c \ - com_jme3_audio_android_AndroidEFX.c +# ----------------------------------------------------------------------------- +# 2) your JNI wrapper +include $(CLEAR_VARS) +LOCAL_MODULE := openalsoftjme +LOCAL_SRC_FILES := \ + com_jme3_audio_android_AndroidAL.c \ + com_jme3_audio_android_AndroidALC.c \ + com_jme3_audio_android_AndroidEFX.c + +LOCAL_C_INCLUDES += \ + $(LOCAL_PATH) \ + $(LOCAL_PATH)/include \ + $(LOCAL_PATH)/alc \ + $(LOCAL_PATH)/common + +LOCAL_CPP_FEATURES := exceptions rtti +LOCAL_CFLAGS := -ffast-math \ + -DAL_ALEXT_PROTOTYPES \ + -fcommon \ + -O0 \ + -DRESTRICT="" \ + -DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=true + +LOCAL_LDLIBS := -lOpenSLES -llog -Wl,-s -lc++_shared +LOCAL_STATIC_LIBRARIES := openalsoft_prebuilt +# (or LOCAL_WHOLE_STATIC_LIBRARIES if you need every object pulled in) include $(BUILD_SHARED_LIBRARY) -# Alc/mixer/hrtf_inc.c \ - From 605866ab71779ee4e7abcf11855b817b1b415dec Mon Sep 17 00:00:00 2001 From: Jesus Oliver Date: Mon, 8 Sep 2025 01:45:38 +0200 Subject: [PATCH 7/8] Changed docker image to build android natives to ghcr.io/cirruslabs/android-sdk:35-ndk --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 25da3d0f8a..698bf1f837 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -104,7 +104,7 @@ jobs: name: Build natives for android runs-on: ubuntu-latest container: - image: jmonkeyengine/buildenv-jme3:android + image: ghcr.io/cirruslabs/android-sdk:35-ndk steps: - name: Clone the repo From be712c7c706b274f8ab065e07cd393595855004b Mon Sep 17 00:00:00 2001 From: Jesus Oliver Date: Tue, 9 Sep 2025 15:02:48 +0200 Subject: [PATCH 8/8] Changed github actions to install cmake in docker image and properly set NDK path for android natives --- .github/workflows/main.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 698bf1f837..3614e1b7f6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -111,10 +111,28 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 1 + + - name: Setup Java 11 + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: '11' + + - name: Check java version + run: java -version + + - name: Install CMake + run: | + apt-get update + apt-get install -y cmake + cmake --version + - name: Validate the Gradle wrapper uses: gradle/actions/wrapper-validation@v3 + - name: Build run: | + export ANDROID_NDK="$ANDROID_SDK_ROOT/ndk/$ANDROID_NDK_VERSION" ./gradlew -PuseCommitHashAsVersionName=true --no-daemon -PbuildNativeProjects=true \ :jme3-android-native:assemble