Skip to content

Commit

Permalink
Merge branch 'master' into gdxsetup_gradle8
Browse files Browse the repository at this point in the history
  • Loading branch information
obigu committed Nov 3, 2023
2 parents f976179 + 78bbe30 commit e78964b
Show file tree
Hide file tree
Showing 36 changed files with 1,711 additions and 114 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/build-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,35 @@ jobs:

natives-linux:
runs-on: ubuntu-20.04
container:
image: ubuntu:18.04
steps:
- name: Install dependencies into minimal dockerfile
run: |
# ubuntu dockerfile is very minimal (only 122 packages are installed)
# need to install updated git (from official git ppa)
apt update
apt install -y software-properties-common
add-apt-repository ppa:git-core/ppa -y
# install dependencies expected by other steps
apt update
apt install -y git \
curl \
ca-certificates \
wget \
bzip2 \
zip \
unzip \
xz-utils \
maven \
ant sudo locales
# set Locale to en_US.UTF-8 (avoids hang during compilation)
locale-gen en_US.UTF-8
echo "LANG=en_US.UTF-8" >> $GITHUB_ENV
echo "LANGUAGE=en_US.UTF-8" >> $GITHUB_ENV
echo "LC_ALL=en_US.UTF-8" >> $GITHUB_ENV
- uses: actions/checkout@v2
with:
fetch-depth: 0
Expand Down
20 changes: 20 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
[1.12.1]
- LWJGL3 Improvement: Audio device is automatically switched if it was changed in the operating system.
- Tiled Fix: TiledLayer parallax default values fix
- API Addition: TiledDrawable: Align can be set to manipulate the alignment of the rendering (TiledDrawable#setAlign, TiledDrawable#getAlign)
- API Addition: TiledDrawable#draw: Also available as a static function (with align) if you don't want to create an extra instance per texture region
- Android: Removed mouse catching added on 1.12.0 due to unintended effects (see #7187).
- Android: Fixed touch state inconsistency when touching screen with 3 fingers on some devices (see #7256)
- iOS: Update to MobiVM 2.3.20
- API Addition: Using "object" property in Tiled object now fetches MapObject being pointed to, and BaseTmxMapLoader includes method for fetching map where key is id and value is MapObject instance.
- Update to LWJGL 3.3.3
- API Addition: Vector4 is just like Vector2 or Vector3, but with x, y, z, and w float components; a Vector4 can be passed as a shader uniform.
- Fix: Fix crash with ANGLE GLES renderer
- API Change: Use STBVorbis to decode ogg data for Sound
- API Change: Remove usage of deprecated tag on GL30
- Lower GLIBC requirements to 2.17 in order to support older Linux systems
- Fix: Fix setCursor releasing the caught cursor on the LWJGL 3 backend.
- Fix crash in ParticleEditor and Flame
- Fix bitwise precedence in ModelBatch#addMesh (float[] vertices, short[] indices)
- Improve the default font's compatibility with GL30
- Fix potential IndexOutOfBoundsException on AsynchronousAndroidSound
- API Addition: GwtGL20 & GwtGL30#glGetFramebufferAttachmentParameteriv
- Fix Tiled classes not being registered in the reflection cache
- Fix: Change androidx.fragment dependency to compileOnly
- Fix borderless fullscreen when taskbar is on the left/top

[1.12.0]
- [BREAKING CHANGE] Added #touchCancelled to InputProcessor interface, see #6871.
Expand Down Expand Up @@ -70,6 +89,7 @@
- API Fix: MathUtils.lerpAngle() fixed for extreme inputs
- MathUtils trigonometry improvements
- Various Scene2D fixes and improvements
- Fix: JsonValue#addChild now clears leftover list pointers, preventing inconsistent or looping JSON objects.

[1.11.0]
- [BREAKING CHANGE] iOS: Increased min supported iOS version to 9.0. Update your Info.plist file if necessary.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,10 @@ public class AndroidApplicationConfiguration {
/** set this to true to enable Android 4.4 KitKat's 'Immersive mode' **/
public boolean useImmersiveMode = true;

/** Experimental, whether to enable OpenGL ES 3 if supported. If not supported it will fall-back to OpenGL ES 2.0. When GL ES
* 3* is enabled, {@link com.badlogic.gdx.Gdx#gl30} can be used to access its functionality. Requires at least Android 4.3 (API
* level 18).
* @deprecated this option is currently experimental and not yet fully supported, expect issues. */
@Deprecated public boolean useGL30 = false;
/** Whether to enable OpenGL ES 3.0 if supported. If not supported it will fall-back to OpenGL ES 2.0. When GL ES 3* is
* enabled, {@link com.badlogic.gdx.Gdx#gl30} can be used to access its functionality. Requires at least Android 4.3 (API level
* 18). */
public boolean useGL30 = false;

/** The maximum number of threads to use for network requests. Default is {@link Integer#MAX_VALUE}. */
public int maxNetThreads = Integer.MAX_VALUE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import com.badlogic.gdx.Input.Buttons;
import com.badlogic.gdx.backends.android.DefaultAndroidInput.TouchEvent;

import java.util.Arrays;

/** Multitouch handler for devices running Android >= 2.0. If device is capable of (fake) multitouch this will report additional
* pointers.
*
Expand Down Expand Up @@ -82,6 +84,10 @@ public void onTouch (MotionEvent event, DefaultAndroidInput input) {
input.touched[realPointerIndex] = false;
input.button[realPointerIndex] = 0;
input.pressure[realPointerIndex] = 0;
if (action == MotionEvent.ACTION_CANCEL) {
Arrays.fill(input.realId, -1);
Arrays.fill(input.touched, false);
}
break;

case MotionEvent.ACTION_MOVE:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import com.badlogic.gdx.utils.ObjectMap;
import com.badlogic.gdx.utils.SharedLibraryLoader;
import org.lwjgl.system.Configuration;
import org.lwjgl.system.ThreadLocalUtil;

public class Lwjgl3Application implements Lwjgl3ApplicationBase {
private final Lwjgl3ApplicationConfiguration config;
Expand Down Expand Up @@ -562,6 +563,8 @@ static long createGlfwWindow (Lwjgl3ApplicationConfiguration config, long shared
try {
Class gles = Class.forName("org.lwjgl.opengles.GLES");
gles.getMethod("createCapabilities").invoke(gles);
// TODO: Remove once https://github.com/LWJGL/lwjgl3/issues/931 is fixed
ThreadLocalUtil.setFunctionMissingAddresses(0);
} catch (Throwable e) {
throw new GdxRuntimeException("Couldn't initialize GLES", e);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*******************************************************************************
* Copyright 2011 See AUTHORS file.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -16,10 +16,16 @@

package com.badlogic.gdx.backends.lwjgl3.audio;

import java.io.ByteArrayOutputStream;

import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.utils.BufferUtils;
import com.badlogic.gdx.utils.GdxRuntimeException;
import com.badlogic.gdx.utils.StreamUtils;
import org.lwjgl.stb.STBVorbis;
import org.lwjgl.system.MemoryStack;

import java.nio.ByteBuffer;
import java.nio.IntBuffer;
import java.nio.ShortBuffer;

/** @author Nathan Sweet */
public class Ogg {
Expand Down Expand Up @@ -61,19 +67,28 @@ static public class Sound extends OpenALSound {
public Sound (OpenALLwjgl3Audio audio, FileHandle file) {
super(audio);
if (audio.noDevice) return;
OggInputStream input = null;
try {
input = new OggInputStream(file.read());
ByteArrayOutputStream output = new ByteArrayOutputStream(4096);
byte[] buffer = new byte[2048];
while (!input.atEnd()) {
int length = input.read(buffer);
if (length == -1) break;
output.write(buffer, 0, length);

// put the encoded audio data in a ByteBuffer
byte[] streamData = file.readBytes();
ByteBuffer encodedData = BufferUtils.newByteBuffer(streamData.length);
encodedData.put(streamData);
encodedData.flip();

try (MemoryStack stack = MemoryStack.stackPush()) {
final IntBuffer channelsBuffer = stack.mallocInt(1);
final IntBuffer sampleRateBuffer = stack.mallocInt(1);

// decode
final ShortBuffer decodedData = STBVorbis.stb_vorbis_decode_memory(encodedData, channelsBuffer, sampleRateBuffer);
int channels = channelsBuffer.get(0);
int sampleRate = sampleRateBuffer.get(0);
if (decodedData == null) {
throw new GdxRuntimeException("Error decoding OGG file: " + file);
} else if (channels < 1 || channels > 2) {
throw new GdxRuntimeException("Error decoding OGG file, unsupported number of channels: " + file);
}
setup(output.toByteArray(), input.getChannels(), input.getSampleRate());
} finally {
StreamUtils.closeQuietly(input);

setup(decodedData, channels, sampleRate);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@

package com.badlogic.gdx.backends.lwjgl3.audio;

import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.utils.BufferUtils;

import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;

import com.badlogic.gdx.audio.Sound;
import java.nio.ShortBuffer;

import static org.lwjgl.openal.AL10.*;

Expand All @@ -36,20 +37,23 @@ public OpenALSound (OpenALLwjgl3Audio audio) {
}

void setup (byte[] pcm, int channels, int sampleRate) {
int validBytes = pcm.length - (pcm.length % (channels > 1 ? 4 : 2));
ByteBuffer buffer = BufferUtils.newByteBuffer(validBytes);
buffer.put(pcm, 0, validBytes);
((Buffer)buffer).flip();

setup(buffer.asShortBuffer(), channels, sampleRate);
}

void setup (ShortBuffer pcm, int channels, int sampleRate) {
this.channels = channels;
this.sampleRate = sampleRate;
int bytes = pcm.length - (pcm.length % (channels > 1 ? 4 : 2));
int samples = bytes / (2 * channels);
duration = samples / (float)sampleRate;

ByteBuffer buffer = ByteBuffer.allocateDirect(bytes);
buffer.order(ByteOrder.nativeOrder());
buffer.put(pcm, 0, bytes);
((Buffer)buffer).flip();
int sampleFrames = pcm.limit() / channels;
duration = sampleFrames / (float)sampleRate;

if (bufferID == -1) {
bufferID = alGenBuffers();
alBufferData(bufferID, channels > 1 ? AL_FORMAT_STEREO16 : AL_FORMAT_MONO16, buffer.asShortBuffer(), sampleRate);
alBufferData(bufferID, channels > 1 ? AL_FORMAT_STEREO16 : AL_FORMAT_MONO16, pcm, sampleRate);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,9 @@ public class IOSApplicationConfiguration {
/** whether or not the onScreenKeyboard should be closed on return key * */
public boolean keyboardCloseOnReturn = true;

/** Experimental, whether to enable OpenGL ES 3 if supported. If not supported it will fall-back to OpenGL ES 2.0. When GL ES 3
* is enabled, {@link com.badlogic.gdx.Gdx#gl30} can be used to access it's functionality.
* @deprecated this option is currently experimental and not yet fully supported, expect issues. */
@Deprecated public boolean useGL30 = false;
/** Whether to enable OpenGL ES 3 if supported. If not supported it will fall-back to OpenGL ES 2.0. When GL ES 3 is enabled,
* {@link com.badlogic.gdx.Gdx#gl30} can be used to access it's functionality. */
public boolean useGL30 = false;

/** whether the status bar should be visible or not * */
public boolean statusBarVisible = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,9 @@ public class IOSApplicationConfiguration {
/** whether or not the onScreenKeyboard should be closed on return key **/
public boolean keyboardCloseOnReturn = true;

/** Experimental, whether to enable OpenGL ES 3 if supported. If not supported it will fall-back to OpenGL ES 2.0. When GL ES 3
* is enabled, {@link com.badlogic.gdx.Gdx#gl30} can be used to access it's functionality.
* @deprecated this option is currently experimental and not yet fully supported, expect issues. */
@Deprecated public boolean useGL30 = false;
/** Whether to enable OpenGL ES 3 if supported. If not supported it will fall-back to OpenGL ES 2.0. When GL ES 3 is enabled,
* {@link com.badlogic.gdx.Gdx#gl30} can be used to access it's functionality. */
public boolean useGL30 = false;

/** whether the status bar should be visible or not **/
public boolean statusBarVisible = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,9 @@ public class GwtApplicationConfiguration {
public TextArea log;
/** whether to use debugging mode for OpenGL calls. Errors will result in a RuntimeException being thrown. */
public boolean useDebugGL = false;
/** Experimental, whether to enable OpenGL ES 30 (aka WebGL2) if supported. If not supported it will fall-back to OpenGL ES
* 2.0. When GL ES 30 is enabled, {@link com.badlogic.gdx.Gdx#gl30} can be used to access its functionality.
* @deprecated this option is currently experimental and not yet fully supported, expect issues. */
@Deprecated public boolean useGL30 = false;
/** Whether to enable OpenGL ES 3.0 (aka WebGL2) if supported. If not supported it will fall-back to OpenGL ES 2.0. When GL ES
* 3.0 is enabled, {@link com.badlogic.gdx.Gdx#gl30} can be used to access its functionality. */
public boolean useGL30 = false;
/** preserve the back buffer, needed if you fetch a screenshot via canvas#toDataUrl, may have performance impact **/
public boolean preserveDrawingBuffer = false;
/** whether to include an alpha channel in the color buffer to combine the color buffer with the rest of the webpage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class DependencyBank {
static String libgdxVersion = "1.12.0";
// Temporary snapshot version, we need a more dynamic solution for pointing to the latest nightly
static String libgdxNightlyVersion = "1.12.1-SNAPSHOT";
static String roboVMVersion = "2.3.19";
static String roboVMVersion = "2.3.20";
static String buildToolsVersion = "33.0.2";
static String androidAPILevel = "33";
static String androidMinAPILevel = "14";
Expand Down
1 change: 1 addition & 0 deletions gdx/res/com/badlogic/gdx.gwt.xml
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@
<include name="math/Vector.java"/>
<include name="math/Vector2.java"/>
<include name="math/Vector3.java"/>
<include name="math/Vector4.java"/>
<include name="math/WindowedMean.java"/>

<!-- math/collision -->
Expand Down
13 changes: 13 additions & 0 deletions gdx/src/com/badlogic/gdx/graphics/glutils/ShaderProgram.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.badlogic.gdx.math.Matrix4;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.math.Vector4;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.BufferUtils;
import com.badlogic.gdx.utils.Disposable;
Expand Down Expand Up @@ -622,6 +623,18 @@ public void setUniformf (int location, Vector3 values) {
setUniformf(location, values.x, values.y, values.z);
}

/** Sets the uniform with the given name. The {@link ShaderProgram} must be bound for this to work.
*
* @param name the name of the uniform
* @param values x, y, z, and w as the first, second, third, and fourth values respectively */
public void setUniformf (String name, Vector4 values) {
setUniformf(name, values.x, values.y, values.z, values.w);
}

public void setUniformf (int location, Vector4 values) {
setUniformf(location, values.x, values.y, values.z, values.w);
}

/** Sets the uniform with the given name. The {@link ShaderProgram} must be bound for this to work.
*
* @param name the name of the uniform
Expand Down
6 changes: 6 additions & 0 deletions gdx/src/com/badlogic/gdx/input/GestureDetector.java
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,12 @@ public boolean touchUp (float x, float y, int pointer, int button) {
return handled;
}

@Override
public boolean touchCancelled (int screenX, int screenY, int pointer, int button) {
cancel();
return super.touchCancelled(screenX, screenY, pointer, button);
}

/** No further gesture events will be triggered for the current touch, if any. */
public void cancel () {
longPressTask.cancel();
Expand Down
Loading

0 comments on commit e78964b

Please sign in to comment.