Skip to content

Commit 8ab3d24

Browse files
riccardoblstephengold
authored andcommitted
Add toggleable fb mipmaps generation
1 parent 5656fe4 commit 8ab3d24

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ public final class GLRenderer implements Renderer {
100100
private int defaultAnisotropicFilter = 1;
101101
private boolean linearizeSrgbImages;
102102
private HashSet<String> extensions;
103+
private boolean generateMipmapsForFramebuffers = true;
103104

104105
private final GL gl;
105106
private final GL2 gl2;
@@ -118,13 +119,21 @@ public GLRenderer(GL gl, GLExt glext, GLFbo glfbo) {
118119
this.glext = glext;
119120
this.texUtil = new TextureUtil(gl, gl2, glext);
120121
}
122+
123+
/**
124+
* Enable/Disable default automatic generation of mipmaps for framebuffers
125+
* @param v Default is true
126+
*/
127+
public void setGenerateMipmapsForFrameBuffer(boolean v) {
128+
generateMipmapsForFramebuffers = v;
129+
}
121130

122131
@Override
123132
public Statistics getStatistics() {
124133
return statistics;
125134
}
126135

127-
@Override
136+
@Override
128137
public EnumSet<Caps> getCaps() {
129138
return caps;
130139
}
@@ -2075,7 +2084,7 @@ public void setFrameBuffer(FrameBuffer fb) {
20752084
}
20762085

20772086
// generate mipmaps for last FB if needed
2078-
if (context.boundFB != null) {
2087+
if (context.boundFB != null && (context.boundFB.getMipMapsGenerationHint()!=null?context.boundFB.getMipMapsGenerationHint():generateMipmapsForFramebuffers)) {
20792088
for (int i = 0; i < context.boundFB.getNumColorBuffers(); i++) {
20802089
RenderBuffer rb = context.boundFB.getColorBuffer(i);
20812090
Texture tex = rb.getTexture();

jme3-core/src/main/java/com/jme3/texture/FrameBuffer.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ public class FrameBuffer extends NativeObject {
8484
private RenderBuffer depthBuf = null;
8585
private int colorBufIndex = 0;
8686
private boolean srgb;
87+
private Boolean mipsGenerationHint = null;
8788

8889
/**
8990
* <code>RenderBuffer</code> represents either a texture or a
@@ -842,4 +843,17 @@ public void setSrgb(boolean srgb) {
842843
public boolean isSrgb() {
843844
return srgb;
844845
}
846+
847+
848+
/**
849+
* Hints the renderer to generate mipmaps for this framebuffer if necessary
850+
* @param v true to enable, null to use the default value for the renderer (default to null)
851+
*/
852+
public void setMipMapsGenerationHint(Boolean v) {
853+
mipsGenerationHint = v;
854+
}
855+
856+
public Boolean getMipMapsGenerationHint() {
857+
return mipsGenerationHint;
858+
}
845859
}

0 commit comments

Comments
 (0)