Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
mavenCentral()
google()
maven {
url "https://plugins.gradle.org/m2/"
url = "https://plugins.gradle.org/m2/"
}
}
dependencies {
Expand Down Expand Up @@ -121,7 +121,7 @@ task copyLibs(type: Copy){
}

task dist(dependsOn: [':jme3-examples:dist', 'mergedJavadoc']){
description 'Creates a jME3 examples distribution with all jme3 binaries, sources, javadoc and external libraries under ./dist'
description = 'Creates a jME3 examples distribution with all jme3 binaries, sources, javadoc and external libraries under ./dist'
}

def mergedJavadocSubprojects = [
Expand Down Expand Up @@ -242,4 +242,4 @@ if (skipPrebuildLibraries != "true" && buildNativeProjects != "true") {

assemble.dependsOn extractPrebuiltNatives
}
}
}
35 changes: 18 additions & 17 deletions common.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ java {
}

tasks.withType(JavaCompile) { // compile-time options:
//options.compilerArgs << '-Xlint:deprecation' // to show deprecation warnings
options.compilerArgs << '-Xlint:deprecation'
options.compilerArgs << '-Xlint:unchecked'
options.compilerArgs << '-Xlint:-options'
options.encoding = 'UTF-8'
if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_1_10)) {
options.release = 8
Expand Down Expand Up @@ -92,26 +93,26 @@ task javadocJar(type: Jar, dependsOn: javadoc, description: 'Creates a jar from
}

ext.pomConfig = {
name POM_NAME
description POM_DESCRIPTION
url POM_URL
inceptionYear POM_INCEPTION_YEAR
name = POM_NAME
description = POM_DESCRIPTION
url = POM_URL
inceptionYear = POM_INCEPTION_YEAR
scm {
url POM_SCM_URL
connection POM_SCM_CONNECTION
developerConnection POM_SCM_DEVELOPER_CONNECTION
url = POM_SCM_URL
connection = POM_SCM_CONNECTION
developerConnection = POM_SCM_DEVELOPER_CONNECTION
}
licenses {
license {
name POM_LICENSE_NAME
url POM_LICENSE_URL
distribution POM_LICENSE_DISTRIBUTION
name = POM_LICENSE_NAME
url = POM_LICENSE_URL
distribution = POM_LICENSE_DISTRIBUTION
}
}
developers {
developer {
name 'jMonkeyEngine Team'
id 'jMonkeyEngine'
name = 'jMonkeyEngine Team'
id = 'jMonkeyEngine'
}
}
}
Expand Down Expand Up @@ -154,7 +155,7 @@ publishing {
}
url = POM_URL
}
version project.version
version = project.version
}
}

Expand Down Expand Up @@ -209,8 +210,8 @@ tasks.withType(Sign) {
}

checkstyle {
toolVersion libs.versions.checkstyle.get()
configFile file("${gradle.rootProject.rootDir}/config/checkstyle/checkstyle.xml")
toolVersion = libs.versions.checkstyle.get()
configFile = file("${gradle.rootProject.rootDir}/config/checkstyle/checkstyle.xml")
}

