Fixes some problems with framebuffers
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9932 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
7271bf4de7
commit
0263c78d55
@ -1560,11 +1560,34 @@ public class JoglRenderer implements Renderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setFrameBuffer(FrameBuffer fb) {
|
public void setFrameBuffer(FrameBuffer fb) {
|
||||||
|
if (fb == null && mainFbOverride != null) {
|
||||||
|
fb = mainFbOverride;
|
||||||
|
}
|
||||||
|
|
||||||
if (lastFb == fb) {
|
if (lastFb == fb) {
|
||||||
|
if (fb == null || !fb.isUpdateNeeded()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
GL gl = GLContext.getCurrentGL();
|
GL gl = GLContext.getCurrentGL();
|
||||||
|
// generate mipmaps for last FB if needed
|
||||||
|
if (lastFb != null) {
|
||||||
|
for (int i = 0; i < lastFb.getNumColorBuffers(); i++) {
|
||||||
|
RenderBuffer rb = lastFb.getColorBuffer(i);
|
||||||
|
Texture tex = rb.getTexture();
|
||||||
|
if (tex != null
|
||||||
|
&& tex.getMinFilter().usesMipMapLevels()) {
|
||||||
|
setTexture(0, rb.getTexture());
|
||||||
|
|
||||||
|
int textureType = convertTextureType(tex.getType(), tex.getImage().getMultiSamples(), rb.getFace());
|
||||||
|
gl.glEnable(textureType);
|
||||||
|
gl.glGenerateMipmap(textureType);
|
||||||
|
gl.glDisable(textureType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (fb == null) {
|
if (fb == null) {
|
||||||
// unbind any fbos
|
// unbind any fbos
|
||||||
if (context.boundFBO != 0) {
|
if (context.boundFBO != 0) {
|
||||||
@ -1585,6 +1608,11 @@ public class JoglRenderer implements Renderer {
|
|||||||
|
|
||||||
lastFb = null;
|
lastFb = null;
|
||||||
} else {
|
} else {
|
||||||
|
if (fb.getNumColorBuffers() == 0 && fb.getDepthBuffer() == null) {
|
||||||
|
throw new IllegalArgumentException("The framebuffer: " + fb
|
||||||
|
+ "\nDoesn't have any color/depth buffers");
|
||||||
|
}
|
||||||
|
|
||||||
if (fb.isUpdateNeeded()) {
|
if (fb.isUpdateNeeded()) {
|
||||||
updateFrameBuffer(fb);
|
updateFrameBuffer(fb);
|
||||||
}
|
}
|
||||||
@ -1612,10 +1640,16 @@ public class JoglRenderer implements Renderer {
|
|||||||
context.boundReadBuf = -2;
|
context.boundReadBuf = -2;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (fb.getNumColorBuffers() > maxFBOAttachs) {
|
||||||
|
throw new RendererException("Framebuffer has more color "
|
||||||
|
+ "attachments than are supported"
|
||||||
|
+ " by the video hardware!");
|
||||||
|
}
|
||||||
if (fb.isMultiTarget()) {
|
if (fb.isMultiTarget()) {
|
||||||
if (fb.getNumColorBuffers() > maxMRTFBOAttachs) {
|
if (fb.getNumColorBuffers() > maxMRTFBOAttachs) {
|
||||||
throw new UnsupportedOperationException("Framebuffer has more"
|
throw new RendererException("Framebuffer has more"
|
||||||
+ " targets than are supported" + " on the system!");
|
+ " multi targets than are supported"
|
||||||
|
+ " by the video hardware!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (context.boundDrawBuf != 100 + fb.getNumColorBuffers()) {
|
if (context.boundDrawBuf != 100 + fb.getNumColorBuffers()) {
|
||||||
@ -1641,15 +1675,16 @@ public class JoglRenderer implements Renderer {
|
|||||||
assert fb.getId() >= 0;
|
assert fb.getId() >= 0;
|
||||||
assert context.boundFBO == fb.getId();
|
assert context.boundFBO == fb.getId();
|
||||||
lastFb = fb;
|
lastFb = fb;
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
checkFrameBufferError();
|
checkFrameBufferError();
|
||||||
} catch (IllegalStateException ex) {
|
} catch (IllegalStateException ex) {
|
||||||
logger.log(Level.SEVERE, "Problem FBO:\n{0}", fb);
|
logger.log(Level.SEVERE, "=== jMonkeyEngine FBO State ===\n{0}", fb);
|
||||||
|
printRealFrameBufferInfo(fb);
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void readFrameBuffer(FrameBuffer fb, ByteBuffer byteBuf) {
|
public void readFrameBuffer(FrameBuffer fb, ByteBuffer byteBuf) {
|
||||||
if (fb != null) {
|
if (fb != null) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user