Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ javadoc_deploy.pub
!.vscode/settings.json
!.vscode/JME_style.xml
!.vscode/extensions.json
joysticks-*.txt
joysticks-*.txt
3 changes: 3 additions & 0 deletions common.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ repositories {
flatDir {
dirs rootProject.file('lib')
}
maven {
url "https://maven.rblb.it/riccardobl/angle-natives"
}
}

dependencies {
Expand Down
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ lwjgl3-openal = { module = "org.lwjgl:lwjgl-openal", version.ref = "lwjgl3"
lwjgl3-opencl = { module = "org.lwjgl:lwjgl-opencl", version.ref = "lwjgl3" }
lwjgl3-opengl = { module = "org.lwjgl:lwjgl-opengl", version.ref = "lwjgl3" }
lwjgl3-sdl = { module = "org.lwjgl:lwjgl-sdl", version.ref = "lwjgl3" }
lwjgl3-opengles = { module = "org.lwjgl:lwjgl-opengles", version.ref = "lwjgl3" }
lwjgl3-egl = { module = "org.lwjgl:lwjgl-egl", version.ref = "lwjgl3" }

mokito-core = "org.mockito:mockito-core:3.12.4"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,14 @@ public interface GLES_30 extends GL {

public static final int GL_RGB10_A2 = 0x8059;
public static final int GL_UNSIGNED_INT_2_10_10_10_REV = 0x8368;

public static final int GL_NUM_EXTENSIONS = 0x821D;

public void glBindVertexArray(int array);

public void glDeleteVertexArrays(IntBuffer arrays);

public void glGenVertexArrays(IntBuffer arrays);

public String glGetString(final int name, final int index);

}
13 changes: 11 additions & 2 deletions jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,15 @@ private HashSet<String> loadExtensions() {
gl3.glGetInteger(GL3.GL_NUM_EXTENSIONS, intBuf16);
int extensionCount = intBuf16.get(0);
for (int i = 0; i < extensionCount; i++) {
String extension = gl3.glGetString(GL.GL_EXTENSIONS, i);
String extension = gl3.glGetString(GL3.GL_EXTENSIONS, i);
extensionSet.add(extension);
}
} else if (caps.contains(Caps.OpenGLES30)) {
GLES_30 gles = (GLES_30) gl;
gles.glGetInteger(GLES_30.GL_NUM_EXTENSIONS, intBuf16);
int extensionCount = intBuf16.get(0);
for (int i = 0; i < extensionCount; i++) {
String extension = gles.glGetString(GLES_30.GL_EXTENSIONS, i);
extensionSet.add(extension);
}
} else {
Expand Down Expand Up @@ -517,7 +525,8 @@ private void loadCapabilitiesCommon() {
limits.put(Limits.FrameBufferSamples, getInteger(GLExt.GL_MAX_SAMPLES_EXT));
}

if (hasExtension("GL_ARB_texture_multisample") || caps.contains(Caps.OpenGLES31)
if (hasExtension("GL_ARB_texture_multisample")
|| hasExtension("GL_EXT_multisampled_render_to_texture") || caps.contains(Caps.OpenGLES31)
|| (JmeSystem.getPlatform().getOs() == Platform.Os.MacOS
&& caps.contains(Caps.OpenGL32))) { // GLES31 does not fully support it
caps.add(Caps.TextureMultisample);
Expand Down
15 changes: 10 additions & 5 deletions jme3-core/src/main/java/com/jme3/system/AppSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public final class AppSettings extends HashMap<String, Object> {
*
* @see AppSettings#setRenderer(java.lang.String)
*/
@Deprecated
public static final String LWJGL_OPENGL2 = "LWJGL-OpenGL2";

/**
Expand Down Expand Up @@ -101,6 +102,7 @@ public final class AppSettings extends HashMap<String, Object> {
*
* @see AppSettings#setRenderer(java.lang.String)
*/
@Deprecated
public static final String LWJGL_OPENGL30 = "LWJGL-OpenGL30";

/**
Expand All @@ -114,6 +116,7 @@ public final class AppSettings extends HashMap<String, Object> {
*
* @see AppSettings#setRenderer(java.lang.String)
*/
@Deprecated
public static final String LWJGL_OPENGL31 = "LWJGL-OpenGL31";

/**
Expand Down Expand Up @@ -219,6 +222,8 @@ public final class AppSettings extends HashMap<String, Object> {
*/
public static final String LWJGL_OPENAL = "LWJGL";

public static final String ANGLE_GLES3 = "ANGLE_GLES3";

/**
* Use the Android MediaPlayer / SoundPool based renderer for Android audio capabilities.
* <p>
Expand Down Expand Up @@ -296,18 +301,18 @@ public final class AppSettings extends HashMap<String, Object> {
static {
defaults.put("Display", 0);
defaults.put("CenterWindow", true);
defaults.put("Width", 640);
defaults.put("Height", 480);
defaults.put("Width", 1440);
defaults.put("Height", 900);
defaults.put("WindowWidth", Integer.MIN_VALUE);
defaults.put("WindowHeight", Integer.MIN_VALUE);
defaults.put("BitsPerPixel", 24);
defaults.put("Frequency", 60);
defaults.put("Frequency", 0);
defaults.put("DepthBits", 24);
defaults.put("StencilBits", 0);
defaults.put("Samples", 0);
defaults.put("Fullscreen", false);
defaults.put("Title", JmeVersion.FULL_NAME);
defaults.put("Renderer", LWJGL_OPENGL32);
defaults.put("Renderer", ANGLE_GLES3);
defaults.put("AudioRenderer", LWJGL_OPENAL);
defaults.put("DisableJoysticks", true);
defaults.put("UseInput", true);
Expand All @@ -317,7 +322,7 @@ public final class AppSettings extends HashMap<String, Object> {
defaults.put("MinHeight", 0);
defaults.put("MinWidth", 0);
defaults.put("GammaCorrection", true);
defaults.put("Resizable", false);
defaults.put("Resizable", true);
defaults.put("SwapBuffers", true);
defaults.put("OpenCL", false);
defaults.put("OpenCLPlatformChooser", DefaultPlatformChooser.class.getName());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#extension GL_ARB_texture_multisample : enable
#extension GL_EXT_multisampled_render_to_texture : enable

Comment on lines +2 to 3
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#extension GL_EXT_multisampled_render_to_texture : enable is emitted unconditionally. On drivers that don't support this extension (common on desktop GL, and some GLES stacks), the shader preprocessor will cause a compile failure even when multisampling isn't used. Consider guarding extension enables (or emitting them only when the extension macro is defined / when compiling for GLES and the extension is required).

Suggested change
#extension GL_EXT_multisampled_render_to_texture : enable
#if defined(GL_ES) && defined(GL_EXT_multisampled_render_to_texture)
#extension GL_EXT_multisampled_render_to_texture : enable
#endif

Copilot uses AI. Check for mistakes.
uniform int m_NumSamples;
uniform int m_NumSamplesDepth;
Expand All @@ -16,7 +17,7 @@ uniform int m_NumSamplesDepth;
#endif

// NOTE: Only define multisample functions if multisample is available
#if defined(GL_ARB_texture_multisample) || (defined GL_ES && __VERSION__>=310)
#if defined(GL_ARB_texture_multisample) || (defined GL_ES && (__VERSION__>=310 || defined(GL_EXT_multisampled_render_to_texture)))
vec4 textureFetch(in sampler2DMS tex,in vec2 texC, in int numSamples){
ivec2 iTexC = ivec2(texC * vec2(textureSize(tex)));
vec4 color = vec4(0.0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ public final class TGALoader implements AssetLoader {
// 11 - run-length encoded, black and white image
public static final int TYPE_BLACKANDWHITE_RLE = 11;

private static void convertBGRtoRGB(byte[] data, int dl){
for (int i = 0; i < data.length; i += dl) {
byte tmp = data[i];
data[i] = data[i + 2];
data[i + 2] = tmp;
}
}

@Override
public Object load(AssetInfo info) throws IOException {
if (!(info.getKey() instanceof TextureKey)) {
Expand Down Expand Up @@ -261,7 +269,8 @@ public static Image load(InputStream in, boolean flip) throws IOException {
// rawData[rawDataIndex++] = blue;
// }
}
format = Format.BGR8;
convertBGRtoRGB(rawData, dl);
format = Format.RGB8;
} else if (pixelDepth == 32) {
for (int i = 0; i <= (height - 1); i++) {
if (!flip) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public JmeContext newContext(AppSettings settings, Type contextType) {
|| contextType == JmeContext.Type.Headless) {
ctx = new NullContext();
ctx.setSettings(settings);
} else if (settings.getRenderer().startsWith("LWJGL")) {
} else if (settings.getRenderer().startsWith("LWJGL") || settings.getRenderer().startsWith("ANGLE")) {
ctx = newContextLwjgl(settings, contextType);
ctx.setSettings(settings);
} else if (settings.getRenderer().startsWith("JOGL")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import java.util.logging.Level;
import java.util.logging.Logger;

import com.jme3.system.NativeLibraries.LibraryInfo;
import com.jme3.util.res.Resources;

/**
Expand Down Expand Up @@ -94,6 +95,16 @@ public static void registerNativeLibrary(NativeLibrary library) {
nativeLibraryMap.put(library.getKey(), library);
}

/**
* Register a new native library.
*
* This simply registers a known library, the actual extraction and loading is performed by calling
* {@link #loadNativeLibrary(java.lang.String, boolean) }.
*/
public static void registerNativeLibrary(LibraryInfo library) {
library.getNativeVariants().forEach(NativeLibraryLoader::registerNativeLibrary);
}

/**
* Register a new native library.
*
Expand Down Expand Up @@ -432,11 +443,15 @@ public static void extractNativeLibrary(Platform platform, String name, File tar
/**
* First extracts the native library and then loads it.
*
* @param name The name of the library to load.
* @param isRequired If true and the library fails to load, throw exception. If
* false, do nothing if it fails to load.
* @param name
* The name of the library to load.
* @param isRequired
* If true and the library fails to load, throw exception. If false, do nothing if it fails to
* load.
*
* @return The absolute path of the loaded library.
*/
public static void loadNativeLibrary(String name, boolean isRequired) {
public static String loadNativeLibrary(String name, boolean isRequired) {
if (JmeSystem.isLowPermissions()) {
throw new UnsupportedOperationException("JVM is running under "
+ "reduced permissions. Cannot load native libraries.");
Expand All @@ -457,15 +472,15 @@ public static void loadNativeLibrary(String name, boolean isRequired) {
" is not available for your OS: {1}",
new Object[]{name, platform});
}
return;
return null;
}
}

final String pathInJar = library.getPathInNativesJar();

if (pathInJar == null) {
// This platform does not require the native library to be loaded.
return;
return null;
}

URL url = Resources.getResource(pathInJar);
Expand All @@ -480,7 +495,7 @@ public static void loadNativeLibrary(String name, boolean isRequired) {
" was not found in the classpath via ''{1}''.",
new Object[]{library.getName(), pathInJar});
}
return;
return null;
}

// The library has been found and is ready to be extracted.
Expand Down Expand Up @@ -530,6 +545,8 @@ public static void loadNativeLibrary(String name, boolean isRequired) {
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, "Loaded native library {0}.", library.getName());
}

return targetFile.getAbsolutePath();
} catch (IOException ex) {
/*if (ex.getMessage().contains("used by another process")) {
return;
Expand Down
29 changes: 27 additions & 2 deletions jme3-desktop/src/main/java/com/jme3/texture/plugins/AWTLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,27 @@ private void flipImage(short[] img, int width, int height, int bpp){
}
}

private static void convertBGRtoRGB(byte[] data){
for (int i = 0; i < data.length; i += 3) {
byte tmp = data[i];
data[i] = data[i + 2];
data[i + 2] = tmp;
}
}

private static void convertABGRtoRGBA(byte[] data){
for (int i = 0; i < data.length; i += 4) {
byte a = data[i];
byte b = data[i + 1];
byte g = data[i + 2];
byte r = data[i + 3];
data[i] = r;
data[i + 1] = g;
data[i + 2] = b;
data[i + 3] = a;
}
}

public Image load(BufferedImage img, boolean flipY){
int width = img.getWidth();
int height = img.getHeight();
Expand All @@ -110,18 +131,22 @@ public Image load(BufferedImage img, boolean flipY){
byte[] dataBuf1 = (byte[]) extractImageData(img);
if (flipY)
flipImage(dataBuf1, width, height, 32);

convertABGRtoRGBA(dataBuf1);

ByteBuffer data1 = BufferUtils.createByteBuffer(img.getWidth()*img.getHeight()*4);
data1.put(dataBuf1);
return new Image(Format.ABGR8, width, height, data1, null, com.jme3.texture.image.ColorSpace.sRGB);
return new Image(Format.RGBA8, width, height, data1, null, com.jme3.texture.image.ColorSpace.sRGB);
case BufferedImage.TYPE_3BYTE_BGR: // most common in JPEG images
byte[] dataBuf2 = (byte[]) extractImageData(img);
if (flipY)
flipImage(dataBuf2, width, height, 24);

convertBGRtoRGB(dataBuf2);

ByteBuffer data2 = BufferUtils.createByteBuffer(img.getWidth()*img.getHeight()*3);
data2.put(dataBuf2);
return new Image(Format.BGR8, width, height, data2, null, com.jme3.texture.image.ColorSpace.sRGB);
return new Image(Format.RGB8, width, height, data2, null, com.jme3.texture.image.ColorSpace.sRGB);
case BufferedImage.TYPE_BYTE_GRAY: // grayscale fonts
byte[] dataBuf3 = (byte[]) extractImageData(img);
if (flipY)
Expand Down
12 changes: 12 additions & 0 deletions jme3-desktop/src/main/java/jme3tools/converters/ImageToAwt.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,16 @@ public DecodeParams(int bpp, int rm, int rs, int im, int is){
private ImageToAwt() {
}

private static Format toGLESFormat(Format format){
if (format == Format.BGR8) {
return Format.RGB8;
}
if (format == Format.BGRA8 || format == Format.ABGR8 || format == Format.ARGB8) {
return Format.RGBA8;
}
return format;
}

private static int Ix(int x, int y, int w){
return y * w + x;
}
Expand Down Expand Up @@ -214,6 +224,8 @@ private static void writePixel(ByteBuffer buf, int idx, int pixel, int bpp){
* @param buf the output buffer (not null, modified)
*/
public static void convert(BufferedImage image, Format format, ByteBuffer buf) {
format = toGLESFormat(format);

DecodeParams p = params.get(format);
if (p == null)
throw new UnsupportedOperationException("Image format " + format + " is not supported");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#extension GL_ARB_texture_multisample : enable
#import "Common/ShaderLib/GLSLCompat.glsllib"
#import "Common/ShaderLib/MultiSample.glsllib"
#import "Common/ShaderLib/Hdr.glsllib"


Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#extension GL_ARB_texture_multisample : enable
#import "Common/ShaderLib/GLSLCompat.glsllib"
#import "Common/ShaderLib/MultiSample.glsllib"

vec3 FilmicCurve(in vec3 x) {
const float A = 0.22;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import com.jme3.math.FastMath;
import com.jme3.scene.Geometry;
import com.jme3.scene.Spatial;
import com.jme3.system.AppSettings;
import com.jme3.util.SkyFactory;
import com.jme3.util.mikktspace.MikktspaceTangentGenerator;

Expand All @@ -49,7 +50,12 @@ public class TestPBRSimple extends SimpleApplication {
private boolean REALTIME_BAKING = false;

public static void main(String[] args) {
new TestPBRSimple().start();
AppSettings settings = new AppSettings(true);


TestPBRSimple app = new TestPBRSimple();
app.setSettings(settings);
app.start();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,17 @@
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Sphere;
import com.jme3.system.AppSettings;
import com.jme3.util.mikktspace.MikktspaceTangentGenerator;

public class TestUnshadedModel extends SimpleApplication {

public static void main(String[] args){
AppSettings settings = new AppSettings(true);
settings.setX11PlatformPreferred(true);
settings.setRenderer(AppSettings.ANGLE_GLES3);
TestUnshadedModel app = new TestUnshadedModel();
app.setSettings(settings);
app.start();
}

Expand Down
Loading
Loading