checkstyleMain {
Expand All @@ -227,4 +228,4 @@ tasks.withType(Checkstyle) {
html.required.set(true)
}
include("**/com/jme3/renderer/**/*.java")
}
}
11 changes: 7 additions & 4 deletions jme3-android/src/main/java/com/jme3/app/AndroidHarness.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.content.DialogInterface;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.NinePatchDrawable;
import android.graphics.Point;
import android.opengl.GLSurfaceView;
import android.os.Bundle;
import android.util.Log;
Expand Down Expand Up @@ -216,7 +217,9 @@ public void onCreate(Bundle savedInstanceState) {
//TODO try to find a better way to get a hand on the resolution
WindowManager wind = this.getWindowManager();
Display disp = wind.getDefaultDisplay();
Log.d("AndroidHarness", "Resolution from Window, width:" + disp.getWidth() + ", height: " + disp.getHeight());
Point displaySize = new Point();
disp.getSize(displaySize);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The method Display.getSize(Point) was introduced in API level 13. Since jme3-android supports down to API level 9 (as specified in OGLESContext), this change will cause a NoSuchMethodError on devices running Android versions older than 3.2. To maintain compatibility, you should use a version check or continue using the deprecated getWidth() and getHeight() methods for older devices.

Log.d("AndroidHarness", "Resolution from Window, width:" + displaySize.x + ", height: " + displaySize.y);

// Create Settings
logger.log(Level.FINE, "Creating settings");
Expand All @@ -232,7 +235,7 @@ public void onCreate(Bundle savedInstanceState) {
settings.setSamples(eglSamples);
settings.setStencilBits(eglStencilBits);

settings.setResolution(disp.getWidth(), disp.getHeight());
settings.setResolution(displaySize.x, displaySize.y);
settings.setAudioRenderer(audioRendererType);

settings.setFrameRate(frameRate);
Expand Down Expand Up @@ -410,9 +413,9 @@ public void layoutDisplay() {
frameLayout = new FrameLayout(this);
splashImageView = new ImageView(this);

Drawable drawable = this.getResources().getDrawable(splashPicID);
Drawable drawable = splashImageView.getContext().getDrawable(splashPicID);
if (drawable instanceof NinePatchDrawable) {
splashImageView.setBackgroundDrawable(drawable);
splashImageView.setBackground(drawable);
Comment on lines +416 to +418
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

These changes introduce API regressions for older Android devices:

  1. Context.getDrawable(int) (line 416) requires API level 21.
  2. View.setBackground(Drawable) (line 418) requires API level 16.

Since the engine supports API level 9, these calls will crash on older platforms. To fix the deprecation warnings while preserving compatibility, use Build.VERSION.SDK_INT checks to call the appropriate methods based on the platform version.

} else {
splashImageView.setImageResource(splashPicID);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
*
* @author iwgeric
*/
@SuppressWarnings("deprecation")
public class AndroidHarnessFragment extends Fragment implements
TouchListener, DialogInterface.OnClickListener, View.OnLayoutChangeListener, SystemListener {
private static final Logger logger = Logger.getLogger(AndroidHarnessFragment.class.getName());
Expand Down Expand Up @@ -494,9 +495,9 @@ public void createLayout() {
if (splashPicID != 0) {
splashImageView = new ImageView(getActivity());

Drawable drawable = getResources().getDrawable(splashPicID);
Drawable drawable = splashImageView.getContext().getDrawable(splashPicID);
if (drawable instanceof NinePatchDrawable) {
splashImageView.setBackgroundDrawable(drawable);
splashImageView.setBackground(drawable);
} else {
splashImageView.setImageResource(splashPicID);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public void writeImageFile(OutputStream outStream, String format, ByteBuffer ima


@Override
@SuppressWarnings("deprecation")
public JmeContext newContext(AppSettings settings, Type contextType) {
if (settings.getAudioRenderer() == null) {
audioRendererType = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -493,8 +493,8 @@ public void requestDialog(
public void run() {
final FrameLayout layoutTextDialogInput = new FrameLayout(view.getContext());
final EditText editTextDialogInput = new EditText(view.getContext());
editTextDialogInput.setWidth(LayoutParams.FILL_PARENT);
editTextDialogInput.setHeight(LayoutParams.FILL_PARENT);
editTextDialogInput.setWidth(LayoutParams.MATCH_PARENT);
editTextDialogInput.setHeight(LayoutParams.MATCH_PARENT);
editTextDialogInput.setPadding(20, 20, 20, 20);
editTextDialogInput.setGravity(Gravity.FILL_HORIZONTAL);
//editTextDialogInput.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ public ParticleEmitter clone(boolean cloneMaterial) {
* The old clone() method that did not use the new Cloner utility.
*/
@Override
@Deprecated
public ParticleEmitter oldClone(boolean cloneMaterial) {
ParticleEmitter clone = (ParticleEmitter) super.clone(cloneMaterial);
clone.shape = shape.deepClone();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ protected void initialize(Application app) {
viewports[i] = createOffViewPort("EnvView" + i, cameras[i]);
framebuffers[i] = createOffScreenFrameBuffer(size, viewports[i]);
textures[i] = new Texture2D(size, size, imageFormat);
framebuffers[i].setColorTexture(textures[i]);
framebuffers[i].addColorTarget(FrameBuffer.FrameBufferTarget.newTarget(textures[i]));
}
}

Expand Down Expand Up @@ -386,7 +386,7 @@ protected ViewPort createOffViewPort(final String name, final Camera offCamera)
protected FrameBuffer createOffScreenFrameBuffer(int mapSize, ViewPort offView) {
// create offscreen framebuffer
final FrameBuffer offBuffer = new FrameBuffer(mapSize, mapSize, 1);
offBuffer.setDepthBuffer(Image.Format.Depth);
offBuffer.setDepthTarget(FrameBuffer.FrameBufferTarget.newTarget(Image.Format.Depth));
offView.setOutputFrameBuffer(offBuffer);
return offBuffer;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ public static void untagGlobal(Spatial s) {
}

@Override
@Deprecated
public Control cloneForSpatial(Spatial spatial) {
throw new UnsupportedOperationException();
}
Expand Down
6 changes: 3 additions & 3 deletions jme3-core/src/main/java/com/jme3/renderer/Caps.java
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ public static boolean supports(Collection<Caps> caps, FrameBuffer fb) {
return false;
}

RenderBuffer depthBuf = fb.getDepthBuffer();
RenderBuffer depthBuf = fb.getDepthTarget();
if (depthBuf != null) {
Format depthFmt = depthBuf.getFormat();
if (!depthFmt.isDepthFormat()) {
Expand All @@ -567,8 +567,8 @@ public static boolean supports(Collection<Caps> caps, FrameBuffer fb) {
}
}
}
for (int i = 0; i < fb.getNumColorBuffers(); i++) {
if (!supportsColorBuffer(caps, fb.getColorBuffer(i))) {
for (int i = 0; i < fb.getNumColorTargets(); i++) {
if (!supportsColorBuffer(caps, fb.getColorTarget(i))) {
return false;
}
}
Expand Down
11 changes: 8 additions & 3 deletions jme3-core/src/main/java/com/jme3/renderer/RenderContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@
* internally to reduce state changes. NOTE: This class is specific to OpenGL.
*/
public class RenderContext {
private static <T> WeakReference<T>[] newWeakReferenceArray(int size) {
WeakReference<T>[] refs = (WeakReference<T>[]) new WeakReference<?>[size];
return refs;
}
Comment on lines +48 to +51
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The cast to WeakReference<T>[] on line 49 is unchecked and will generate a compiler warning. Since the purpose of this PR is to reduce warning noise, this helper method should be annotated with @SuppressWarnings("unchecked").

Suggested change
private static <T> WeakReference<T>[] newWeakReferenceArray(int size) {
WeakReference<T>[] refs = (WeakReference<T>[]) new WeakReference<?>[size];
return refs;
}
@SuppressWarnings("unchecked")
private static <T> WeakReference<T>[] newWeakReferenceArray(int size) {
return (WeakReference<T>[]) new WeakReference<?>[size];
}


/**
* Number of texture units that JME supports.
*/
Expand Down Expand Up @@ -260,7 +265,7 @@ public class RenderContext {
* @see Renderer#setTexture(int, com.jme3.texture.Texture)
*/
public final WeakReference<Image> boundTextures[]
= new WeakReference[maxTextureUnits];
= newWeakReferenceArray(maxTextureUnits);


/**
Expand All @@ -269,7 +274,7 @@ public class RenderContext {
* @see Renderer#setUniformBufferObject(int, com.jme3.shader.BufferObject)
* @see Renderer#setShaderStorageBufferObject(int, com.jme3.shader.BufferObject)
*/
public final WeakReference<BufferObject>[] boundBO = new WeakReference[maxBufferObjectUnits];
public final WeakReference<BufferObject>[] boundBO = newWeakReferenceArray(maxBufferObjectUnits);

/**
* IDList for texture units.
Expand Down Expand Up @@ -326,7 +331,7 @@ public class RenderContext {
* Vertex attribs currently bound and enabled. If a slot is null, then
* it is disabled.
*/
public final WeakReference<VertexBuffer>[] boundAttribs = new WeakReference[16];
public final WeakReference<VertexBuffer>[] boundAttribs = newWeakReferenceArray(16);

/**
* IDList for vertex attributes.
Expand Down
31 changes: 17 additions & 14 deletions jme3-core/src/main/java/com/jme3/renderer/RenderManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public class RenderManager {
private final HashMap<Class<? extends PipelineContext>, PipelineContext> contexts = new HashMap<>();
private final LinkedList<PipelineContext> usedContexts = new LinkedList<>();
private final LinkedList<RenderPipeline<? extends PipelineContext>> usedPipelines = new LinkedList<>();
private RenderPipeline<? extends PipelineContext> defaultPipeline = new ForwardPipeline();
private RenderPipeline<? extends PipelineContext> defaultPipeline = new ForwardPipeline();
private Camera prevCam = null;
private Material forcedMaterial = null;
private String forcedTechnique = null;
Expand Down Expand Up @@ -1382,19 +1382,22 @@ public void applyViewPort(ViewPort vp) {
* @param vp View port to render
* @param tpf Time per frame value
*/
public void renderViewPort(ViewPort vp, float tpf) {
if (!vp.isEnabled()) {
return;
}
RenderPipeline pipeline = vp.getPipeline();
if (pipeline == null) {
pipeline = defaultPipeline;
}

PipelineContext context = pipeline.fetchPipelineContext(this);
if (context == null) {
throw new NullPointerException("Failed to fetch pipeline context.");
}
public void renderViewPort(ViewPort vp, float tpf) {
if (!vp.isEnabled()) {
return;
}
RenderPipeline<? extends PipelineContext> pipeline = vp.getPipeline();
if (pipeline == null) {
pipeline = defaultPipeline;
}
renderViewPort(vp, tpf, pipeline);
}

private <T extends PipelineContext> void renderViewPort(ViewPort vp, float tpf, RenderPipeline<T> pipeline) {
T context = pipeline.fetchPipelineContext(this);
if (context == null) {
throw new NullPointerException("Failed to fetch pipeline context.");
}
if (!context.startViewPortRender(this, vp)) {
usedContexts.add(context);
}
Expand Down
7 changes: 4 additions & 3 deletions jme3-core/src/main/java/com/jme3/renderer/ViewPort.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
package com.jme3.renderer;

import com.jme3.renderer.pipeline.RenderPipeline;
import com.jme3.renderer.pipeline.PipelineContext;
import com.jme3.math.ColorRGBA;
import com.jme3.post.SceneProcessor;
import com.jme3.renderer.queue.RenderQueue;
Expand Down Expand Up @@ -88,7 +89,7 @@ public class ViewPort {
/**
* Dedicated pipeline.
*/
protected RenderPipeline pipeline;
protected RenderPipeline<? extends PipelineContext> pipeline;
/**
* FrameBuffer for output.
*/
Expand Down Expand Up @@ -440,7 +441,7 @@ public boolean isEnabled() {
*
* @param pipeline pipeline, or null to use render manager's pipeline
*/
public void setPipeline(RenderPipeline pipeline) {
public void setPipeline(RenderPipeline<? extends PipelineContext> pipeline) {
this.pipeline = pipeline;
}

Expand All @@ -449,7 +450,7 @@ public void setPipeline(RenderPipeline pipeline) {
*
* @return
*/
public RenderPipeline getPipeline() {
public RenderPipeline<? extends PipelineContext> getPipeline() {
return pipeline;
}

Expand Down
Loading
Loading