Compare commits

...

18 Commits

Author SHA1 Message Date
Toni Helenius
1e7e12ee69 Fix for resizing the window (issue 1191) (#1308)
* Listen for framebuffer size callbacks and set the resolution from that

* Also check the window size on the framebuffer size callback
2020-03-24 04:48:25 -04:00
Stephen Gold
f0e09b2a9e main.yml: add Gradle-wrapper validation to several jobs 2020-03-24 04:47:32 -04:00
Toni Helenius
1198908555 Lwjgl3 restart input handle (#1268)
* Reinit inputs on context restart

* Added test issue from issue #1013

* Verify that the inputs are already initialized
2020-03-24 04:44:01 -04:00
Stephen Gold
fecd018fae BufferUtils: resolve issue #1288 (rewrite isDirect()) (#1299) 2020-03-24 04:42:02 -04:00
Stephen Gold
b102eabb56 Fixes issue #1286 2020-03-24 04:37:53 -04:00
Riccardo Balbo
836455826b Fix openal-soft dead link 2020-03-24 04:36:39 -04:00
Riccardo Balbo
3c93e50d99 Update link for stb_image.h 2020-03-24 04:36:08 -04:00
Ali-RS
78779ffe0a Removed extra PostShadow Technique from PBRLighting.j3md (#1273) 2020-03-24 04:33:19 -04:00
Toni Helenius
9002d088e7 Issue 801 (#1269)
* Test case for issue #801

* Reset the context with the initial values
2020-03-24 04:33:03 -04:00
Ryan McDonough
753c3cc173 PreShadow & PostShadow Support for PBRLighting.j3md (#1265)
* Update PBRLighting.j3md

* Create PreShadowPBR.frag

* Create PostShadowPBR.frag
2020-03-24 04:31:37 -04:00
MeFisto94
55a36abe9d Fixes #1261 - Clone the Terrain Picker, so that loading a terrain from file still works (after cloning, the picker would have the wrong terrain quad instance) 2020-03-24 04:29:34 -04:00
MeFisto94
17fbedd5fe Fixes Bullet-Native Artifacts not containing natives when not building from cpp source and not using the build target. 2020-03-24 04:26:30 -04:00
Riccardo Balbo
2e30b24438 Fix #1236 non-lvalue cannot be out parameter 2020-03-24 04:21:52 -04:00
Stephen Gold
bd1b6d284c com.jme3.scene.shape.Line: protect the no-argument constructor (#1234) 2019-12-21 08:48:51 -05:00
Stephen Gold
8a04afd7a1 AnimControl: correct javadoc for the no-arg constructor (#1233) 2019-12-21 08:48:43 -05:00
Stephen Gold
f9d2e03362 Mesh: avoid NPE in getMorphTargets() when there are no targets (#1231) 2019-12-21 08:48:25 -05:00
Paul Speed
8905b3d8f8 Refactored how versions are auto-built to provide more normal versions
when building locally.
Normal auto-detected versions will be based on the base version parsed
from the most recent tag on the branch with a -SNAPSHOT appended.  If
the current commit is the tagged commit then it is used directly to
preserve backwards compatibility... but really that should be a CI
only option for most use-cases.
A new includeBranchInVersion option was added to allow the old behavior
of including the branch name in a munged version string for those
wanting to keep their experimental branch builds separate from their
normal master/version-branch builds.
2019-12-21 08:43:59 -05:00
Riccardo Balbo
a2169999e5 Remove "v" from version tag to maintain consistency with old releases 2019-12-21 05:02:37 -05:00
22 changed files with 877 additions and 409 deletions

View File

@ -1,5 +1,5 @@
###################################################################################### ######################################################################################
# JME CI/CD # JME CI/CD
###################################################################################### ######################################################################################
# Quick overview of what is going on in this script: # Quick overview of what is going on in this script:
# - Build natives for android # - Build natives for android
@ -10,7 +10,7 @@
# - (only when building a release) Deploy everything else to github releases, github packet registry and bintray # - (only when building a release) Deploy everything else to github releases, github packet registry and bintray
# - (only when building a release) Update javadoc.jmonkeyengine.org # - (only when building a release) Update javadoc.jmonkeyengine.org
# Note: # Note:
# All the actions/upload-artifact and actions/download-artifact steps are used to pass # All the actions/upload-artifact and actions/download-artifact steps are used to pass
# stuff between jobs, github actions has some sort of storage that is local to the # stuff between jobs, github actions has some sort of storage that is local to the
# running workflow, we use it to store the result of each job since the filesystem # running workflow, we use it to store the result of each job since the filesystem
# is not maintained between jobs. # is not maintained between jobs.
@ -23,7 +23,7 @@
# BINTRAY_APIKEY=XXXXXX # BINTRAY_APIKEY=XXXXXX
# BINTRAY_LICENSE="BSD 3-Clause" # BINTRAY_LICENSE="BSD 3-Clause"
# >> Configure PACKAGE REGISTRY RELEASE # >> Configure PACKAGE REGISTRY RELEASE
# Nothing to do here, everything is autoconfigured to work with the account/org that # Nothing to do here, everything is autoconfigured to work with the account/org that
# is running the build. # is running the build.
# >> Configure JAVADOC # >> Configure JAVADOC
# JAVADOC_GHPAGES_REPO="riccardoblsandbox/javadoc.jmonkeyengine.org.git" # JAVADOC_GHPAGES_REPO="riccardoblsandbox/javadoc.jmonkeyengine.org.git"
@ -31,7 +31,7 @@
# ssh-keygen -t rsa -b 4096 -C "actions@users.noreply.github.com" -f javadoc_deploy # ssh-keygen -t rsa -b 4096 -C "actions@users.noreply.github.com" -f javadoc_deploy
# Set # Set
# JAVADOC_GHPAGES_DEPLOY_PRIVKEY="......." # JAVADOC_GHPAGES_DEPLOY_PRIVKEY="......."
# In github repo -> Settings, use javadoc_deploy.pub as Deploy key with write access # In github repo -> Settings, use javadoc_deploy.pub as Deploy key with write access
###################################################################################### ######################################################################################
# Resources: # Resources:
# - Github actions docs: https://help.github.com/en/articles/about-github-actions # - Github actions docs: https://help.github.com/en/articles/about-github-actions
@ -54,35 +54,36 @@ on:
pull_request: pull_request:
release: release:
types: [published] types: [published]
jobs: jobs:
# Builds the natives on linux arm # Builds the natives on linux arm
BuildLinuxArmNatives: BuildLinuxArmNatives:
name: Build natives for linux (arm) name: Build natives for linux (arm)
runs-on: ubuntu-18.04 runs-on: ubuntu-18.04
container: container:
image: riccardoblb/buildenv-jme3:linuxArm image: riccardoblb/buildenv-jme3:linuxArm
steps: steps:
- name: Clone the repo - name: Clone the repo
uses: actions/checkout@v1 uses: actions/checkout@v1
with: with:
fetch-depth: 1 fetch-depth: 1
- name: Validate the Gradle wrapper
- name: Build uses: gradle/wrapper-validation-action@v1
- name: Build
run: | run: |
# Build # Build
# Note: since this is crossbuild we use the buildForPlatforms filter to tell # Note: since this is crossbuild we use the buildForPlatforms filter to tell
# the buildscript wich platforms it should build for. # the buildscript wich platforms it should build for.
gradle -PuseCommitHashAsVersionName=true --no-daemon -PbuildForPlatforms=LinuxArm,LinuxArmHF,LinuxArm64 -PbuildNativeProjects=true \ gradle -PuseCommitHashAsVersionName=true --no-daemon -PbuildForPlatforms=LinuxArm,LinuxArmHF,LinuxArm64 -PbuildNativeProjects=true \
:jme3-bullet-native:assemble :jme3-bullet-native:assemble
- name: Upload natives - name: Upload natives
uses: actions/upload-artifact@master uses: actions/upload-artifact@master
with: with:
name: linuxarm-natives name: linuxarm-natives
path: build/native path: build/native
# Build the natives on android # Build the natives on android
BuildAndroidNatives: BuildAndroidNatives:
@ -90,19 +91,20 @@ jobs:
runs-on: ubuntu-18.04 runs-on: ubuntu-18.04
container: container:
image: riccardoblb/buildenv-jme3:android image: riccardoblb/buildenv-jme3:android
steps: steps:
- name: Clone the repo - name: Clone the repo
uses: actions/checkout@v1 uses: actions/checkout@v1
with: with:
fetch-depth: 1 fetch-depth: 1
- name: Validate the Gradle wrapper
- name: Build uses: gradle/wrapper-validation-action@v1
run: | - name: Build
gradle -PuseCommitHashAsVersionName=true --no-daemon -PbuildNativeProjects=true \ run: |
./gradlew -PuseCommitHashAsVersionName=true --no-daemon -PbuildNativeProjects=true \
:jme3-android-native:assemble \ :jme3-android-native:assemble \
:jme3-bullet-native-android:assemble :jme3-bullet-native-android:assemble
- name: Upload natives - name: Upload natives
uses: actions/upload-artifact@master uses: actions/upload-artifact@master
with: with:
@ -114,7 +116,7 @@ jobs:
strategy: strategy:
fail-fast: true fail-fast: true
matrix: matrix:
os: [ubuntu-18.04,windows-2019,macOS-latest] os: [ubuntu-18.04,windows-2019,macOS-latest]
jdk: [8.x.x] jdk: [8.x.x]
include: include:
- os: ubuntu-18.04 - os: ubuntu-18.04
@ -123,22 +125,23 @@ jobs:
osName: windows osName: windows
- os: macOS-latest - os: macOS-latest
osName: mac osName: mac
name: Build natives for ${{ matrix.osName }} name: Build natives for ${{ matrix.osName }}
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- name: Clone the repo - name: Clone the repo
uses: actions/checkout@v1 uses: actions/checkout@v1
with: with:
fetch-depth: 1 fetch-depth: 1
- name: Prepare java environment - name: Prepare java environment
uses: actions/setup-java@v1 uses: actions/setup-java@v1
with: with:
java-version: ${{ matrix.jdk }} java-version: ${{ matrix.jdk }}
architecture: x64 architecture: x64
- name: Validate the Gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: Build Natives - name: Build Natives
shell: bash shell: bash
env: env:
@ -147,8 +150,8 @@ jobs:
# Install dependencies # Install dependencies
if [ "$OS_NAME" = "mac" ]; if [ "$OS_NAME" = "mac" ];
then then
echo "Prepare mac" echo "Prepare mac"
elif [ "$OS_NAME" = "linux" ]; elif [ "$OS_NAME" = "linux" ];
then then
echo "Prepare linux" echo "Prepare linux"
@ -157,25 +160,25 @@ jobs:
else else
echo "Prepare windows" echo "Prepare windows"
fi fi
# Build # Build
gradle -PuseCommitHashAsVersionName=true --no-daemon -PbuildNativeProjects=true -Dmaven.repo.local="$PWD/dist/maven" \ gradle -PuseCommitHashAsVersionName=true --no-daemon -PbuildNativeProjects=true -Dmaven.repo.local="$PWD/dist/maven" \
build \ build \
:jme3-bullet-native:build :jme3-bullet-native:build
# Upload natives to be used later by the BuildJMonkey job # Upload natives to be used later by the BuildJMonkey job
- name: Upload natives - name: Upload natives
uses: actions/upload-artifact@master uses: actions/upload-artifact@master
with: with:
name: ${{ matrix.osName }}-natives name: ${{ matrix.osName }}-natives
path: build/native path: build/native
# Build the engine, we only deploy from ubuntu-18.04 jdk8 # Build the engine, we only deploy from ubuntu-18.04 jdk8
BuildJMonkey: BuildJMonkey:
needs: [BuildNatives,BuildAndroidNatives] needs: [BuildNatives,BuildAndroidNatives]
name: Build on ${{ matrix.osName }} jdk${{ matrix.jdk }} name: Build on ${{ matrix.osName }} jdk${{ matrix.jdk }}
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
strategy: strategy:
fail-fast: true fail-fast: true
matrix: matrix:
@ -188,21 +191,21 @@ jobs:
- os: windows-2019 - os: windows-2019
osName: windows osName: windows
- os: macOS-latest - os: macOS-latest
osName: mac osName: mac
- jdk: 11.x.x - jdk: 11.x.x
deploy: false deploy: false
steps: steps:
- name: Clone the repo - name: Clone the repo
uses: actions/checkout@v1 uses: actions/checkout@v1
with: with:
fetch-depth: 1 fetch-depth: 1
- name: Setup the java environment - name: Setup the java environment
uses: actions/setup-java@v1 uses: actions/setup-java@v1
with: with:
java-version: ${{ matrix.jdk }} java-version: ${{ matrix.jdk }}
architecture: x64 architecture: x64
- name: Download natives for linux - name: Download natives for linux
uses: actions/download-artifact@master uses: actions/download-artifact@master
@ -215,7 +218,7 @@ jobs:
with: with:
name: windows-natives name: windows-natives
path: build/native path: build/native
- name: Download natives for mac - name: Download natives for mac
uses: actions/download-artifact@master uses: actions/download-artifact@master
with: with:
@ -233,26 +236,27 @@ jobs:
with: with:
name: linuxarm-natives name: linuxarm-natives
path: build/native path: build/native
- name: Validate the Gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: Build Engine - name: Build Engine
shell: bash shell: bash
run: | run: |
# Build # Build
gradle -PuseCommitHashAsVersionName=true -PskipPrebuildLibraries=true build gradle -PuseCommitHashAsVersionName=true -PskipPrebuildLibraries=true build
if [ "${{ matrix.deploy }}" = "true" ]; if [ "${{ matrix.deploy }}" = "true" ];
then then
# We are going to need "zip" # We are going to need "zip"
sudo apt-get update sudo apt-get update
sudo apt-get install -y zip sudo apt-get install -y zip
# Create the zip release and the javadoc # Create the zip release and the javadoc
gradle -PuseCommitHashAsVersionName=true -PskipPrebuildLibraries=true mergedJavadoc createZipDistribution gradle -PuseCommitHashAsVersionName=true -PskipPrebuildLibraries=true mergedJavadoc createZipDistribution
# We prepare the release for deploy # We prepare the release for deploy
mkdir -p ./dist/release/ mkdir -p ./dist/release/
mv build/distributions/*.zip dist/release/ mv build/distributions/*.zip dist/release/
# Create the maven artifacts # Create the maven artifacts
mkdir -p ./dist/maven/ mkdir -p ./dist/maven/
gradle -PuseCommitHashAsVersionName=true -PskipPrebuildLibraries=true install -Dmaven.repo.local="$PWD/dist/maven" gradle -PuseCommitHashAsVersionName=true -PskipPrebuildLibraries=true install -Dmaven.repo.local="$PWD/dist/maven"
@ -261,10 +265,10 @@ jobs:
echo "Create native zip" echo "Create native zip"
cdir="$PWD" cdir="$PWD"
cd "build/native" cd "build/native"
zip -r "$cdir/dist/jme3-natives.zip" * zip -r "$cdir/dist/jme3-natives.zip" *
cd "$cdir" cd "$cdir"
echo "Done" echo "Done"
fi fi
# Used later by DeploySnapshot # Used later by DeploySnapshot
- name: Upload merged natives - name: Upload merged natives
@ -273,29 +277,29 @@ jobs:
with: with:
name: natives name: natives
path: dist/jme3-natives.zip path: dist/jme3-natives.zip
# Upload maven artifacts to be used later by the deploy job # Upload maven artifacts to be used later by the deploy job
- name: Upload maven artifacts - name: Upload maven artifacts
if: matrix.deploy==true if: matrix.deploy==true
uses: actions/upload-artifact@master uses: actions/upload-artifact@master
with: with:
name: maven name: maven
path: dist/maven path: dist/maven
- name: Upload javadoc - name: Upload javadoc
if: matrix.deploy==true if: matrix.deploy==true
uses: actions/upload-artifact@master uses: actions/upload-artifact@master
with: with:
name: javadoc name: javadoc
path: dist/javadoc path: dist/javadoc
# Upload release archive to be used later by the deploy job # Upload release archive to be used later by the deploy job
- name: Upload release - name: Upload release
if: github.event_name == 'release' && matrix.deploy==true if: github.event_name == 'release' && matrix.deploy==true
uses: actions/upload-artifact@master uses: actions/upload-artifact@master
with: with:
name: release name: release
path: dist/release path: dist/release
# This job deploys the native snapshot. # This job deploys the native snapshot.
# The snapshot is downloaded when people build the engine without setting buildNativeProject # The snapshot is downloaded when people build the engine without setting buildNativeProject
@ -316,7 +320,7 @@ jobs:
then then
git clone --single-branch --branch "$branch" https://github.com/${GITHUB_REPOSITORY}.git . git clone --single-branch --branch "$branch" https://github.com/${GITHUB_REPOSITORY}.git .
fi fi
- name: Download merged natives - name: Download merged natives
uses: actions/download-artifact@master uses: actions/download-artifact@master
with: with:
@ -334,7 +338,7 @@ jobs:
then then
nativeSnapshot=`cat "natives-snapshot.properties"` nativeSnapshot=`cat "natives-snapshot.properties"`
nativeSnapshot="${nativeSnapshot#*=}" nativeSnapshot="${nativeSnapshot#*=}"
# We deploy ONLY if GITHUB_SHA (the current commit hash) is newer than $nativeSnapshot # We deploy ONLY if GITHUB_SHA (the current commit hash) is newer than $nativeSnapshot
if [ "`git rev-list --count $nativeSnapshot..$GITHUB_SHA`" = "0" ]; if [ "`git rev-list --count $nativeSnapshot..$GITHUB_SHA`" = "0" ];
then then
@ -355,9 +359,9 @@ jobs:
echo "No changes, skip." echo "No changes, skip."
else else
if [ "${{ secrets.BINTRAY_GENERIC_REPO }}" = "" ]; if [ "${{ secrets.BINTRAY_GENERIC_REPO }}" = "" ];
then then
echo "Configure the following secrets to enable native snapshot deployment" echo "Configure the following secrets to enable native snapshot deployment"
echo "BINTRAY_GENERIC_REPO, BINTRAY_USER, BINTRAY_APIKEY" echo "BINTRAY_GENERIC_REPO, BINTRAY_USER, BINTRAY_APIKEY"
else else
# Deploy snapshot # Deploy snapshot
bintray_uploadFile dist/jme3-natives.zip \ bintray_uploadFile dist/jme3-natives.zip \
@ -368,17 +372,17 @@ jobs:
"https://github.com/${GITHUB_REPOSITORY}" \ "https://github.com/${GITHUB_REPOSITORY}" \
"${{ secrets.BINTRAY_LICENSE }}" "true" "${{ secrets.BINTRAY_LICENSE }}" "true"
# We reference the snapshot by writing its commit hash in natives-snapshot.properties # We reference the snapshot by writing its commit hash in natives-snapshot.properties
echo "natives.snapshot=$GITHUB_SHA" > natives-snapshot.properties echo "natives.snapshot=$GITHUB_SHA" > natives-snapshot.properties
# We commit the updated natives-snapshot.properties # We commit the updated natives-snapshot.properties
git config --global user.name "Github Actions" git config --global user.name "Github Actions"
git config --global user.email "actions@users.noreply.github.com" git config --global user.email "actions@users.noreply.github.com"
git add natives-snapshot.properties git add natives-snapshot.properties
git commit -m "[skip ci] update natives snapshot" git commit -m "[skip ci] update natives snapshot"
# Pull rebase from the remote repo, just in case there was a push in the meantime # Pull rebase from the remote repo, just in case there was a push in the meantime
git pull -q --rebase git pull -q --rebase
@ -387,39 +391,39 @@ jobs:
# Push # Push
(git -c http.extraheader="AUTHORIZATION: basic $header" push origin "$branch" || true) (git -c http.extraheader="AUTHORIZATION: basic $header" push origin "$branch" || true)
fi fi
fi fi
fi fi
# This job deploys the release # This job deploys the release
DeployRelease: DeployRelease:
needs: [BuildJMonkey] needs: [BuildJMonkey]
name: Deploy Release name: Deploy Release
runs-on: ubuntu-18.04 runs-on: ubuntu-18.04
if: github.event_name == 'release' if: github.event_name == 'release'
steps: steps:
# We need to clone everything again for uploadToMaven.sh ... # We need to clone everything again for uploadToMaven.sh ...
- name: Clone the repo - name: Clone the repo
uses: actions/checkout@v1 uses: actions/checkout@v1
with: with:
fetch-depth: 1 fetch-depth: 1
# Download all the stuff... # Download all the stuff...
- name: Download maven artifacts - name: Download maven artifacts
uses: actions/download-artifact@master uses: actions/download-artifact@master
with: with:
name: maven name: maven
path: dist/maven path: dist/maven
- name: Download release - name: Download release
uses: actions/download-artifact@master uses: actions/download-artifact@master
with: with:
name: release name: release
path: dist/release path: dist/release
- name: Deploy to github releases - name: Deploy to github releases
run: | run: |
# We need to get the release id (yeah, it's not the same as the tag) # We need to get the release id (yeah, it's not the same as the tag)
echo "${GITHUB_EVENT_PATH}" echo "${GITHUB_EVENT_PATH}"
@ -436,7 +440,7 @@ jobs:
-H "Content-Type: application/zip" \ -H "Content-Type: application/zip" \
--data-binary @"$filename" \ --data-binary @"$filename" \
"$url" "$url"
- name: Deploy to bintray - name: Deploy to bintray
run: | run: |
source .github/actions/tools/uploadToMaven.sh source .github/actions/tools/uploadToMaven.sh
@ -447,22 +451,22 @@ jobs:
else else
uploadAllToMaven dist/maven/ https://api.bintray.com/maven/${{ secrets.BINTRAY_MAVEN_REPO }} ${{ secrets.BINTRAY_USER }} ${{ secrets.BINTRAY_APIKEY }} "https://github.com/${GITHUB_REPOSITORY}" "${{ secrets.BINTRAY_LICENSE }}" uploadAllToMaven dist/maven/ https://api.bintray.com/maven/${{ secrets.BINTRAY_MAVEN_REPO }} ${{ secrets.BINTRAY_USER }} ${{ secrets.BINTRAY_APIKEY }} "https://github.com/${GITHUB_REPOSITORY}" "${{ secrets.BINTRAY_LICENSE }}"
fi fi
# - name: Deploy to github package registry # - name: Deploy to github package registry
# run: | # run: |
# source .github/actions/tools/uploadToMaven.sh # source .github/actions/tools/uploadToMaven.sh
# registry="https://maven.pkg.github.com/$GITHUB_REPOSITORY" # registry="https://maven.pkg.github.com/$GITHUB_REPOSITORY"
# echo "Deploy to github package registry $registry" # echo "Deploy to github package registry $registry"
# uploadAllToMaven dist/maven/ $registry "token" ${{ secrets.GITHUB_TOKEN }} # uploadAllToMaven dist/maven/ $registry "token" ${{ secrets.GITHUB_TOKEN }}
# Deploy the javadoc # Deploy the javadoc
DeployJavaDoc: DeployJavaDoc:
needs: [BuildJMonkey] needs: [BuildJMonkey]
name: Deploy Javadoc name: Deploy Javadoc
runs-on: ubuntu-18.04 runs-on: ubuntu-18.04
if: github.event_name == 'release' if: github.event_name == 'release'
steps: steps:
# We are going to need a deploy key for this, since we need # We are going to need a deploy key for this, since we need
# to push to a different repo # to push to a different repo
- name: Set ssh key - name: Set ssh key
@ -477,16 +481,16 @@ jobs:
branch="gh-pages" branch="gh-pages"
export GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i $HOME/.ssh/deploy.key" export GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i $HOME/.ssh/deploy.key"
git clone --single-branch --branch "$branch" git@github.com:${{ secrets.JAVADOC_GHPAGES_REPO }} . git clone --single-branch --branch "$branch" git@github.com:${{ secrets.JAVADOC_GHPAGES_REPO }} .
# Download the javadoc in the new directory "newdoc" # Download the javadoc in the new directory "newdoc"
- name: Download javadoc - name: Download javadoc
uses: actions/download-artifact@master uses: actions/download-artifact@master
with: with:
name: javadoc name: javadoc
path: newdoc path: newdoc
# The actual deploy # The actual deploy
- name: Deploy to github pages - name: Deploy to github pages
run: | run: |
set -f set -f
IFS=$'\n' IFS=$'\n'
@ -508,10 +512,10 @@ jobs:
# if there isn't an index.txt we create one (we need this to list the versions) # if there isn't an index.txt we create one (we need this to list the versions)
if [ ! -f "index.txt" ]; then echo "" > index.txt ; fi if [ ! -f "index.txt" ]; then echo "" > index.txt ; fi
index="`cat index.txt`" index="`cat index.txt`"
# Check if this version is already in index.txt # Check if this version is already in index.txt
addNew=true addNew=true
for v in $index; for v in $index;
do do
if [ "$v" = "$version" ]; if [ "$v" = "$version" ];
then then
@ -538,11 +542,11 @@ jobs:
# Commit the changes # Commit the changes
git config --global user.name "Github Actions" git config --global user.name "Github Actions"
git config --global user.email "actions@users.noreply.github.com" git config --global user.email "actions@users.noreply.github.com"
git add . git add .
git commit -m "$version" git commit -m "$version"
branch="gh-pages" branch="gh-pages"
git push origin "$branch" --force git push origin "$branch" --force
fi fi

View File

@ -158,29 +158,29 @@ task configureAndroidNDK {
gradle.rootProject.ext.set("usePrebuildNatives", buildNativeProjects!="true"); gradle.rootProject.ext.set("usePrebuildNatives", buildNativeProjects!="true");
if(skipPrebuildLibraries!="true"&&buildNativeProjects!="true"){ if (skipPrebuildLibraries != "true" && buildNativeProjects != "true") {
String rootPath = rootProject.projectDir.absolutePath String rootPath = rootProject.projectDir.absolutePath
Properties nativesSnasphotProp = new Properties() Properties nativesSnasphotProp = new Properties()
File nativesSnasphotPropF=new File("${rootPath}/natives-snapshot.properties"); File nativesSnasphotPropF = new File("${rootPath}/natives-snapshot.properties");
if(nativesSnasphotPropF.exists()){ if (nativesSnasphotPropF.exists()) {
nativesSnasphotPropF.withInputStream { nativesSnasphotProp.load(it) } nativesSnasphotPropF.withInputStream { nativesSnasphotProp.load(it) }
String nativesSnasphot=nativesSnasphotProp.getProperty("natives.snapshot"); String nativesSnasphot = nativesSnasphotProp.getProperty("natives.snapshot");
String nativesUrl=PREBUILD_NATIVES_URL.replace('${natives.snapshot}',nativesSnasphot) String nativesUrl = PREBUILD_NATIVES_URL.replace('${natives.snapshot}', nativesSnasphot)
println "Use natives snapshot: "+nativesUrl println "Use natives snapshot: " + nativesUrl
String nativesZipFile="${rootPath}" + File.separator + "build"+ File.separator +nativesSnasphot+"-natives.zip" String nativesZipFile = "${rootPath}" + File.separator + "build" + File.separator + nativesSnasphot + "-natives.zip"
String nativesPath="${rootPath}" + File.separator + "build"+ File.separator +"native" String nativesPath = "${rootPath}" + File.separator + "build" + File.separator + "native"
task getNativesZipFile { task getNativesZipFile {
outputs.file nativesZipFile outputs.file nativesZipFile
doFirst { doFirst {
File target = file(nativesZipFile); File target = file(nativesZipFile);
println("Download natives from "+nativesUrl+" to "+nativesZipFile); println("Download natives from " + nativesUrl + " to " + nativesZipFile);
target.getParentFile().mkdirs(); target.getParentFile().mkdirs();
ant.get(src: nativesUrl, dest: target); ant.get(src: nativesUrl, dest: target);
} }
@ -192,28 +192,26 @@ if(skipPrebuildLibraries!="true"&&buildNativeProjects!="true"){
dependsOn getNativesZipFile dependsOn getNativesZipFile
doFirst { doFirst {
for(File src : zipTree(nativesZipFile)){ for (File src : zipTree(nativesZipFile)) {
String srcRel=src.getAbsolutePath().substring((int)(nativesZipFile.length()+1)); String srcRel = src.getAbsolutePath().substring((int) (nativesZipFile.length() + 1));
srcRel=srcRel.substring(srcRel.indexOf( File.separator)+1); srcRel = srcRel.substring(srcRel.indexOf(File.separator) + 1);
File dest=new File(nativesPath+File.separator+srcRel); File dest = new File(nativesPath + File.separator + srcRel);
boolean doCopy = !(dest.exists() && dest.lastModified() > src.lastModified()) boolean doCopy = !(dest.exists() && dest.lastModified() > src.lastModified())
if (doCopy) { if (doCopy) {
println("Copy "+src+" "+dest); println("Copy " + src + " " + dest);
dest.getParentFile().mkdirs(); dest.getParentFile().mkdirs();
Files.copy(src.toPath(), dest.toPath(), StandardCopyOption.REPLACE_EXISTING); Files.copy(src.toPath(), dest.toPath(), StandardCopyOption.REPLACE_EXISTING);
} }
} }
} }
} }
build.dependsOn extractPrebuiltNatives
assemble.dependsOn extractPrebuiltNatives
} }
} }
//class IncrementalReverseTask extends DefaultTask { //class IncrementalReverseTask extends DefaultTask {
// @InputDirectory // @InputDirectory
// def File inputDir // def File inputDir

View File

@ -8,6 +8,10 @@ jmeVersionName =
# If true, the version name will contain the commit hash # If true, the version name will contain the commit hash
useCommitHashAsVersionName = false useCommitHashAsVersionName = false
# Set to true if a non-master branch name should be included in the automatically
# generated version.
includeBranchInVersion = false
# specify if JavaDoc should be built # specify if JavaDoc should be built
buildJavaDoc = true buildJavaDoc = true

View File

@ -1,5 +1,5 @@
String tremorZipFile = "TremorAndroid.zip" String tremorZipFile = "TremorAndroid.zip"
String stbiUrl = 'https://raw.githubusercontent.com/nothings/stb/master/stb_image.h' String stbiUrl = 'https://raw.githubusercontent.com/jMonkeyEngine/stb/0224a44a10564a214595797b4c88323f79a5f934/stb_image.h'
// Working directories for the ndk build. // Working directories for the ndk build.
String decodeBuildDir = "${buildDir}" + File.separator + 'decode' String decodeBuildDir = "${buildDir}" + File.separator + 'decode'

View File

@ -1,11 +1,11 @@
// OpenAL Soft r1.16 // OpenAL Soft r1.16
String openALSoftUrl = 'http://repo.or.cz/w/openal-soft.git/snapshot/e5016f814a265ed592a88acea95cf912c4bfdf12.zip' String openALSoftUrl = 'https://github.com/jMonkeyEngine/openal-soft/archive/e5016f814a265ed592a88acea95cf912c4bfdf12.zip'
String openALSoftZipFile = 'OpenALSoft.zip' String openALSoftZipFile = 'OpenALSoft.zip'
// OpenAL Soft directory the download is extracted into // OpenAL Soft directory the download is extracted into
// Typically, the downloaded OpenAL Soft zip file will extract to a directory // Typically, the downloaded OpenAL Soft zip file will extract to a directory
// called "openal-soft" // called "openal-soft"
String openALSoftFolder = 'openal-soft-e5016f8' String openALSoftFolder = 'openal-soft-e5016f814a265ed592a88acea95cf912c4bfdf12'
//Working directories for the ndk build. //Working directories for the ndk build.
String openalsoftBuildDir = "${buildDir}" + File.separator + 'openalsoft' String openalsoftBuildDir = "${buildDir}" + File.separator + 'openalsoft'

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2009-2018 jMonkeyEngine * Copyright (c) 2009-2019 jMonkeyEngine
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -102,7 +102,9 @@ public final class AnimControl extends AbstractControl implements Cloneable, Jme
} }
/** /**
* Serialization only. Do not use. * Instantiate an animation control with no skeleton, suitable only for
* animations that don't contain any bone tracks. Also used for
* serialization.
*/ */
public AnimControl() { public AnimControl() {
} }
@ -144,6 +146,7 @@ public final class AnimControl extends AbstractControl implements Cloneable, Jme
/** /**
* Retrieve an animation from the list of animations. * Retrieve an animation from the list of animations.
*
* @param name The name of the animation to retrieve. * @param name The name of the animation to retrieve.
* @return The animation corresponding to the given name, or null, if no * @return The animation corresponding to the given name, or null, if no
* such named animation exists. * such named animation exists.
@ -155,6 +158,7 @@ public final class AnimControl extends AbstractControl implements Cloneable, Jme
/** /**
* Adds an animation to be available for playing to this * Adds an animation to be available for playing to this
* <code>AnimControl</code>. * <code>AnimControl</code>.
*
* @param anim The animation to add. * @param anim The animation to add.
*/ */
public void addAnim(Animation anim) { public void addAnim(Animation anim) {
@ -163,6 +167,7 @@ public final class AnimControl extends AbstractControl implements Cloneable, Jme
/** /**
* Remove an animation so that it is no longer available for playing. * Remove an animation so that it is no longer available for playing.
*
* @param anim The animation to remove. * @param anim The animation to remove.
*/ */
public void removeAnim(Animation anim) { public void removeAnim(Animation anim) {
@ -231,6 +236,7 @@ public final class AnimControl extends AbstractControl implements Cloneable, Jme
/** /**
* Adds a new listener to receive animation related events. * Adds a new listener to receive animation related events.
*
* @param listener The listener to add. * @param listener The listener to add.
*/ */
public void addListener(AnimEventListener listener) { public void addListener(AnimEventListener listener) {
@ -244,6 +250,7 @@ public final class AnimControl extends AbstractControl implements Cloneable, Jme
/** /**
* Removes the given listener from listening to events. * Removes the given listener from listening to events.
*
* @param listener * @param listener
* @see AnimControl#addListener(com.jme3.animation.AnimEventListener) * @see AnimControl#addListener(com.jme3.animation.AnimEventListener)
*/ */
@ -308,6 +315,7 @@ public final class AnimControl extends AbstractControl implements Cloneable, Jme
/** /**
* Returns the length of the given named animation. * Returns the length of the given named animation.
*
* @param name The name of the animation * @param name The name of the animation
* @return The length of time, in seconds, of the named animation. * @return The length of time, in seconds, of the named animation.
*/ */

View File

@ -32,7 +32,6 @@
package com.jme3.renderer; package com.jme3.renderer;
import com.jme3.material.RenderState; import com.jme3.material.RenderState;
import com.jme3.material.RenderState.BlendFunc;
import com.jme3.math.ColorRGBA; import com.jme3.math.ColorRGBA;
import com.jme3.scene.Mesh; import com.jme3.scene.Mesh;
import com.jme3.scene.VertexBuffer; import com.jme3.scene.VertexBuffer;
@ -49,123 +48,123 @@ public class RenderContext {
/** /**
* @see RenderState#setFaceCullMode(com.jme3.material.RenderState.FaceCullMode) * @see RenderState#setFaceCullMode(com.jme3.material.RenderState.FaceCullMode)
*/ */
public RenderState.FaceCullMode cullMode = RenderState.FaceCullMode.Off; public RenderState.FaceCullMode cullMode;
/** /**
* @see RenderState#setDepthTest(boolean) * @see RenderState#setDepthTest(boolean)
*/ */
public boolean depthTestEnabled = false; public boolean depthTestEnabled;
/** /**
* @see RenderState#setDepthWrite(boolean) * @see RenderState#setDepthWrite(boolean)
*/ */
public boolean depthWriteEnabled = true; public boolean depthWriteEnabled;
/** /**
* @see RenderState#setColorWrite(boolean) * @see RenderState#setColorWrite(boolean)
*/ */
public boolean colorWriteEnabled = true; public boolean colorWriteEnabled;
/** /**
* @see Renderer#setClipRect(int, int, int, int) * @see Renderer#setClipRect(int, int, int, int)
*/ */
public boolean clipRectEnabled = false; public boolean clipRectEnabled;
/** /**
* @see RenderState#setPolyOffset(float, float) * @see RenderState#setPolyOffset(float, float)
*/ */
public boolean polyOffsetEnabled = false; public boolean polyOffsetEnabled;
/**
* @see RenderState#setPolyOffset(float, float)
*/
public float polyOffsetFactor = 0;
/**
* @see RenderState#setPolyOffset(float, float)
*/
public float polyOffsetUnits = 0;
/** /**
* @see Mesh#setPointSize(float) * @see RenderState#setPolyOffset(float, float)
*/ */
public float pointSize = 1; public float polyOffsetFactor;
/**
* @see RenderState#setPolyOffset(float, float)
*/
public float polyOffsetUnits;
/**
* @see Mesh#setPointSize(float)
*/
public float pointSize;
/** /**
* @see RenderState#setLineWidth(float) * @see RenderState#setLineWidth(float)
*/ */
public float lineWidth = 1; public float lineWidth;
/** /**
* @see RenderState#setBlendMode(com.jme3.material.RenderState.BlendMode) * @see RenderState#setBlendMode(com.jme3.material.RenderState.BlendMode)
*/ */
public RenderState.BlendMode blendMode = RenderState.BlendMode.Off; public RenderState.BlendMode blendMode;
/** /**
* @see RenderState#setBlendEquation(com.jme3.material.RenderState.BlendEquation) * @see RenderState#setBlendEquation(com.jme3.material.RenderState.BlendEquation)
*/ */
public RenderState.BlendEquation blendEquation = RenderState.BlendEquation.Add; public RenderState.BlendEquation blendEquation;
/** /**
* @see RenderState#setBlendEquationAlpha(com.jme3.material.RenderState.BlendEquationAlpha) * @see RenderState#setBlendEquationAlpha(com.jme3.material.RenderState.BlendEquationAlpha)
*/ */
public RenderState.BlendEquationAlpha blendEquationAlpha = RenderState.BlendEquationAlpha.InheritColor; public RenderState.BlendEquationAlpha blendEquationAlpha;
/** /**
* @see RenderState#setCustomBlendFactors(com.jme3.material.RenderState.BlendFunc, com.jme3.material.RenderState.BlendFunc, * @see RenderState#setCustomBlendFactors(com.jme3.material.RenderState.BlendFunc, com.jme3.material.RenderState.BlendFunc,
* com.jme3.material.RenderState.BlendFunc, com.jme3.material.RenderState.BlendFunc) * com.jme3.material.RenderState.BlendFunc, com.jme3.material.RenderState.BlendFunc)
*/ */
public RenderState.BlendFunc sfactorRGB = RenderState.BlendFunc.One; public RenderState.BlendFunc sfactorRGB;
/** /**
* @see RenderState#setCustomBlendFactors(com.jme3.material.RenderState.BlendFunc, com.jme3.material.RenderState.BlendFunc, * @see RenderState#setCustomBlendFactors(com.jme3.material.RenderState.BlendFunc, com.jme3.material.RenderState.BlendFunc,
* com.jme3.material.RenderState.BlendFunc, com.jme3.material.RenderState.BlendFunc) * com.jme3.material.RenderState.BlendFunc, com.jme3.material.RenderState.BlendFunc)
*/ */
public RenderState.BlendFunc dfactorRGB = RenderState.BlendFunc.One; public RenderState.BlendFunc dfactorRGB;
/** /**
* @see RenderState#setCustomBlendFactors(com.jme3.material.RenderState.BlendFunc, com.jme3.material.RenderState.BlendFunc, * @see RenderState#setCustomBlendFactors(com.jme3.material.RenderState.BlendFunc, com.jme3.material.RenderState.BlendFunc,
* com.jme3.material.RenderState.BlendFunc, com.jme3.material.RenderState.BlendFunc) * com.jme3.material.RenderState.BlendFunc, com.jme3.material.RenderState.BlendFunc)
*/ */
public RenderState.BlendFunc sfactorAlpha = RenderState.BlendFunc.One; public RenderState.BlendFunc sfactorAlpha;
/** /**
* @see RenderState#setCustomBlendFactors(com.jme3.material.RenderState.BlendFunc, com.jme3.material.RenderState.BlendFunc, * @see RenderState#setCustomBlendFactors(com.jme3.material.RenderState.BlendFunc, com.jme3.material.RenderState.BlendFunc,
* com.jme3.material.RenderState.BlendFunc, com.jme3.material.RenderState.BlendFunc) * com.jme3.material.RenderState.BlendFunc, com.jme3.material.RenderState.BlendFunc)
*/ */
public RenderState.BlendFunc dfactorAlpha = RenderState.BlendFunc.One; public RenderState.BlendFunc dfactorAlpha;
/** /**
* @see RenderState#setWireframe(boolean) * @see RenderState#setWireframe(boolean)
*/ */
public boolean wireframe = false; public boolean wireframe;
/** /**
* @see Renderer#setShader(com.jme3.shader.Shader) * @see Renderer#setShader(com.jme3.shader.Shader)
*/ */
public int boundShaderProgram; public int boundShaderProgram;
/** /**
* @see Renderer#setShader(com.jme3.shader.Shader) * @see Renderer#setShader(com.jme3.shader.Shader)
*/ */
public Shader boundShader; public Shader boundShader;
/** /**
* @see Renderer#setFrameBuffer(com.jme3.texture.FrameBuffer) * @see Renderer#setFrameBuffer(com.jme3.texture.FrameBuffer)
*/ */
public int boundFBO = 0; public int boundFBO;
/** /**
* @see Renderer#setFrameBuffer(com.jme3.texture.FrameBuffer) * @see Renderer#setFrameBuffer(com.jme3.texture.FrameBuffer)
*/ */
public FrameBuffer boundFB; public FrameBuffer boundFB;
/** /**
* Currently bound Renderbuffer * Currently bound Renderbuffer
* *
* @see Renderer#setFrameBuffer(com.jme3.texture.FrameBuffer) * @see Renderer#setFrameBuffer(com.jme3.texture.FrameBuffer)
*/ */
public int boundRB = 0; public int boundRB;
/** /**
* Currently bound draw buffer * Currently bound draw buffer
@ -174,20 +173,20 @@ public class RenderContext {
* 0 = GL_COLOR_ATTACHMENT0 * 0 = GL_COLOR_ATTACHMENT0
* n = GL_COLOR_ATTACHMENTn * n = GL_COLOR_ATTACHMENTn
* where n is an integer greater than 1 * where n is an integer greater than 1
* *
* @see Renderer#setFrameBuffer(com.jme3.texture.FrameBuffer) * @see Renderer#setFrameBuffer(com.jme3.texture.FrameBuffer)
* @see FrameBuffer#setTargetIndex(int) * @see FrameBuffer#setTargetIndex(int)
*/ */
public int boundDrawBuf = -1; public int boundDrawBuf;
/** /**
* Currently bound read buffer * Currently bound read buffer
* *
* @see RenderContext#boundDrawBuf * @see RenderContext#boundDrawBuf
* @see Renderer#setFrameBuffer(com.jme3.texture.FrameBuffer) * @see Renderer#setFrameBuffer(com.jme3.texture.FrameBuffer)
* @see FrameBuffer#setTargetIndex(int) * @see FrameBuffer#setTargetIndex(int)
*/ */
public int boundReadBuf = -1; public int boundReadBuf;
/** /**
* Currently bound element array vertex buffer. * Currently bound element array vertex buffer.
@ -207,118 +206,114 @@ public class RenderContext {
* @see Renderer#renderMesh(com.jme3.scene.Mesh, int, int, com.jme3.scene.VertexBuffer[]) * @see Renderer#renderMesh(com.jme3.scene.Mesh, int, int, com.jme3.scene.VertexBuffer[])
*/ */
public int boundArrayVBO; public int boundArrayVBO;
/** /**
* Currently bound pixel pack pixel buffer. * Currently bound pixel pack pixel buffer.
*/ */
public int boundPixelPackPBO; public int boundPixelPackPBO;
public int numTexturesSet = 0; public int numTexturesSet;
/** /**
* Current bound texture IDs for each texture unit. * Current bound texture IDs for each texture unit.
* *
* @see Renderer#setTexture(int, com.jme3.texture.Texture) * @see Renderer#setTexture(int, com.jme3.texture.Texture)
*/ */
public Image[] boundTextures = new Image[16]; public final Image[] boundTextures = new Image[16];
/** /**
* IDList for texture units * IDList for texture units
* *
* @see Renderer#setTexture(int, com.jme3.texture.Texture) * @see Renderer#setTexture(int, com.jme3.texture.Texture)
*/ */
public IDList textureIndexList = new IDList(); public final IDList textureIndexList = new IDList();
/** /**
* Currently bound texture unit * Currently bound texture unit
* *
* @see Renderer#setTexture(int, com.jme3.texture.Texture) * @see Renderer#setTexture(int, com.jme3.texture.Texture)
*/ */
public int boundTextureUnit = 0; public int boundTextureUnit;
/** /**
* Stencil Buffer state * Stencil Buffer state
*/ */
public boolean stencilTest = false; public boolean stencilTest;
public RenderState.StencilOperation frontStencilStencilFailOperation = RenderState.StencilOperation.Keep; public RenderState.StencilOperation frontStencilStencilFailOperation;
public RenderState.StencilOperation frontStencilDepthFailOperation = RenderState.StencilOperation.Keep; public RenderState.StencilOperation frontStencilDepthFailOperation;
public RenderState.StencilOperation frontStencilDepthPassOperation = RenderState.StencilOperation.Keep; public RenderState.StencilOperation frontStencilDepthPassOperation;
public RenderState.StencilOperation backStencilStencilFailOperation = RenderState.StencilOperation.Keep; public RenderState.StencilOperation backStencilStencilFailOperation;
public RenderState.StencilOperation backStencilDepthFailOperation = RenderState.StencilOperation.Keep; public RenderState.StencilOperation backStencilDepthFailOperation;
public RenderState.StencilOperation backStencilDepthPassOperation = RenderState.StencilOperation.Keep; public RenderState.StencilOperation backStencilDepthPassOperation;
public RenderState.TestFunction frontStencilFunction = RenderState.TestFunction.Always; public RenderState.TestFunction frontStencilFunction;
public RenderState.TestFunction backStencilFunction = RenderState.TestFunction.Always; public RenderState.TestFunction backStencilFunction;
/** /**
* Vertex attribs currently bound and enabled. If a slot is null, then * Vertex attribs currently bound and enabled. If a slot is null, then
* it is disabled. * it is disabled.
*/ */
public VertexBuffer[] boundAttribs = new VertexBuffer[16]; public final VertexBuffer[] boundAttribs = new VertexBuffer[16];
/** /**
* IDList for vertex attributes * IDList for vertex attributes
*/ */
public IDList attribIndexList = new IDList(); public final IDList attribIndexList = new IDList();
/** /**
* depth test function * depth test function
*/ */
public RenderState.TestFunction depthFunc = RenderState.TestFunction.Less; public RenderState.TestFunction depthFunc;
/** /**
* alpha test function * alpha test function
*/ */
public RenderState.TestFunction alphaFunc = RenderState.TestFunction.Greater; public RenderState.TestFunction alphaFunc;
public int initialDrawBuf; public int initialDrawBuf;
public int initialReadBuf; public int initialReadBuf;
public ColorRGBA clearColor = new ColorRGBA(0,0,0,0); public ColorRGBA clearColor = new ColorRGBA(0, 0, 0, 0);
/** public RenderContext() {
* Reset the RenderContext to default GL state init();
*/ }
public void reset(){
private void init() {
cullMode = RenderState.FaceCullMode.Off; cullMode = RenderState.FaceCullMode.Off;
depthTestEnabled = false; depthTestEnabled = false;
depthWriteEnabled = false; depthWriteEnabled = true;
colorWriteEnabled = false; colorWriteEnabled = true;
clipRectEnabled = false; clipRectEnabled = false;
polyOffsetEnabled = false; polyOffsetEnabled = false;
polyOffsetFactor = 0; polyOffsetFactor = 0;
polyOffsetUnits = 0; polyOffsetUnits = 0;
pointSize = 1; pointSize = 1;
lineWidth = 1;
blendMode = RenderState.BlendMode.Off; blendMode = RenderState.BlendMode.Off;
blendEquation = RenderState.BlendEquation.Add; blendEquation = RenderState.BlendEquation.Add;
blendEquationAlpha = RenderState.BlendEquationAlpha.InheritColor; blendEquationAlpha = RenderState.BlendEquationAlpha.InheritColor;
sfactorRGB = BlendFunc.One; sfactorRGB = RenderState.BlendFunc.One;
dfactorRGB = BlendFunc.One; dfactorRGB = RenderState.BlendFunc.One;
sfactorAlpha = BlendFunc.One; sfactorAlpha = RenderState.BlendFunc.One;
dfactorAlpha = BlendFunc.One; dfactorAlpha = RenderState.BlendFunc.One;
wireframe = false; wireframe = false;
boundShaderProgram = 0; boundShaderProgram = 0;
boundShader = null; boundShader = null;
boundFBO = 0; boundFBO = 0;
boundFB = null; boundFB = null;
boundRB = 0; boundRB = 0;
boundDrawBuf = -1; boundDrawBuf = -1;
boundReadBuf = -1; boundReadBuf = -1;
boundElementArrayVBO = 0; boundElementArrayVBO = 0;
boundVertexArray = 0; boundVertexArray = 0;
boundArrayVBO = 0; boundArrayVBO = 0;
boundPixelPackPBO = 0; boundPixelPackPBO = 0;
numTexturesSet = 0; numTexturesSet = 0;
for (int i = 0; i < boundTextures.length; i++)
boundTextures[i] = null;
textureIndexList.reset();
boundTextureUnit = 0; boundTextureUnit = 0;
for (int i = 0; i < boundAttribs.length; i++)
boundAttribs[i] = null;
attribIndexList.reset();
stencilTest = false; stencilTest = false;
frontStencilStencilFailOperation = RenderState.StencilOperation.Keep; frontStencilStencilFailOperation = RenderState.StencilOperation.Keep;
frontStencilDepthFailOperation = RenderState.StencilOperation.Keep; frontStencilDepthFailOperation = RenderState.StencilOperation.Keep;
frontStencilDepthPassOperation = RenderState.StencilOperation.Keep; frontStencilDepthPassOperation = RenderState.StencilOperation.Keep;
@ -327,9 +322,30 @@ public class RenderContext {
backStencilDepthPassOperation = RenderState.StencilOperation.Keep; backStencilDepthPassOperation = RenderState.StencilOperation.Keep;
frontStencilFunction = RenderState.TestFunction.Always; frontStencilFunction = RenderState.TestFunction.Always;
backStencilFunction = RenderState.TestFunction.Always; backStencilFunction = RenderState.TestFunction.Always;
depthFunc = RenderState.TestFunction.LessOrEqual; depthFunc = RenderState.TestFunction.Less;
alphaFunc = RenderState.TestFunction.Greater; alphaFunc = RenderState.TestFunction.Greater;
clearColor.set(0,0,0,0); cullMode = RenderState.FaceCullMode.Off;
clearColor.set(0, 0, 0, 0);
}
/**
* Reset the RenderContext to default GL state
*/
public void reset(){
init();
for (int i = 0; i < boundTextures.length; i++) {
boundTextures[i] = null;
}
textureIndexList.reset();
for (int i = 0; i < boundAttribs.length; i++) {
boundAttribs[i] = null;
}
attribIndexList.reset();
} }
} }

View File

@ -1527,7 +1527,11 @@ public class Mesh implements Savable, Cloneable, JmeCloneable {
} }
public MorphTarget[] getMorphTargets() { public MorphTarget[] getMorphTargets() {
return morphTargets.getArray(); if (morphTargets == null) {
return new MorphTarget[0];
} else {
return morphTargets.getArray();
}
} }
/** /**

View File

@ -55,7 +55,7 @@ public class Line extends Mesh {
/** /**
* No-argument constructor needed by SavableClassUtil. * No-argument constructor needed by SavableClassUtil.
*/ */
public Line() { // TODO protected protected Line() {
} }
public Line(Vector3f start, Vector3f end) { public Line(Vector3f start, Vector3f end) {
@ -69,7 +69,6 @@ public class Line extends Mesh {
setBuffer(Type.Position, 3, new float[]{start.x, start.y, start.z, setBuffer(Type.Position, 3, new float[]{start.x, start.y, start.z,
end.x, end.y, end.z,}); end.x, end.y, end.z,});
setBuffer(Type.TexCoord, 2, new float[]{0, 0, setBuffer(Type.TexCoord, 2, new float[]{0, 0,
1, 1}); 1, 1});

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2009-2019 jMonkeyEngine * Copyright (c) 2009-2020 jMonkeyEngine
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -171,7 +171,7 @@ public abstract class JmeSystemDelegate {
return is64 ? Platform.Windows64 : Platform.Windows32; return is64 ? Platform.Windows64 : Platform.Windows32;
} else if (os.contains("linux") || os.contains("freebsd") } else if (os.contains("linux") || os.contains("freebsd")
|| os.contains("sunos") || os.contains("unix")) { || os.contains("sunos") || os.contains("unix")) {
if (arch.startsWith("arm")) { if (arch.startsWith("arm") || arch.startsWith("aarch")) {
return is64 ? Platform.Linux_ARM64 : Platform.Linux_ARM32; return is64 ? Platform.Linux_ARM64 : Platform.Linux_ARM32;
} else { } else {
return is64 ? Platform.Linux64 : Platform.Linux32; return is64 ? Platform.Linux64 : Platform.Linux32;

View File

@ -54,7 +54,7 @@ import java.util.concurrent.ConcurrentHashMap;
/** /**
* <code>BufferUtils</code> is a helper class for generating nio buffers from * <code>BufferUtils</code> is a helper class for generating nio buffers from
* jME data classes such as Vectors and ColorRGBA. * jME data classes such as Vectors and ColorRGBA.
* *
* @author Joshua Slack * @author Joshua Slack
* @version $Id: BufferUtils.java,v 1.16 2007/10/29 16:56:18 nca Exp $ * @version $Id: BufferUtils.java,v 1.16 2007/10/29 16:56:18 nca Exp $
*/ */
@ -74,7 +74,7 @@ public final class BufferUtils {
* Set it to true if you want to enable direct memory tracking for debugging * Set it to true if you want to enable direct memory tracking for debugging
* purpose. Default is false. To print direct memory usage use * purpose. Default is false. To print direct memory usage use
* BufferUtils.printCurrentDirectMemory(StringBuilder store); * BufferUtils.printCurrentDirectMemory(StringBuilder store);
* *
* @param enabled * @param enabled
*/ */
public static void setTrackDirectMemoryEnabled(boolean enabled) { public static void setTrackDirectMemoryEnabled(boolean enabled) {
@ -84,7 +84,7 @@ public final class BufferUtils {
/** /**
* Creates a clone of the given buffer. The clone's capacity is equal to the * Creates a clone of the given buffer. The clone's capacity is equal to the
* given buffer's limit. * given buffer's limit.
* *
* @param buf * @param buf
* The buffer to clone * The buffer to clone
* @return The cloned buffer * @return The cloned buffer
@ -141,7 +141,7 @@ public final class BufferUtils {
* Generate a new FloatBuffer using the given array of Vector3f objects. The * Generate a new FloatBuffer using the given array of Vector3f objects. The
* FloatBuffer will be 3 * data.length long and contain the vector data as * FloatBuffer will be 3 * data.length long and contain the vector data as
* data[0].x, data[0].y, data[0].z, data[1].x... etc. * data[0].x, data[0].y, data[0].z, data[1].x... etc.
* *
* @param data * @param data
* array of Vector3f objects to place into a new FloatBuffer * array of Vector3f objects to place into a new FloatBuffer
*/ */
@ -164,7 +164,7 @@ public final class BufferUtils {
/** /**
* Generate a new FloatBuffer using the given array of Quaternion objects. * Generate a new FloatBuffer using the given array of Quaternion objects.
* The FloatBuffer will be 4 * data.length long and contain the vector data. * The FloatBuffer will be 4 * data.length long and contain the vector data.
* *
* @param data * @param data
* array of Quaternion objects to place into a new FloatBuffer * array of Quaternion objects to place into a new FloatBuffer
*/ */
@ -232,7 +232,7 @@ public final class BufferUtils {
/** /**
* Generate a new FloatBuffer using the given array of float primitives. * Generate a new FloatBuffer using the given array of float primitives.
* *
* @param data * @param data
* array of float primitives to place into a new FloatBuffer * array of float primitives to place into a new FloatBuffer
*/ */
@ -250,7 +250,7 @@ public final class BufferUtils {
/** /**
* Create a new FloatBuffer of an appropriate size to hold the specified * Create a new FloatBuffer of an appropriate size to hold the specified
* number of Vector3f object data. * number of Vector3f object data.
* *
* @param vertices * @param vertices
* number of vertices that need to be held by the newly created * number of vertices that need to be held by the newly created
* buffer * buffer
@ -265,7 +265,7 @@ public final class BufferUtils {
* Create a new FloatBuffer of an appropriate size to hold the specified * Create a new FloatBuffer of an appropriate size to hold the specified
* number of Vector3f object data only if the given buffer if not already * number of Vector3f object data only if the given buffer if not already
* the right size. * the right size.
* *
* @param buf * @param buf
* the buffer to first check and rewind * the buffer to first check and rewind
* @param vertices * @param vertices
@ -285,7 +285,7 @@ public final class BufferUtils {
/** /**
* Sets the data contained in the given color into the FloatBuffer at the * Sets the data contained in the given color into the FloatBuffer at the
* specified index. * specified index.
* *
* @param color * @param color
* the data to insert * the data to insert
* @param buf * @param buf
@ -304,7 +304,7 @@ public final class BufferUtils {
/** /**
* Sets the data contained in the given quaternion into the FloatBuffer at * Sets the data contained in the given quaternion into the FloatBuffer at
* the specified index. * the specified index.
* *
* @param quat * @param quat
* the {@link Quaternion} to insert * the {@link Quaternion} to insert
* @param buf * @param buf
@ -343,7 +343,7 @@ public final class BufferUtils {
/** /**
* Sets the data contained in the given Vector3F into the FloatBuffer at the * Sets the data contained in the given Vector3F into the FloatBuffer at the
* specified index. * specified index.
* *
* @param vector * @param vector
* the data to insert * the data to insert
* @param buf * @param buf
@ -369,7 +369,7 @@ public final class BufferUtils {
/** /**
* Updates the values of the given vector from the specified buffer at the * Updates the values of the given vector from the specified buffer at the
* index provided. * index provided.
* *
* @param vector * @param vector
* the vector to set data on * the vector to set data on
* @param buf * @param buf
@ -387,7 +387,7 @@ public final class BufferUtils {
/** /**
* Updates the values of the given vector from the specified buffer at the * Updates the values of the given vector from the specified buffer at the
* index provided. * index provided.
* *
* @param vector * @param vector
* the vector to set data on * the vector to set data on
* @param buf * @param buf
@ -405,7 +405,7 @@ public final class BufferUtils {
/** /**
* Generates a Vector3f array from the given FloatBuffer. * Generates a Vector3f array from the given FloatBuffer.
* *
* @param buff * @param buff
* the FloatBuffer to read from * the FloatBuffer to read from
* @return a newly generated array of Vector3f objects * @return a newly generated array of Vector3f objects
@ -424,7 +424,7 @@ public final class BufferUtils {
* Copies a Vector3f from one position in the buffer to another. The index * Copies a Vector3f from one position in the buffer to another. The index
* values are in terms of vector number (eg, vector number 0 is positions * values are in terms of vector number (eg, vector number 0 is positions
* 0-2 in the FloatBuffer.) * 0-2 in the FloatBuffer.)
* *
* @param buf * @param buf
* the buffer to copy from/to * the buffer to copy from/to
* @param fromPos * @param fromPos
@ -438,7 +438,7 @@ public final class BufferUtils {
/** /**
* Normalize a Vector3f in-buffer. * Normalize a Vector3f in-buffer.
* *
* @param buf * @param buf
* the buffer to find the Vector3f within * the buffer to find the Vector3f within
* @param index * @param index
@ -456,7 +456,7 @@ public final class BufferUtils {
/** /**
* Add to a Vector3f in-buffer. * Add to a Vector3f in-buffer.
* *
* @param toAdd * @param toAdd
* the vector to add from * the vector to add from
* @param buf * @param buf
@ -476,7 +476,7 @@ public final class BufferUtils {
/** /**
* Multiply and store a Vector3f in-buffer. * Multiply and store a Vector3f in-buffer.
* *
* @param toMult * @param toMult
* the vector to multiply against * the vector to multiply against
* @param buf * @param buf
@ -497,7 +497,7 @@ public final class BufferUtils {
/** /**
* Checks to see if the given Vector3f is equals to the data stored in the * Checks to see if the given Vector3f is equals to the data stored in the
* buffer at the given data index. * buffer at the given data index.
* *
* @param check * @param check
* the vector to check against - null will return false. * the vector to check against - null will return false.
* @param buf * @param buf
@ -521,7 +521,7 @@ public final class BufferUtils {
* Generate a new FloatBuffer using the given array of Vector2f objects. The * Generate a new FloatBuffer using the given array of Vector2f objects. The
* FloatBuffer will be 2 * data.length long and contain the vector data as * FloatBuffer will be 2 * data.length long and contain the vector data as
* data[0].x, data[0].y, data[1].x... etc. * data[0].x, data[0].y, data[1].x... etc.
* *
* @param data * @param data
* array of Vector2f objects to place into a new FloatBuffer * array of Vector2f objects to place into a new FloatBuffer
*/ */
@ -544,7 +544,7 @@ public final class BufferUtils {
/** /**
* Create a new FloatBuffer of an appropriate size to hold the specified * Create a new FloatBuffer of an appropriate size to hold the specified
* number of Vector2f object data. * number of Vector2f object data.
* *
* @param vertices * @param vertices
* number of vertices that need to be held by the newly created * number of vertices that need to be held by the newly created
* buffer * buffer
@ -559,7 +559,7 @@ public final class BufferUtils {
* Create a new FloatBuffer of an appropriate size to hold the specified * Create a new FloatBuffer of an appropriate size to hold the specified
* number of Vector2f object data only if the given buffer if not already * number of Vector2f object data only if the given buffer if not already
* the right size. * the right size.
* *
* @param buf * @param buf
* the buffer to first check and rewind * the buffer to first check and rewind
* @param vertices * @param vertices
@ -579,7 +579,7 @@ public final class BufferUtils {
/** /**
* Sets the data contained in the given Vector2F into the FloatBuffer at the * Sets the data contained in the given Vector2F into the FloatBuffer at the
* specified index. * specified index.
* *
* @param vector * @param vector
* the data to insert * the data to insert
* @param buf * @param buf
@ -595,7 +595,7 @@ public final class BufferUtils {
/** /**
* Updates the values of the given vector from the specified buffer at the * Updates the values of the given vector from the specified buffer at the
* index provided. * index provided.
* *
* @param vector * @param vector
* the vector to set data on * the vector to set data on
* @param buf * @param buf
@ -611,7 +611,7 @@ public final class BufferUtils {
/** /**
* Generates a Vector2f array from the given FloatBuffer. * Generates a Vector2f array from the given FloatBuffer.
* *
* @param buff * @param buff
* the FloatBuffer to read from * the FloatBuffer to read from
* @return a newly generated array of Vector2f objects * @return a newly generated array of Vector2f objects
@ -630,7 +630,7 @@ public final class BufferUtils {
* Copies a Vector2f from one position in the buffer to another. The index * Copies a Vector2f from one position in the buffer to another. The index
* values are in terms of vector number (eg, vector number 0 is positions * values are in terms of vector number (eg, vector number 0 is positions
* 0-1 in the FloatBuffer.) * 0-1 in the FloatBuffer.)
* *
* @param buf * @param buf
* the buffer to copy from/to * the buffer to copy from/to
* @param fromPos * @param fromPos
@ -644,7 +644,7 @@ public final class BufferUtils {
/** /**
* Normalize a Vector2f in-buffer. * Normalize a Vector2f in-buffer.
* *
* @param buf * @param buf
* the buffer to find the Vector2f within * the buffer to find the Vector2f within
* @param index * @param index
@ -662,7 +662,7 @@ public final class BufferUtils {
/** /**
* Add to a Vector2f in-buffer. * Add to a Vector2f in-buffer.
* *
* @param toAdd * @param toAdd
* the vector to add from * the vector to add from
* @param buf * @param buf
@ -682,7 +682,7 @@ public final class BufferUtils {
/** /**
* Multiply and store a Vector2f in-buffer. * Multiply and store a Vector2f in-buffer.
* *
* @param toMult * @param toMult
* the vector to multiply against * the vector to multiply against
* @param buf * @param buf
@ -703,7 +703,7 @@ public final class BufferUtils {
/** /**
* Checks to see if the given Vector2f is equals to the data stored in the * Checks to see if the given Vector2f is equals to the data stored in the
* buffer at the given data index. * buffer at the given data index.
* *
* @param check * @param check
* the vector to check against - null will return false. * the vector to check against - null will return false.
* @param buf * @param buf
@ -727,7 +727,7 @@ public final class BufferUtils {
* Generate a new IntBuffer using the given array of ints. The IntBuffer * Generate a new IntBuffer using the given array of ints. The IntBuffer
* will be data.length long and contain the int data as data[0], data[1]... * will be data.length long and contain the int data as data[0], data[1]...
* etc. * etc.
* *
* @param data * @param data
* array of ints to place into a new IntBuffer * array of ints to place into a new IntBuffer
*/ */
@ -745,7 +745,7 @@ public final class BufferUtils {
/** /**
* Create a new int[] array and populate it with the given IntBuffer's * Create a new int[] array and populate it with the given IntBuffer's
* contents. * contents.
* *
* @param buff * @param buff
* the IntBuffer to read from * the IntBuffer to read from
* @return a new int array populated from the IntBuffer * @return a new int array populated from the IntBuffer
@ -765,7 +765,7 @@ public final class BufferUtils {
/** /**
* Create a new float[] array and populate it with the given FloatBuffer's * Create a new float[] array and populate it with the given FloatBuffer's
* contents. * contents.
* *
* @param buff * @param buff
* the FloatBuffer to read from * the FloatBuffer to read from
* @return a new float array populated from the FloatBuffer * @return a new float array populated from the FloatBuffer
@ -785,7 +785,7 @@ public final class BufferUtils {
//// -- GENERAL DOUBLE ROUTINES -- //// //// -- GENERAL DOUBLE ROUTINES -- ////
/** /**
* Create a new DoubleBuffer of the specified size. * Create a new DoubleBuffer of the specified size.
* *
* @param size * @param size
* required number of double to store. * required number of double to store.
* @return the new DoubleBuffer * @return the new DoubleBuffer
@ -800,7 +800,7 @@ public final class BufferUtils {
/** /**
* Create a new DoubleBuffer of an appropriate size to hold the specified * Create a new DoubleBuffer of an appropriate size to hold the specified
* number of doubles only if the given buffer if not already the right size. * number of doubles only if the given buffer if not already the right size.
* *
* @param buf * @param buf
* the buffer to first check and rewind * the buffer to first check and rewind
* @param size * @param size
@ -823,7 +823,7 @@ public final class BufferUtils {
* DoubleBuffer. The new DoubleBuffer is separate from the old one and * DoubleBuffer. The new DoubleBuffer is separate from the old one and
* changes are not reflected across. If you want to reflect changes, * changes are not reflected across. If you want to reflect changes,
* consider using Buffer.duplicate(). * consider using Buffer.duplicate().
* *
* @param buf * @param buf
* the DoubleBuffer to copy * the DoubleBuffer to copy
* @return the copy * @return the copy
@ -848,7 +848,7 @@ public final class BufferUtils {
//// -- GENERAL FLOAT ROUTINES -- //// //// -- GENERAL FLOAT ROUTINES -- ////
/** /**
* Create a new FloatBuffer of the specified size. * Create a new FloatBuffer of the specified size.
* *
* @param size * @param size
* required number of floats to store. * required number of floats to store.
* @return the new FloatBuffer * @return the new FloatBuffer
@ -862,7 +862,7 @@ public final class BufferUtils {
/** /**
* Copies floats from one position in the buffer to another. * Copies floats from one position in the buffer to another.
* *
* @param buf * @param buf
* the buffer to copy from/to * the buffer to copy from/to
* @param fromPos * @param fromPos
@ -885,7 +885,7 @@ public final class BufferUtils {
* FloatBuffer. The new FloatBuffer is separate from the old one and changes * FloatBuffer. The new FloatBuffer is separate from the old one and changes
* are not reflected across. If you want to reflect changes, consider using * are not reflected across. If you want to reflect changes, consider using
* Buffer.duplicate(). * Buffer.duplicate().
* *
* @param buf * @param buf
* the FloatBuffer to copy * the FloatBuffer to copy
* @return the copy * @return the copy
@ -910,7 +910,7 @@ public final class BufferUtils {
//// -- GENERAL INT ROUTINES -- //// //// -- GENERAL INT ROUTINES -- ////
/** /**
* Create a new IntBuffer of the specified size. * Create a new IntBuffer of the specified size.
* *
* @param size * @param size
* required number of ints to store. * required number of ints to store.
* @return the new IntBuffer * @return the new IntBuffer
@ -925,7 +925,7 @@ public final class BufferUtils {
/** /**
* Create a new IntBuffer of an appropriate size to hold the specified * Create a new IntBuffer of an appropriate size to hold the specified
* number of ints only if the given buffer if not already the right size. * number of ints only if the given buffer if not already the right size.
* *
* @param buf * @param buf
* the buffer to first check and rewind * the buffer to first check and rewind
* @param size * @param size
@ -948,7 +948,7 @@ public final class BufferUtils {
* The new IntBuffer is separate from the old one and changes are not * The new IntBuffer is separate from the old one and changes are not
* reflected across. If you want to reflect changes, consider using * reflected across. If you want to reflect changes, consider using
* Buffer.duplicate(). * Buffer.duplicate().
* *
* @param buf * @param buf
* the IntBuffer to copy * the IntBuffer to copy
* @return the copy * @return the copy
@ -973,7 +973,7 @@ public final class BufferUtils {
//// -- GENERAL BYTE ROUTINES -- //// //// -- GENERAL BYTE ROUTINES -- ////
/** /**
* Create a new ByteBuffer of the specified size. * Create a new ByteBuffer of the specified size.
* *
* @param size * @param size
* required number of ints to store. * required number of ints to store.
* @return the new IntBuffer * @return the new IntBuffer
@ -988,7 +988,7 @@ public final class BufferUtils {
/** /**
* Create a new ByteBuffer of an appropriate size to hold the specified * Create a new ByteBuffer of an appropriate size to hold the specified
* number of ints only if the given buffer if not already the right size. * number of ints only if the given buffer if not already the right size.
* *
* @param buf * @param buf
* the buffer to first check and rewind * the buffer to first check and rewind
* @param size * @param size
@ -1030,7 +1030,7 @@ public final class BufferUtils {
* The new ByteBuffer is separate from the old one and changes are not * The new ByteBuffer is separate from the old one and changes are not
* reflected across. If you want to reflect changes, consider using * reflected across. If you want to reflect changes, consider using
* Buffer.duplicate(). * Buffer.duplicate().
* *
* @param buf * @param buf
* the ByteBuffer to copy * the ByteBuffer to copy
* @return the copy * @return the copy
@ -1055,7 +1055,7 @@ public final class BufferUtils {
//// -- GENERAL SHORT ROUTINES -- //// //// -- GENERAL SHORT ROUTINES -- ////
/** /**
* Create a new ShortBuffer of the specified size. * Create a new ShortBuffer of the specified size.
* *
* @param size * @param size
* required number of shorts to store. * required number of shorts to store.
* @return the new ShortBuffer * @return the new ShortBuffer
@ -1070,7 +1070,7 @@ public final class BufferUtils {
/** /**
* Create a new ShortBuffer of an appropriate size to hold the specified * Create a new ShortBuffer of an appropriate size to hold the specified
* number of shorts only if the given buffer if not already the right size. * number of shorts only if the given buffer if not already the right size.
* *
* @param buf * @param buf
* the buffer to first check and rewind * the buffer to first check and rewind
* @param size * @param size
@ -1104,7 +1104,7 @@ public final class BufferUtils {
* ShortBuffer. The new ShortBuffer is separate from the old one and changes * ShortBuffer. The new ShortBuffer is separate from the old one and changes
* are not reflected across. If you want to reflect changes, consider using * are not reflected across. If you want to reflect changes, consider using
* Buffer.duplicate(). * Buffer.duplicate().
* *
* @param buf * @param buf
* the ShortBuffer to copy * the ShortBuffer to copy
* @return the copy * @return the copy
@ -1130,7 +1130,7 @@ public final class BufferUtils {
* Ensures there is at least the <code>required</code> number of entries * Ensures there is at least the <code>required</code> number of entries
* left after the current position of the buffer. If the buffer is too small * left after the current position of the buffer. If the buffer is too small
* a larger one is created and the old one copied to the new buffer. * a larger one is created and the old one copied to the new buffer.
* *
* @param buffer * @param buffer
* buffer that should be checked/copied (may be null) * buffer that should be checked/copied (may be null)
* @param required * @param required
@ -1277,36 +1277,14 @@ public final class BufferUtils {
allocator.destroyDirectBuffer(toBeDestroyed); allocator.destroyDirectBuffer(toBeDestroyed);
} }
/* /**
* FIXME when java 1.5 supprt is dropped - replace calls to this method with * Test whether the specified buffer is direct.
* Buffer.isDirect *
* * @param buf the buffer to test (not null, unaffected)
* Buffer.isDirect() is only java 6. Java 5 only have this method on Buffer * @return true if direct, otherwise false
* subclasses : FloatBuffer, IntBuffer, ShortBuffer,
* ByteBuffer,DoubleBuffer, LongBuffer. CharBuffer has been excluded as we
* don't use it.
*
*/ */
private static boolean isDirect(Buffer buf) { private static boolean isDirect(Buffer buf) {
if (buf instanceof FloatBuffer) { return buf.isDirect();
return ((FloatBuffer) buf).isDirect();
}
if (buf instanceof IntBuffer) {
return ((IntBuffer) buf).isDirect();
}
if (buf instanceof ShortBuffer) {
return ((ShortBuffer) buf).isDirect();
}
if (buf instanceof ByteBuffer) {
return ((ByteBuffer) buf).isDirect();
}
if (buf instanceof DoubleBuffer) {
return ((DoubleBuffer) buf).isDirect();
}
if (buf instanceof LongBuffer) {
return ((LongBuffer) buf).isDirect();
}
throw new UnsupportedOperationException(" BufferUtils.isDirect was called on " + buf.getClass().getName());
} }
private static class BufferInfo extends PhantomReference<Buffer> { private static class BufferInfo extends PhantomReference<Buffer> {

View File

@ -168,7 +168,7 @@ MaterialDef PBR Lighting {
Technique PreShadow { Technique PreShadow {
VertexShader GLSL300 GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadow.vert VertexShader GLSL300 GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadow.vert
FragmentShader GLSL300 GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadow.frag FragmentShader GLSL300 GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadowPBR.frag
WorldParameters { WorldParameters {
WorldViewProjectionMatrix WorldViewProjectionMatrix
@ -196,9 +196,9 @@ MaterialDef PBR Lighting {
} }
Technique PostShadow{ Technique PostShadow {
VertexShader GLSL310 GLSL300 GLSL150: Common/MatDefs/Shadow/PostShadow.vert VertexShader GLSL310 GLSL300 GLSL100 GLSL150: Common/MatDefs/Shadow/PostShadow.vert
FragmentShader GLSL310 GLSL300 GLSL150: Common/MatDefs/Shadow/PostShadow.frag FragmentShader GLSL310 GLSL300 GLSL100 GLSL150: Common/MatDefs/Shadow/PostShadowPBR.frag
WorldParameters { WorldParameters {
WorldViewProjectionMatrix WorldViewProjectionMatrix
@ -213,7 +213,6 @@ MaterialDef PBR Lighting {
PCFEDGE : PCFEdge PCFEDGE : PCFEdge
DISCARD_ALPHA : AlphaDiscardThreshold DISCARD_ALPHA : AlphaDiscardThreshold
SHADOWMAP_SIZE : ShadowMapSize SHADOWMAP_SIZE : ShadowMapSize
SHADOWMAP_SIZE : ShadowMapSize
FADE : FadeInfo FADE : FadeInfo
PSSM : Splits PSSM : Splits
POINTLIGHT : LightViewProjectionMatrix5 POINTLIGHT : LightViewProjectionMatrix5
@ -231,40 +230,6 @@ MaterialDef PBR Lighting {
} }
} }
Technique PostShadow{
VertexShader GLSL100: Common/MatDefs/Shadow/PostShadow.vert
FragmentShader GLSL100: Common/MatDefs/Shadow/PostShadow.frag
WorldParameters {
WorldViewProjectionMatrix
WorldMatrix
ViewProjectionMatrix
ViewMatrix
}
Defines {
HARDWARE_SHADOWS : HardwareShadows
FILTER_MODE : FilterMode
PCFEDGE : PCFEdge
DISCARD_ALPHA : AlphaDiscardThreshold
SHADOWMAP_SIZE : ShadowMapSize
FADE : FadeInfo
PSSM : Splits
POINTLIGHT : LightViewProjectionMatrix5
NUM_BONES : NumberOfBones
INSTANCING : UseInstancing
BACKFACE_SHADOWS: BackfaceShadows
NUM_MORPH_TARGETS: NumberOfMorphTargets
NUM_TARGETS_BUFFERS: NumberOfTargetsBuffers
}
ForcedRenderState {
Blend Modulate
DepthWrite Off
PolyOffset -0.1 0
}
}
Technique PreNormalPass { Technique PreNormalPass {
VertexShader GLSL100 : Common/MatDefs/SSAO/normal.vert VertexShader GLSL100 : Common/MatDefs/SSAO/normal.vert

View File

@ -0,0 +1,89 @@
#import "Common/ShaderLib/GLSLCompat.glsllib"
#import "Common/ShaderLib/Shadows.glsllib"
#if defined(PSSM) || defined(FADE)
varying float shadowPosition;
#endif
varying vec4 projCoord0;
varying vec4 projCoord1;
varying vec4 projCoord2;
varying vec4 projCoord3;
#ifndef BACKFACE_SHADOWS
varying float nDotL;
#endif
#ifdef POINTLIGHT
varying vec4 projCoord4;
varying vec4 projCoord5;
uniform vec3 m_LightPos;
varying vec4 worldPos;
#else
#ifndef PSSM
varying float lightDot;
#endif
#endif
#ifdef DISCARD_ALPHA
#ifdef COLOR_MAP
uniform sampler2D m_ColorMap;
#else
uniform sampler2D m_BaseColorMap;
#endif
uniform float m_AlphaDiscardThreshold;
varying vec2 texCoord;
#endif
#ifdef FADE
uniform vec2 m_FadeInfo;
#endif
void main(){
#ifdef DISCARD_ALPHA
#ifdef COLOR_MAP
float alpha = texture2D(m_ColorMap,texCoord).a;
#else
float alpha = texture2D(m_BaseColorMap,texCoord).a;
#endif
if(alpha<=m_AlphaDiscardThreshold){
discard;
}
#endif
#ifndef BACKFACE_SHADOWS
if(nDotL > 0.0){
discard;
}
#endif
float shadow = 1.0;
#ifdef POINTLIGHT
shadow = getPointLightShadows(worldPos, m_LightPos,
m_ShadowMap0,m_ShadowMap1,m_ShadowMap2,m_ShadowMap3,m_ShadowMap4,m_ShadowMap5,
projCoord0, projCoord1, projCoord2, projCoord3, projCoord4, projCoord5);
#else
#ifdef PSSM
shadow = getDirectionalLightShadows(m_Splits, shadowPosition,
m_ShadowMap0,m_ShadowMap1,m_ShadowMap2,m_ShadowMap3,
projCoord0, projCoord1, projCoord2, projCoord3);
#else
//spotlight
if(lightDot < 0.0){
gl_FragColor = vec4(1.0);
return;
}
shadow = getSpotLightShadows(m_ShadowMap0,projCoord0);
#endif
#endif
#ifdef FADE
shadow = max(0.0, mix(shadow, 1.0, max(0.0, (shadowPosition - m_FadeInfo.x) * m_FadeInfo.y)));
#endif
shadow = shadow * m_ShadowIntensity + (1.0 - m_ShadowIntensity);
gl_FragColor = vec4(shadow, shadow, shadow, 1.0);
}

View File

@ -0,0 +1,28 @@
#import "Common/ShaderLib/GLSLCompat.glsllib"
varying vec2 texCoord;
#ifdef DISCARD_ALPHA
#ifdef COLOR_MAP
uniform sampler2D m_ColorMap;
#else
uniform sampler2D m_BaseColorMap;
#endif
uniform float m_AlphaDiscardThreshold;
#endif
void main(){
#ifdef DISCARD_ALPHA
#ifdef COLOR_MAP
if (texture2D(m_ColorMap, texCoord).a <= m_AlphaDiscardThreshold){
discard;
}
#else
if (texture2D(m_BaseColorMap, texCoord).a <= m_AlphaDiscardThreshold){
discard;
}
#endif
#endif
gl_FragColor = vec4(1.0);
}

View File

@ -173,10 +173,13 @@ Note that it only handles morphing position, normals and tangents.
void Morph_Compute(inout vec4 pos){ void Morph_Compute(inout vec4 pos){
#if (NUM_TARGETS_BUFFERS == 2) #if (NUM_TARGETS_BUFFERS == 2)
Morph_Compute_Pos_Norm(pos,vec3(0.0)); vec3 dummy_norm = vec3(0.0);
Morph_Compute_Pos_Norm(pos, dummy_norm);
return; return;
#elif (NUM_TARGETS_BUFFERS == 3) #elif (NUM_TARGETS_BUFFERS == 3)
Morph_Compute_Pos_Norm_Tan(pos, vec3(0.0), vec3(0.0)); vec3 dummy_norm = vec3(0.0);
vec3 dummy_tan = vec3(0.0);
Morph_Compute_Pos_Norm_Tan(pos, dummy_norm, dummy_tan);
return; return;
#endif #endif
Morph_Compute_Pos(pos); Morph_Compute_Pos(pos);
@ -187,7 +190,9 @@ Note that it only handles morphing position, normals and tangents.
Morph_Compute_Pos(pos); Morph_Compute_Pos(pos);
return; return;
#elif (NUM_TARGETS_BUFFERS == 3) #elif (NUM_TARGETS_BUFFERS == 3)
Morph_Compute_Pos_Norm_Tan(pos, vec3(0.0), vec3(0.0)); vec3 dummy_norm = vec3(0.0);
vec3 dummy_tan = vec3(0.0);
Morph_Compute_Pos_Norm_Tan(pos, dummy_norm, dummy_tan);
return; return;
#elif (NUM_TARGETS_BUFFERS == 2) #elif (NUM_TARGETS_BUFFERS == 2)
Morph_Compute_Pos_Norm(pos, norm); Morph_Compute_Pos_Norm(pos, norm);

View File

@ -0,0 +1,127 @@
/*
* Copyright (c) 2009-2020 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.material.Material;
import com.jme3.niftygui.NiftyJmeDisplay;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import de.lessvoid.nifty.Nifty;
import de.lessvoid.nifty.builder.LayerBuilder;
import de.lessvoid.nifty.builder.PanelBuilder;
import de.lessvoid.nifty.builder.ScreenBuilder;
import de.lessvoid.nifty.controls.button.builder.ButtonBuilder;
import de.lessvoid.nifty.screen.Screen;
import de.lessvoid.nifty.screen.ScreenController;
public class TestIssue1013 extends SimpleApplication implements ScreenController {
public static void main(String[] args) {
new TestIssue1013().start();
}
private NiftyJmeDisplay niftyDisplay;
@Override
public void simpleInitApp() {
// this box here always renders
Box b = new Box(1, 1, 1);
Geometry geom = new Geometry("Box", b);
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.setTexture("ColorMap", assetManager.loadTexture("/com/jme3/app/Monkey.png"));
geom.setMaterial(mat);
rootNode.attachChild(geom);
niftyDisplay = NiftyJmeDisplay.newNiftyJmeDisplay(assetManager, inputManager, audioRenderer, guiViewPort);
Nifty nifty = niftyDisplay.getNifty();
nifty.loadStyleFile("nifty-default-styles.xml");
nifty.loadControlFile("nifty-default-controls.xml");
ScreenController ctrl = this;
new ScreenBuilder("start") {
{
controller(ctrl);
layer(new LayerBuilder() {
{
childLayoutVertical();
panel(new PanelBuilder() {
{
childLayoutCenter();
width("100%");
height("50%");
backgroundColor("#ff0000");
}
});
control(new ButtonBuilder("RestartButton", "Restart Context") {
{
alignCenter();
valignCenter();
height("32px");
width("480px");
interactOnClick("restartContext()");
}
});
}
});
}
}.build(nifty);
guiViewPort.addProcessor(niftyDisplay);
nifty.gotoScreen("start");
flyCam.setDragToRotate(true);
}
@Override
public void bind(Nifty nifty, Screen screen) {
}
@Override
public void onStartScreen() {
}
@Override
public void onEndScreen() {
}
public void restartContext() {
// even without changing settings, stuff breaks!
restart();
// ...and re-adding the processor doesn't help at all
guiViewPort.addProcessor(niftyDisplay);
}
}

View File

@ -0,0 +1,87 @@
/*
* Copyright (c) 2009-2020 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.renderer;
import com.jme3.app.SimpleApplication;
import com.jme3.input.KeyInput;
import com.jme3.input.controls.ActionListener;
import com.jme3.input.controls.KeyTrigger;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import com.jme3.system.AppSettings;
public class TestIssue801 extends SimpleApplication {
public static void main(String[] args) {
AppSettings initialSettings = new AppSettings(true);
initialSettings.setBitsPerPixel(24);
TestIssue801 app = new TestIssue801();
app.setSettings(initialSettings);
app.start();
}
@Override
public void simpleInitApp() {
viewPort.setBackgroundColor(new ColorRGBA(0.3f, 0.3f, 0.3f, 1f));
Box b = new Box(1, 1, 1);
Geometry geom = new Geometry("Box", b);
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.setColor("Color", ColorRGBA.Blue);
geom.setMaterial(mat);
rootNode.attachChild(geom);
inputManager.addMapping("changeBpp", new KeyTrigger(KeyInput.KEY_P));
ActionListener listener = new ActionListener() {
@Override
public void onAction(String name, boolean keyPressed, float tpf) {
if (name.equals("changeBpp") && keyPressed) {
goWindowed();
}
}
};
inputManager.addListener(listener, "changeBpp");
}
void goWindowed() {
AppSettings newSettings = new AppSettings(false);
newSettings.copyFrom(settings);
newSettings.setBitsPerPixel(16);
setSettings(newSettings);
restart();
}
}

View File

@ -83,11 +83,33 @@ public class GlfwKeyInput implements KeyInput {
@Override @Override
public void initialize() { public void initialize() {
if (!context.isRenderable()) {
return;
}
initCallbacks();
initialized = true;
logger.fine("Keyboard created.");
}
/**
* Re-initializes the key input context window specific callbacks
*/
public void resetContext() {
if (!context.isRenderable()) { if (!context.isRenderable()) {
return; return;
} }
closeCallbacks();
initCallbacks();
}
private void closeCallbacks() {
keyCallback.close();
charCallback.close();
}
private void initCallbacks() {
glfwSetKeyCallback(context.getWindowHandle(), keyCallback = new GLFWKeyCallback() { glfwSetKeyCallback(context.getWindowHandle(), keyCallback = new GLFWKeyCallback() {
@Override @Override
public void invoke(final long window, final int key, final int scancode, final int action, final int mods) { public void invoke(final long window, final int key, final int scancode, final int action, final int mods) {
@ -122,9 +144,6 @@ public class GlfwKeyInput implements KeyInput {
keyInputEvents.add(released); keyInputEvents.add(released);
} }
}); });
initialized = true;
logger.fine("Keyboard created.");
} }
public int getKeyCount() { public int getKeyCount() {
@ -149,8 +168,7 @@ public class GlfwKeyInput implements KeyInput {
return; return;
} }
keyCallback.close(); closeCallbacks();
charCallback.close();
logger.fine("Keyboard destroyed."); logger.fine("Keyboard destroyed.");
} }

View File

@ -176,7 +176,30 @@ public class GlfwMouseInput implements MouseInput {
@Override @Override
public void initialize() { public void initialize() {
initCallbacks();
if (listener != null) {
sendFirstMouseEvent();
}
setCursorVisible(cursorVisible);
logger.fine("Mouse created.");
initialized = true;
}
/**
* Re-initializes the mouse input context window specific callbacks
*/
public void resetContext() {
if (!context.isRenderable()) {
return;
}
closeCallbacks();
initCallbacks();
}
private void initCallbacks() {
final long window = context.getWindowHandle(); final long window = context.getWindowHandle();
try (MemoryStack stack = MemoryStack.stackPush()) { try (MemoryStack stack = MemoryStack.stackPush()) {
@ -219,14 +242,6 @@ public class GlfwMouseInput implements MouseInput {
currentWidth = width; currentWidth = width;
} }
}); });
if(listener != null) {
sendFirstMouseEvent();
}
setCursorVisible(cursorVisible);
logger.fine("Mouse created.");
initialized = true;
} }
private void initCurrentMousePosition(long window) { private void initCurrentMousePosition(long window) {
@ -295,9 +310,7 @@ public class GlfwMouseInput implements MouseInput {
return; return;
} }
cursorPosCallback.close(); closeCallbacks();
scrollCallback.close();
mouseButtonCallback.close();
currentCursor = null; currentCursor = null;
currentCursorDelays = null; currentCursorDelays = null;
@ -313,6 +326,12 @@ public class GlfwMouseInput implements MouseInput {
logger.fine("Mouse destroyed."); logger.fine("Mouse destroyed.");
} }
private void closeCallbacks() {
cursorPosCallback.close();
scrollCallback.close();
mouseButtonCallback.close();
}
@Override @Override
public void setCursorVisible(boolean visible) { public void setCursorVisible(boolean visible) {
cursorVisible = visible; cursorVisible = visible;

View File

@ -47,6 +47,7 @@ import com.jme3.util.BufferUtils;
import java.awt.*; import java.awt.*;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.IntBuffer;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -121,6 +122,7 @@ public abstract class LwjglWindow extends LwjglContext implements Runnable {
private GLFWErrorCallback errorCallback; private GLFWErrorCallback errorCallback;
private GLFWWindowSizeCallback windowSizeCallback; private GLFWWindowSizeCallback windowSizeCallback;
private GLFWFramebufferSizeCallback framebufferSizeCallback;
private GLFWWindowFocusCallback windowFocusCallback; private GLFWWindowFocusCallback windowFocusCallback;
private Thread mainThread; private Thread mainThread;
@ -250,16 +252,8 @@ public abstract class LwjglWindow extends LwjglContext implements Runnable {
throw new RuntimeException("Failed to create the GLFW window"); throw new RuntimeException("Failed to create the GLFW window");
} }
// Add a resize callback which delegates to the listener
glfwSetWindowSizeCallback(window, windowSizeCallback = new GLFWWindowSizeCallback() {
@Override
public void invoke(final long window, final int width, final int height) {
settings.setResolution(width, height);
listener.reshape(width, height);
}
});
glfwSetWindowFocusCallback(window, windowFocusCallback = new GLFWWindowFocusCallback() { glfwSetWindowFocusCallback(window, windowFocusCallback = new GLFWWindowFocusCallback() {
@Override @Override
public void invoke(final long window, final boolean focus) { public void invoke(final long window, final boolean focus) {
if (wasActive != focus) { if (wasActive != focus) {
@ -294,7 +288,46 @@ public abstract class LwjglWindow extends LwjglContext implements Runnable {
setWindowIcon(settings); setWindowIcon(settings);
showWindow(); showWindow();
// Windows resize callback
glfwSetWindowSizeCallback(window, windowSizeCallback = new GLFWWindowSizeCallback() {
@Override
public void invoke(final long window, final int width, final int height) {
// This is the window size, never to passed to any pixel based stuff!
// https://www.glfw.org/docs/latest/window_guide.html#window_size
onWindowSizeChanged(width, height);
}
});
// Add a framebuffer resize callback which delegates to the listener
glfwSetFramebufferSizeCallback(window, framebufferSizeCallback = new GLFWFramebufferSizeCallback() {
@Override
public void invoke(final long window, final int width, final int height) {
// The window size might be also changed, but the window size callback might not trigger
// Maybe a bug in graphics drivers or LWJGL 3...? So make sure we emulate the original JME behavior here
IntBuffer windowWidth = BufferUtils.createIntBuffer(1);
IntBuffer windowHeight = BufferUtils.createIntBuffer(1);
glfwGetWindowSize(window, windowWidth, windowHeight);
onWindowSizeChanged(windowWidth.get(), windowHeight.get());
// https://www.glfw.org/docs/latest/window_guide.html#window_fbsize
listener.reshape(width, height);
}
});
allowSwapBuffers = settings.isSwapBuffers(); allowSwapBuffers = settings.isSwapBuffers();
// Create OpenCL
if (settings.isOpenCLSupport()) {
initOpenCL(window);
}
}
private void onWindowSizeChanged(final int width, final int height) {
settings.setResolution(width, height);
} }
protected void showWindow() { protected void showWindow() {
@ -303,6 +336,8 @@ public abstract class LwjglWindow extends LwjglContext implements Runnable {
/** /**
* Set custom icons to the window of this application. * Set custom icons to the window of this application.
*
* @param settings settings for getting the icons
*/ */
protected void setWindowIcon(final AppSettings settings) { protected void setWindowIcon(final AppSettings settings) {
@ -399,6 +434,11 @@ public abstract class LwjglWindow extends LwjglContext implements Runnable {
windowSizeCallback = null; windowSizeCallback = null;
} }
if (framebufferSizeCallback != null) {
framebufferSizeCallback.close();
framebufferSizeCallback = null;
}
if (windowFocusCallback != null) { if (windowFocusCallback != null) {
windowFocusCallback.close(); windowFocusCallback.close();
windowFocusCallback = null; windowFocusCallback = null;
@ -409,7 +449,6 @@ public abstract class LwjglWindow extends LwjglContext implements Runnable {
window = NULL; window = NULL;
} }
glfwTerminate();
} catch (final Exception ex) { } catch (final Exception ex) {
listener.handleError("Failed to destroy context", ex); listener.handleError("Failed to destroy context", ex);
} }
@ -429,6 +468,8 @@ public abstract class LwjglWindow extends LwjglContext implements Runnable {
/** /**
* Does LWJGL display initialization in the OpenGL thread * Does LWJGL display initialization in the OpenGL thread
*
* @return returns {@code true} if the context initialization was successful
*/ */
protected boolean initInThread() { protected boolean initInThread() {
try { try {
@ -455,13 +496,6 @@ public abstract class LwjglWindow extends LwjglContext implements Runnable {
created.set(true); created.set(true);
super.internalCreate(); super.internalCreate();
//create OpenCL
//Must be done here because the window handle is needed
if (settings.isOpenCLSupport()) {
initOpenCL(window);
}
} catch (Exception ex) { } catch (Exception ex) {
try { try {
if (window != NULL) { if (window != NULL) {
@ -486,14 +520,7 @@ public abstract class LwjglWindow extends LwjglContext implements Runnable {
protected void runLoop() { protected void runLoop() {
// If a restart is required, lets recreate the context. // If a restart is required, lets recreate the context.
if (needRestart.getAndSet(false)) { if (needRestart.getAndSet(false)) {
try { restartContext();
destroyContext();
createContext(settings);
} catch (Exception ex) {
LOGGER.log(Level.SEVERE, "Failed to set display settings!", ex);
}
LOGGER.fine("Display restarted.");
} }
if (!created.get()) { if (!created.get()) {
@ -549,6 +576,25 @@ public abstract class LwjglWindow extends LwjglContext implements Runnable {
glfwPollEvents(); glfwPollEvents();
} }
private void restartContext() {
try {
destroyContext();
createContext(settings);
} catch (Exception ex) {
LOGGER.log(Level.SEVERE, "Failed to set display settings!", ex);
}
// We need to reinit the mouse and keyboard input as they are tied to a window handle
if (keyInput != null && keyInput.isInitialized()) {
keyInput.resetContext();
}
if (mouseInput != null && mouseInput.isInitialized()) {
mouseInput.resetContext();
}
LOGGER.fine("Display restarted.");
}
private void setFrameRateLimit(int frameRateLimit) { private void setFrameRateLimit(int frameRateLimit) {
this.frameRateLimit = frameRateLimit; this.frameRateLimit = frameRateLimit;
frameSleepTime = 1000.0 / this.frameRateLimit; frameSleepTime = 1000.0 / this.frameRateLimit;
@ -562,6 +608,7 @@ public abstract class LwjglWindow extends LwjglContext implements Runnable {
destroyContext(); destroyContext();
super.internalDestroy(); super.internalDestroy();
glfwTerminate();
LOGGER.fine("Display destroyed."); LOGGER.fine("Display destroyed.");
} }

View File

@ -1793,9 +1793,8 @@ public class TerrainQuad extends Node implements Terrain {
// This was not cloned before... I think that's a mistake. // This was not cloned before... I think that's a mistake.
this.affectedAreaBBox = cloner.clone(affectedAreaBBox); this.affectedAreaBBox = cloner.clone(affectedAreaBBox);
// picker is not cloneable and not cloned. This also seems like // Otherwise, picker would be cloned by reference and thus "this" would be wrong
// a mistake if you ever load the same terrain twice. this.picker = new BresenhamTerrainPicker(this);
// this.picker = cloner.clone(picker);
// neighbourFinder is also not cloned. Maybe that's ok. // neighbourFinder is also not cloned. Maybe that's ok.
} }

View File

@ -24,36 +24,108 @@ ext {
task configureVersionInfo { task configureVersionInfo {
try { try {
// Users can configure behavior by setting properties on the command
// line:
//
// jmeVersionName:
// If set this will override all automatic version detection.
//
// useCommitHashAsVersionName:
// If there is no jmeVersionName set and the current commit has no
// specific tag then setting this to 'true' will cause the version to
// be the full commit ID.
//
// includeBranchInVersion:
// Set to true if a non-master branch name should be included in the automatically
// generated version.
def grgit = Grgit.open(project.file('.')) def grgit = Grgit.open(project.file('.'))
def head = grgit.head() def head = grgit.head()
jmeRevision = grgit.log(includes: [head]).size() jmeRevision = grgit.log(includes: [head]).size()
jmeGitHash = head.id jmeGitHash = head.id
jmeShortGitHash = head.abbreviatedId jmeShortGitHash = head.abbreviatedId
jmeBranchName = grgit.branch.current.name jmeBranchName = grgit.branch.current.name
jmeGitTag = grgit.tag.list().find { it.commit == head }
if(jmeVersionName==""){ // This code will find an exact-match tag if the current
if (jmeGitTag != null) { // commit is the same as the tag commit.
jmeGitTag = jmeGitTag.name jmeGitTag = grgit.tag.list().find { it.commit == head }
jmeFullVersion = jmeGitTag def latestTag;
jmeVersionTag = "" if( jmeGitTag ) {
} else { // Just use the name. We keep jmeGitTag separate because there
if(useCommitHashAsVersionName=="true"&&jmeGitHash!=null&&!jmeGitHash.equals("")){ // is some logic that wants to know if this specific commit has
jmeFullVersion = jmeGitHash // a tag versus 'whatever tag we are a child of'... which is what
jmeVersionTag = "" // 'latestTag' will be.
}else{ jmeGitTag = jmeGitTag.name
jmeFullVersion="${jmeVersion}-"; latestTag = jmeGitTag;
if(jmeBranchName!="master")jmeFullVersion+="${jmeBranchName}-"; } else {
jmeFullVersion+="SNAPSHOT" // Use describe to find the most recent tag. Unfortunately,
jmeVersionTag="SNAPSHOT" // in this version of grgit, we don't have the 'always' options
} // so we can't make as many assumptions about the format of the
} // string.
}else{ // If the commit is an exact match then it will return just the
jmeVersionTag="" // tag name... else it will be tagName-commitCount-abbreviatedId
jmeFullVersion=jmeVersionName // We'll use some groovy regex magic to get the tag either way.
def describe = grgit.describe()
def fullDescribe = (describe =~/(.*?)-(\d+)-g$jmeShortGitHash/)
latestTag = fullDescribe ? fullDescribe[0][1] : describe
println "Latest tag:" + latestTag
}
// We could enhance this with some more regex if we wanted to sanity
// check that it was formatted like our versions.
def tagVersion = (latestTag =~/v?(.*)/)[0][1];
// If the branch is not master then use the tag.
if( jmeBranchName != "master" ) {
jmeVersion = tagVersion
}
// Parse out just the base version part. -SNAPSHOT versions
// shouldn't really include our release suffixes
def baseVersion = (tagVersion =~/(\d+\.\d+.\d+)/)
baseVersion = baseVersion.size() > 0 ? baseVersion[0][0] : tagVersion
if( !jmeVersionName ) {
// If there is a specific tag for the top commit then we always
// use that.
if( jmeGitTag ) {
println "Using GIT tag as version"
jmeFullVersion = tagVersion; // already cleaned up
jmeVersionTag = "" // and no SNAPSHOT suffix for an exact version tag
// Note: this will not automatically add SNAPSHOT if the user has
// local changes that they haven't committed. Technically, only
// real CI builds should be using non-SNAPSHOT versions so we may
// eventually want to change the script to always use -SNAPSHOT with
// a CI option to turn it off.
// We could also check the grgit.status for unstaged modified/removed files.
// def unstaged = grgit.status().unstaged;
// def modCount = unstaged.modified.size() + unstaged.removed.size()
// ...but that seems like a wasteful check considering only official
// version builds should not have a -SNAPSHOT.
} else if( useCommitHashAsVersionName == "true" && jmeGitHash ) {
// The user has opted to use the hash... and we actually have
// a hash.
println "Using commit ID as version"
jmeFullVersion = jmeGitHash;
jmeVersionTag = ""
} else {
println "Auto-detecting version"
jmeVersionTag = "SNAPSHOT"
if( includeBranchInVersion == "true" && jmeBranchName != "master" ) {
jmeFullVersion = baseVersion + "-" + jmeBranchName + "-" + jmeVersionTag;
} else {
jmeFullVersion = baseVersion + "-" + jmeVersionTag;
}
}
} else {
// Just use defaults
println "Using user-defined version"
jmeFullVersion=jmeVersionName
jmeVersionTag = "SNAPSHOT"
} }
println("Revision: ${jmeRevision}") println("Revision: ${jmeRevision}")
println("Hash: ${jmeGitHash}") println("Hash: ${jmeGitHash}")
println("Short Hash: ${jmeShortGitHash}") println("Short Hash: ${jmeShortGitHash}")
@ -61,7 +133,8 @@ task configureVersionInfo {
println("Build Date: ${jmeBuildDate}") println("Build Date: ${jmeBuildDate}")
println("Build Branch: ${jmeBranchName}") println("Build Branch: ${jmeBranchName}")
println("Use commit hash as version ${useCommitHashAsVersionName}") println("Use commit hash as version ${useCommitHashAsVersionName}")
println("Build Tag: ${jmeVersionTag}") println("Base Version: ${baseVersion}")
println("Build Suffix: ${jmeVersionTag}")
println("Build Version: ${jmeFullVersion}") println("Build Version: ${jmeFullVersion}")
} catch (ex) { } catch (ex) {