Skip to content

Commit c899ea5

Browse files
committed
Merge remote-tracking branch 'upstream/master' into allocators
2 parents 2955924 + 1c2822a commit c899ea5

11 files changed

Lines changed: 112 additions & 16 deletions

File tree

jme3-core/src/main/java/com/jme3/app/DetailedProfilerState.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ protected void initialize(Application app) {
108108

109109
ui.attachChild(darkenStats);
110110
ui.setLocalTranslation(app.getCamera().getWidth() - PANEL_WIDTH, app.getCamera().getHeight(), 0);
111-
font = app.getAssetManager().loadFont("Interface/Fonts/Console.fnt");
112-
bigFont = app.getAssetManager().loadFont("Interface/Fonts/Default.fnt");
111+
font = app.getAssetManager().loadFont("Interface/Fonts/Console.j3o");
112+
bigFont = app.getAssetManager().loadFont("Interface/Fonts/Default.j3o");
113113
prof.setRenderer(app.getRenderer());
114114
rootLine = new StatLineView("Frame");
115115
rootLine.attachTo(ui);

jme3-core/src/main/java/com/jme3/app/SimpleApplication.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ public void setShowSettings(boolean showSettings) {
248248
* @return the loaded BitmapFont
249249
*/
250250
protected BitmapFont loadGuiFont() {
251-
return assetManager.loadFont("Interface/Fonts/Default.fnt");
251+
return assetManager.loadFont("Interface/Fonts/Default.j3o");
252252
}
253253

254254
@Override

jme3-core/src/main/java/com/jme3/app/StatsAppState.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public void initialize(AppStateManager stateManager, Application app) {
155155
}
156156

157157
if (guiFont == null) {
158-
guiFont = app.getAssetManager().loadFont("Interface/Fonts/Default.fnt");
158+
guiFont = app.getAssetManager().loadFont("Interface/Fonts/Default.j3o");
159159
}
160160

161161
loadFpsText();

jme3-core/src/main/java/com/jme3/app/StatsView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public StatsView(String name, AssetManager manager, Statistics stats) {
8282
statLabels = statistics.getLabels();
8383
statData = new int[statLabels.length];
8484

85-
BitmapFont font = manager.loadFont("Interface/Fonts/Console.fnt");
85+
BitmapFont font = manager.loadFont("Interface/Fonts/Console.j3o");
8686
statText = new BitmapText(font);
8787
statText.setLocalTranslation(0, statText.getLineHeight() * statLabels.length, 0);
8888
attachChild(statText);

jme3-core/src/main/java/com/jme3/input/virtual/VirtualJoystickTheme.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
*/
4646
public class VirtualJoystickTheme implements Savable {
4747

48-
private static final String DEFAULT_FONT = "Interface/Fonts/Default.fnt";
48+
private static final String DEFAULT_FONT = "Interface/Fonts/Default.j3o";
4949

5050
public enum TextureKey {
5151
BUTTON,

jme3-core/src/main/java/com/jme3/renderer/opengl/GLImageFormats.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,17 @@ public static GLImageFormat[][] getFormatsForCaps(EnumSet<Caps> caps) {
169169
format(formatToGL, Format.RGB565, GL2.GL_RGB8, GL.GL_RGB, GL.GL_UNSIGNED_SHORT_5_6_5, opengl || opengles3 || webgl, false, true);
170170
}
171171

172-
// Additional desktop-specific formats.
172+
// Additional byte-order formats supported directly on desktop GL.
173173
if (opengl) {
174174
format(formatToGL, Format.BGR8, GL2.GL_RGB8, GL2.GL_BGR, GL.GL_UNSIGNED_BYTE, true, false, true);
175175
format(formatToGL, Format.ARGB8, GLExt.GL_RGBA8, GL2.GL_BGRA, GL2.GL_UNSIGNED_INT_8_8_8_8, true, false, true);
176176
format(formatToGL, Format.BGRA8, GLExt.GL_RGBA8, GL2.GL_BGRA, GL.GL_UNSIGNED_BYTE, true, false, true);
177177
format(formatToGL, Format.ABGR8, GLExt.GL_RGBA8, GL.GL_RGBA, GL2.GL_UNSIGNED_INT_8_8_8_8, true, false, true);
178+
} else if (opengles3) {
179+
formatSwiz(formatToGL, Format.BGR8, GL2.GL_RGB8, GL.GL_RGB, GL.GL_UNSIGNED_BYTE, true, false, true);
180+
formatSwiz(formatToGL, Format.ARGB8, GLExt.GL_RGBA8, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, true, false, true);
181+
formatSwiz(formatToGL, Format.BGRA8, GLExt.GL_RGBA8, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, true, false, true);
182+
formatSwiz(formatToGL, Format.ABGR8, GLExt.GL_RGBA8, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, true, false, true);
178183
}
179184

180185
// sRGB formats
@@ -193,6 +198,12 @@ public static GLImageFormat[][] getFormatsForCaps(EnumSet<Caps> caps) {
193198
formatSrgb(formatToGL, Format.ABGR8, GLExt.GL_SRGB8_ALPHA8_EXT, GL.GL_RGBA, GL2.GL_UNSIGNED_INT_8_8_8_8, true, false, true);
194199
formatSrgb(formatToGL, Format.ARGB8, GLExt.GL_SRGB8_ALPHA8_EXT, GL2.GL_BGRA, GL2.GL_UNSIGNED_INT_8_8_8_8, true, false, true);
195200
formatSrgb(formatToGL, Format.BGRA8, GLExt.GL_SRGB8_ALPHA8_EXT, GL2.GL_BGRA, GL.GL_UNSIGNED_BYTE, true, false, true);
201+
} else if (opengles3) {
202+
// Match GLES RGB8/sRGB8 renderability for the same internal format.
203+
formatSrgbSwiz(formatToGL, Format.BGR8, GLExt.GL_SRGB8_EXT, GL.GL_RGB, GL.GL_UNSIGNED_BYTE, false, false, true);
204+
formatSrgbSwiz(formatToGL, Format.ARGB8, GLExt.GL_SRGB8_ALPHA8_EXT, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, true, false, true);
205+
formatSrgbSwiz(formatToGL, Format.BGRA8, GLExt.GL_SRGB8_ALPHA8_EXT, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, true, false, true);
206+
formatSrgbSwiz(formatToGL, Format.ABGR8, GLExt.GL_SRGB8_ALPHA8_EXT, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, true, false, true);
196207
}
197208

198209
if (caps.contains(Caps.TextureCompressionS3TC)) {

jme3-core/src/main/java/com/jme3/renderer/opengl/TextureUtil.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,24 @@ private void setupTextureSwizzle(int target, Format format) {
128128
gl.glTexParameteri(target, GL3.GL_TEXTURE_SWIZZLE_B, GL.GL_RED);
129129
gl.glTexParameteri(target, GL3.GL_TEXTURE_SWIZZLE_A, GL.GL_GREEN);
130130
break;
131+
case BGR8:
132+
gl.glTexParameteri(target, GL3.GL_TEXTURE_SWIZZLE_R, GL.GL_BLUE);
133+
gl.glTexParameteri(target, GL3.GL_TEXTURE_SWIZZLE_G, GL.GL_GREEN);
134+
gl.glTexParameteri(target, GL3.GL_TEXTURE_SWIZZLE_B, GL.GL_RED);
135+
gl.glTexParameteri(target, GL3.GL_TEXTURE_SWIZZLE_A, GL.GL_ONE);
136+
break;
137+
case ARGB8:
138+
gl.glTexParameteri(target, GL3.GL_TEXTURE_SWIZZLE_R, GL.GL_GREEN);
139+
gl.glTexParameteri(target, GL3.GL_TEXTURE_SWIZZLE_G, GL.GL_BLUE);
140+
gl.glTexParameteri(target, GL3.GL_TEXTURE_SWIZZLE_B, GL.GL_ALPHA);
141+
gl.glTexParameteri(target, GL3.GL_TEXTURE_SWIZZLE_A, GL.GL_RED);
142+
break;
143+
case BGRA8:
144+
gl.glTexParameteri(target, GL3.GL_TEXTURE_SWIZZLE_R, GL.GL_BLUE);
145+
gl.glTexParameteri(target, GL3.GL_TEXTURE_SWIZZLE_G, GL.GL_GREEN);
146+
gl.glTexParameteri(target, GL3.GL_TEXTURE_SWIZZLE_B, GL.GL_RED);
147+
gl.glTexParameteri(target, GL3.GL_TEXTURE_SWIZZLE_A, GL.GL_ALPHA);
148+
break;
131149
case ABGR8:
132150
gl.glTexParameteri(target, GL3.GL_TEXTURE_SWIZZLE_R, GL.GL_ALPHA);
133151
gl.glTexParameteri(target, GL3.GL_TEXTURE_SWIZZLE_G, GL.GL_BLUE);
261 KB
Binary file not shown.
266 KB
Binary file not shown.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package com.jme3.asset;
2+
3+
import com.jme3.asset.plugins.ClasspathLocator;
4+
import com.jme3.export.binary.BinaryLoader;
5+
import com.jme3.font.BitmapFont;
6+
import com.jme3.material.plugins.J3MLoader;
7+
import org.junit.jupiter.api.Test;
8+
9+
import static org.junit.jupiter.api.Assertions.assertNotNull;
10+
11+
/**
12+
* Verifies that Default.j3o (with embedded image data) can be loaded using only
13+
* the loaders available in jme3-core, without depending on the PNG loader from
14+
* jme3-plugins. This is needed for Android/iOS which don't depend on jme3-plugins.
15+
*/
16+
public class DefaultFontJ3oTest {
17+
18+
private static DesktopAssetManager createCoreOnlyAssetManager() {
19+
DesktopAssetManager assetManager = new DesktopAssetManager(false);
20+
assetManager.registerLocator("/", ClasspathLocator.class);
21+
assetManager.registerLoader(BinaryLoader.class, "j3o", "j3f");
22+
assetManager.registerLoader(J3MLoader.class, "j3m", "j3md");
23+
return assetManager;
24+
}
25+
26+
private static void assertFontLoaded(DesktopAssetManager assetManager, String path) {
27+
BitmapFont font = assetManager.loadFont(path);
28+
assertNotNull(font, path + " should load without a PNG loader");
29+
assertNotNull(font.getPage(0), path + " should have at least one material page");
30+
assertNotNull(font.getPage(0).getTextureParam("ColorMap"),
31+
path + " material page should have a ColorMap texture");
32+
assertNotNull(font.getPage(0).getTextureParam("ColorMap").getTextureValue().getImage(),
33+
path + " texture should have embedded image data (no key needed)");
34+
}
35+
36+
@Test
37+
public void testDefaultFontJ3oLoadsWithoutPngLoader() {
38+
// This should succeed: Default.j3o has embedded image data (no PNG loader needed)
39+
assertFontLoaded(createCoreOnlyAssetManager(), "Interface/Fonts/Default.j3o");
40+
}
41+
42+
@Test
43+
public void testConsoleFontJ3oLoadsWithoutPngLoader() {
44+
// This should succeed: Console.j3o has embedded image data (no PNG loader needed)
45+
assertFontLoaded(createCoreOnlyAssetManager(), "Interface/Fonts/Console.j3o");
46+
}
47+
}

0 commit comments

Comments
 (0)