Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
91a49ec
This is a very simple addition. It allows a person to set 3 variables…
bob0bob Nov 22, 2021
7bcba98
Merge branch 'master' of https://github.com/bob0bob/jmonkeyengine
bob0bob Nov 22, 2021
ce24716
formatting and comments changes.
bob0bob Nov 24, 2021
aef358f
jme3test.app.TestApplication hangs with LWJGL3 #1193
bob0bob Nov 24, 2021
1b0507e
Merge branch 'jMonkeyEngine:master' into master
bob0bob Nov 25, 2021
f0489b8
removing unwanted changes, since you can't do multiple pull requests …
bob0bob Nov 25, 2021
e5f608d
Merge branch 'master' of https://github.com/bob0bob/jmonkeyengine int…
bob0bob Nov 25, 2021
a5b0e37
formatting issues.
bob0bob Nov 25, 2021
26937ca
changed parameter naming to be more consistency with other items.
bob0bob Nov 25, 2021
3832d37
jme3test.app.TestApplication hangs with LWJGL3 #1193
bob0bob Nov 25, 2021
811493c
jme3test.app.TestApplication hangs with LWJGL3 #1193 (#3)
bob0bob Nov 25, 2021
db0d9ff
removing unwanted changes.
bob0bob Nov 25, 2021
5eb2690
AppSettings: enhance the new javadoc
stephengold Nov 30, 2021
72d008d
AppSettings: capitalize Window{X/Y}Position consistent w/other settings
stephengold Nov 30, 2021
f7c5ec7
LwjglWindow: convert tabs to spaces
stephengold Nov 30, 2021
4544d64
AppSettings: re-arrange @see tags in javadoc
stephengold Nov 30, 2021
0d28d62
Merge branch 'jMonkeyEngine:master' into master
bob0bob Dec 1, 2021
f600f23
Merge branch 'jMonkeyEngine:master' into master
bob0bob Dec 3, 2021
ef6d02e
using deprecated FrameBuffer methods in jme3-core and jme3-desktop #…
bob0bob Dec 3, 2021
a3dd6b7
Removing unused imports.
bob0bob Dec 4, 2021
5889962
missed an unused import.
bob0bob Dec 4, 2021
735c249
FrameBuffer: improve formatting of the added sourcecode
stephengold Dec 9, 2021
c6ebe24
tweak the whitespace
stephengold Dec 9, 2021
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
11 changes: 6 additions & 5 deletions jme3-core/src/main/java/com/jme3/post/Filter.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import com.jme3.texture.Image.Format;
import com.jme3.texture.Texture;
import com.jme3.texture.Texture2D;
import com.jme3.texture.FrameBuffer.FrameBufferTarget;
import java.io.IOException;
import java.util.Collection;
import java.util.Iterator;
Expand Down Expand Up @@ -110,22 +111,22 @@ public void init(Renderer renderer, int width, int height, Format textureFormat,
if (numSamples > 1 && caps.contains(Caps.FrameBufferMultisample) && caps.contains(Caps.OpenGL31)) {
renderFrameBuffer = new FrameBuffer(width, height, numSamples);
renderedTexture = new Texture2D(width, height, numSamples, textureFormat);
renderFrameBuffer.setDepthBuffer(depthBufferFormat);
renderFrameBuffer.setDepthTarget(FrameBufferTarget.newTarget(depthBufferFormat));
if (renderDepth) {
depthTexture = new Texture2D(width, height, numSamples, depthBufferFormat);
renderFrameBuffer.setDepthTexture(depthTexture);
renderFrameBuffer.setDepthTarget(FrameBufferTarget.newTarget(depthTexture));
}
} else {
renderFrameBuffer = new FrameBuffer(width, height, 1);
renderedTexture = new Texture2D(width, height, textureFormat);
renderFrameBuffer.setDepthBuffer(depthBufferFormat);
renderFrameBuffer.setDepthTarget(FrameBufferTarget.newTarget(depthBufferFormat));
if (renderDepth) {
depthTexture = new Texture2D(width, height, depthBufferFormat);
renderFrameBuffer.setDepthTexture(depthTexture);
renderFrameBuffer.setDepthTarget(FrameBufferTarget.newTarget(depthTexture));
}
}

renderFrameBuffer.setColorTexture(renderedTexture);
renderFrameBuffer.addColorTarget(FrameBufferTarget.newTarget(renderedTexture));


}
Expand Down
15 changes: 8 additions & 7 deletions jme3-core/src/main/java/com/jme3/post/FilterPostProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import com.jme3.texture.Image.Format;
import com.jme3.texture.Texture;
import com.jme3.texture.Texture2D;
import com.jme3.texture.FrameBuffer.FrameBufferTarget;
import com.jme3.ui.Picture;
import com.jme3.util.SafeArrayList;
import java.io.IOException;
Expand Down Expand Up @@ -182,7 +183,7 @@ private void initFilter(Filter filter, ViewPort vp) {
if (filter.isRequiresDepthTexture()) {
if (!computeDepth && renderFrameBuffer != null) {
depthTexture = new Texture2D(width, height, depthFormat);
renderFrameBuffer.setDepthTexture(depthTexture);
renderFrameBuffer.setDepthTarget(FrameBufferTarget.newTarget(depthTexture));
}
computeDepth = true;
filter.init(assetManager, renderManager, vp, width, height);
Expand Down Expand Up @@ -488,21 +489,21 @@ public void reshape(ViewPort vp, int w, int h) {
if (caps.contains(Caps.OpenGL32)) {
Texture2D msColor = new Texture2D(width, height, numSamples, fbFormat);
Texture2D msDepth = new Texture2D(width, height, numSamples, depthFormat);
renderFrameBufferMS.setDepthTexture(msDepth);
renderFrameBufferMS.setColorTexture(msColor);
renderFrameBufferMS.setDepthTarget(FrameBufferTarget.newTarget(msDepth));
renderFrameBufferMS.addColorTarget(FrameBufferTarget.newTarget(msColor));
filterTexture = msColor;
depthTexture = msDepth;
} else {
renderFrameBufferMS.setDepthBuffer(depthFormat);
renderFrameBufferMS.setColorBuffer(fbFormat);
renderFrameBufferMS.setDepthTarget(FrameBufferTarget.newTarget(depthFormat));
renderFrameBufferMS.addColorTarget(FrameBufferTarget.newTarget(fbFormat));
}
}

if (numSamples <= 1 || !caps.contains(Caps.OpenGL32)) {
renderFrameBuffer = new FrameBuffer(width, height, 1);
renderFrameBuffer.setDepthBuffer(depthFormat);
renderFrameBuffer.setDepthTarget(FrameBufferTarget.newTarget(depthFormat));
filterTexture = new Texture2D(width, height, fbFormat);
renderFrameBuffer.setColorTexture(filterTexture);
renderFrameBuffer.addColorTarget(FrameBufferTarget.newTarget(filterTexture));
}

for (Filter filter : filters.getArray()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
import com.jme3.texture.Texture.MinFilter;
import com.jme3.texture.Texture.ShadowCompareMode;
import com.jme3.texture.Texture2D;
import com.jme3.texture.FrameBuffer.FrameBufferTarget;
import com.jme3.ui.Picture;
import com.jme3.util.clone.Cloner;
import com.jme3.util.clone.JmeCloneable;
Expand Down Expand Up @@ -170,10 +171,10 @@ private void init(AssetManager assetManager, int nbShadowMaps, int shadowMapSize
shadowFB[i] = new FrameBuffer(shadowMapSize, shadowMapSize, 1);
shadowMaps[i] = new Texture2D(shadowMapSize, shadowMapSize, Format.Depth);

shadowFB[i].setDepthTexture(shadowMaps[i]);
shadowFB[i].setDepthTarget(FrameBufferTarget.newTarget(shadowMaps[i]));

//DO NOT COMMENT THIS (it prevent the OSX incomplete read buffer crash)
shadowFB[i].setColorTexture(dummyTex);
shadowFB[i].addColorTarget(FrameBufferTarget.newTarget(dummyTex));
shadowMapStringCache[i] = "ShadowMap" + i;
lightViewStringCache[i] = "LightViewProjectionMatrix" + i;

Expand Down
29 changes: 29 additions & 0 deletions jme3-core/src/main/java/com/jme3/texture/FrameBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,21 @@ public static FrameBufferBufferTarget newTarget(Format format){
t.setFormat(format);
return t;
}

/**
* Creates a frame buffer texture and sets the face position by using the face parameter. It uses
* {@link TextureCubeMap} ordinal number for the face position.
*
* @param tx texture to add to the frame buffer
* @param face face to add to the color buffer to
* @return FrameBufferTexture Target
*/
public static FrameBufferTextureTarget newTarget(Texture tx, TextureCubeMap.Face face) {
FrameBufferTextureTarget t = new FrameBufferTextureTarget();
t.face = face.ordinal();
t.setTexture(tx);
return t;
}
}

/**
Expand All @@ -250,6 +265,20 @@ public void addColorTarget(FrameBufferTextureTarget colorBuf){
colorBufs.add(colorBuf);
}

/**
* Adds a texture to one of the color Buffers Array. It uses {@link TextureCubeMap} ordinal number for the
* position in the color buffer ArrayList.
*
* @param colorBuf texture to add to the color Buffer
* @param face position to add to the color buffer
*/
public void addColorTarget(FrameBufferTextureTarget colorBuf, TextureCubeMap.Face face) {
// checkSetTexture(colorBuf.getTexture(), false); // TODO: this won't work for levels.
colorBuf.slot = colorBufs.size();
colorBuf.face = face.ordinal();
colorBufs.add(colorBuf);
}

public void setDepthTarget(FrameBufferBufferTarget depthBuf){
if (!depthBuf.getFormat().isDepthFormat())
throw new IllegalArgumentException("Depth buffer format must be depth.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import com.jme3.scene.Spatial;
import com.jme3.scene.shape.Quad;
import com.jme3.texture.*;
import com.jme3.texture.FrameBuffer.FrameBufferTarget;
import com.jme3.texture.Image.Format;
import com.jme3.texture.Texture.WrapMode;
import com.jme3.ui.Picture;
Expand Down Expand Up @@ -282,8 +283,8 @@ protected void createPreViews() {
// create offscreen framebuffer
reflectionBuffer = new FrameBuffer(renderWidth, renderHeight, 1);
//setup framebuffer to use texture
reflectionBuffer.setDepthBuffer(Format.Depth);
reflectionBuffer.setColorTexture(reflectionTexture);
reflectionBuffer.setDepthTarget(FrameBufferTarget.newTarget(Format.Depth));
reflectionBuffer.addColorTarget(FrameBufferTarget.newTarget(reflectionTexture));

//set viewport to render to offscreen framebuffer
reflectionView.setOutputFrameBuffer(reflectionBuffer);
Expand All @@ -298,9 +299,8 @@ protected void createPreViews() {
// create offscreen framebuffer
refractionBuffer = new FrameBuffer(renderWidth, renderHeight, 1);
//setup framebuffer to use texture
refractionBuffer.setDepthBuffer(Format.Depth);
refractionBuffer.setColorTexture(refractionTexture);
refractionBuffer.setDepthTexture(depthTexture);
refractionBuffer.addColorTarget(FrameBufferTarget.newTarget(refractionTexture));
refractionBuffer.setDepthTarget(FrameBufferTarget.newTarget(depthTexture));
//set viewport to render to offscreen framebuffer
refractionView.setOutputFrameBuffer(refractionBuffer);
refractionView.addProcessor(new RefractionProcessor());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import com.jme3.texture.Texture.MagFilter;
import com.jme3.texture.Texture.MinFilter;
import com.jme3.texture.Texture2D;
import com.jme3.texture.FrameBuffer.FrameBufferTarget;
import de.lessvoid.nifty.Nifty;

public class TestNiftyToMesh extends SimpleApplication{
Expand All @@ -67,13 +68,13 @@ public void simpleInitApp() {

Texture2D depthTex = new Texture2D(1024, 768, Format.Depth);
FrameBuffer fb = new FrameBuffer(1024, 768, 1);
fb.setDepthTexture(depthTex);
fb.setDepthTarget(FrameBufferTarget.newTarget(depthTex));

Texture2D tex = new Texture2D(1024, 768, Format.RGBA8);
tex.setMinFilter(MinFilter.Trilinear);
tex.setMagFilter(MagFilter.Bilinear);

fb.setColorTexture(tex);
fb.addColorTarget(FrameBufferTarget.newTarget(tex));
niftyView.setClearFlags(true, true, true);
niftyView.setOutputFrameBuffer(fb);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import com.jme3.texture.FrameBuffer;
import com.jme3.texture.Image.Format;
import com.jme3.texture.Texture2D;
import com.jme3.texture.FrameBuffer.FrameBufferTarget;
import com.jme3.ui.Picture;

/**
Expand Down Expand Up @@ -70,8 +71,8 @@ public void simpleInitApp() {
fb = new FrameBuffer(w, h, 1);

Texture2D fbTex = new Texture2D(w, h, Format.RGBA8);
fb.setDepthBuffer(Format.Depth);
fb.setColorTexture(fbTex);
fb.setDepthTarget(FrameBufferTarget.newTarget(Format.Depth));
fb.addColorTarget(FrameBufferTarget.newTarget(fbTex));

// setup framebuffer's scene
Sphere sphMesh = new Sphere(20, 20, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
import com.jme3.texture.FrameBuffer;
import com.jme3.texture.Image;
import com.jme3.texture.Texture2D;
import com.jme3.texture.FrameBuffer.FrameBufferTarget;
import com.jme3.texture.Image.Format;
import com.jme3.util.SkyFactory;

/**
Expand Down Expand Up @@ -78,8 +80,9 @@ public void simpleInitApp() {
//creating a frame buffer for the mainviewport
FrameBuffer mainVPFrameBuffer = new FrameBuffer(cam.getWidth(), cam.getHeight(), 1);
Texture2D mainVPTexture = new Texture2D(cam.getWidth(), cam.getHeight(), Image.Format.RGBA8);
mainVPFrameBuffer.addColorTexture(mainVPTexture);
mainVPFrameBuffer.setDepthBuffer(Image.Format.Depth);
mainVPFrameBuffer.setDepthTarget(FrameBufferTarget.newTarget(Format.Depth));
mainVPFrameBuffer.addColorTarget(FrameBufferTarget.newTarget(mainVPTexture));

viewPort.setOutputFrameBuffer(mainVPFrameBuffer);

//creating the post processor for the gui viewport
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import com.jme3.texture.Image.Format;
import com.jme3.texture.Texture;
import com.jme3.texture.TextureCubeMap;
import com.jme3.texture.FrameBuffer.FrameBufferTarget;
import com.jme3.util.SkyFactory;
import com.jme3.util.SkyFactory.EnvMapType;

Expand Down Expand Up @@ -86,15 +87,15 @@ public Texture setupOffscreenView(){
offTex.setMagFilter(Texture.MagFilter.Bilinear);

//setup framebuffer to use texture
offBuffer.setDepthBuffer(Format.Depth);
offBuffer.setDepthTarget(FrameBufferTarget.newTarget(Format.Depth));
offBuffer.setMultiTarget(true);
offBuffer.addColorTexture(offTex, TextureCubeMap.Face.NegativeX);
offBuffer.addColorTexture(offTex, TextureCubeMap.Face.PositiveX);
offBuffer.addColorTexture(offTex, TextureCubeMap.Face.NegativeY);
offBuffer.addColorTexture(offTex, TextureCubeMap.Face.PositiveY);
offBuffer.addColorTexture(offTex, TextureCubeMap.Face.NegativeZ);
offBuffer.addColorTexture(offTex, TextureCubeMap.Face.PositiveZ);
offBuffer.addColorTarget(FrameBufferTarget.newTarget(offTex, TextureCubeMap.Face.NegativeX));
offBuffer.addColorTarget(FrameBufferTarget.newTarget(offTex, TextureCubeMap.Face.PositiveX));
offBuffer.addColorTarget(FrameBufferTarget.newTarget(offTex, TextureCubeMap.Face.NegativeY));
offBuffer.addColorTarget(FrameBufferTarget.newTarget(offTex, TextureCubeMap.Face.PositiveY));
offBuffer.addColorTarget(FrameBufferTarget.newTarget(offTex, TextureCubeMap.Face.NegativeZ));
offBuffer.addColorTarget(FrameBufferTarget.newTarget(offTex, TextureCubeMap.Face.PositiveZ));

//set viewport to render to offscreen framebuffer
offView.setOutputFrameBuffer(offBuffer);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import com.jme3.system.AppSettings;
import com.jme3.system.JmeContext.Type;
import com.jme3.texture.FrameBuffer;
import com.jme3.texture.FrameBuffer.FrameBufferTarget;
import com.jme3.texture.Image.Format;
import com.jme3.util.BufferUtils;
import com.jme3.util.Screenshots;
Expand Down Expand Up @@ -192,9 +193,8 @@ public void setupOffscreenView(){

//setup framebuffer to use renderbuffer
// this is faster for gpu -> cpu copies
offBuffer.setDepthBuffer(Format.Depth);
offBuffer.setColorBuffer(Format.RGBA8);
// offBuffer.setColorTexture(offTex);
offBuffer.setDepthTarget(FrameBufferTarget.newTarget(Format.Depth));
offBuffer.addColorTarget(FrameBufferTarget.newTarget(Format.RGBA8));

//set viewport to render to offscreen framebuffer
offView.setOutputFrameBuffer(offBuffer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import com.jme3.texture.Image.Format;
import com.jme3.texture.Texture;
import com.jme3.texture.Texture2D;
import com.jme3.texture.FrameBuffer.FrameBufferTarget;

/**
* This test renders a scene to a texture, then displays the texture on a cube.
Expand Down Expand Up @@ -86,9 +87,9 @@ public Texture setupOffscreenView(){
offTex.setMagFilter(Texture.MagFilter.Bilinear);

//setup framebuffer to use texture
offBuffer.setDepthBuffer(Format.Depth);
offBuffer.setColorTexture(offTex);
offBuffer.setDepthTarget(FrameBufferTarget.newTarget(Format.Depth));
offBuffer.addColorTarget(FrameBufferTarget.newTarget(offTex));

//set viewport to render to offscreen framebuffer
offView.setOutputFrameBuffer(offBuffer);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import com.jme3.texture.FrameBuffer;
import com.jme3.texture.Image.Format;
import com.jme3.texture.Texture2D;
import com.jme3.texture.FrameBuffer.FrameBufferTarget;
import com.jme3.ui.Picture;

public class TestDepthStencil extends SimpleApplication {
Expand All @@ -71,8 +72,8 @@ public void simpleInitApp() {
fb = new FrameBuffer(w, h, 1);

Texture2D fbTex = new Texture2D(w, h, Format.RGB8);
fb.setDepthBuffer(Format.Depth24Stencil8);
fb.setColorTexture(fbTex);
fb.setDepthTarget(FrameBufferTarget.newTarget(Format.Depth24Stencil8));
fb.addColorTarget(FrameBufferTarget.newTarget(fbTex));

// setup framebuffer's scene
Sphere sphMesh = new Sphere(20, 20, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.ViewPort;
import com.jme3.renderer.queue.RenderQueue;
import com.jme3.shadow.CompareMode;
import com.jme3.shadow.EdgeFilteringMode;
import com.jme3.texture.FrameBuffer;

import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import com.jme3.texture.Texture.MinFilter;
import com.jme3.texture.Texture.ShadowCompareMode;
import com.jme3.texture.Texture2D;
import com.jme3.texture.FrameBuffer.FrameBufferTarget;
import com.jme3.ui.Picture;

import java.io.IOException;
Expand Down Expand Up @@ -169,10 +170,10 @@ private void init(AssetManager assetManager, int nbShadowMaps, int shadowMapSize
shadowFB[i] = new FrameBuffer(shadowMapSize, shadowMapSize, 1);
shadowMaps[i] = new Texture2D(shadowMapSize, shadowMapSize, Format.Depth);

shadowFB[i].setDepthTexture(shadowMaps[i]);
shadowFB[i].setDepthTarget(FrameBufferTarget.newTarget(shadowMaps[i]));

//DO NOT COMMENT THIS (It prevents the OSX incomplete read buffer crash.)
shadowFB[i].setColorTexture(dummyTex);
shadowFB[i].addColorTarget(FrameBufferTarget.newTarget(dummyTex));
shadowMapStringCache[i] = "ShadowMap" + i;
lightViewStringCache[i] = "LightViewProjectionMatrix" + i;

Expand Down