Skip to content
This repository has been archived by the owner on Oct 20, 2020. It is now read-only.

Commit

Permalink
Merge pull request #947 from cedricpinson/bug/Fixes-framebuffer-lefto…
Browse files Browse the repository at this point in the history
…vers

Fixes framebuffer leftover
  • Loading branch information
cedricpinson authored Jan 30, 2018
2 parents a3e5c6e + 52394d5 commit c2ad0bf
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions sources/osgShadow/ShadowMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ utils.createPrototypeObject(
return this._dirty;
},
/**
* at which Texture unit number we start adding texture shadow
*/
* at which Texture unit number we start adding texture shadow
*/
setTextureUnitBase: function(unitBase) {
this._textureUnitBase = unitBase;
this._textureUnit = unitBase;
Expand Down Expand Up @@ -332,6 +332,15 @@ utils.createPrototypeObject(
}
},

_rebindFbo: function() {
this._cameraShadow.detachAll();
this._cameraShadow.attachTexture(FrameBufferObject.COLOR_ATTACHMENT0, this._texture);
this._cameraShadow.attachRenderBuffer(
FrameBufferObject.DEPTH_ATTACHMENT,
FrameBufferObject.DEPTH_COMPONENT16
);
},

/** initialize the ShadowedScene and local cached data structures.*/
init: function(atlasTexture, lightIndex, textureUnit) {
if (!this._shadowedScene) return;
Expand All @@ -344,7 +353,7 @@ utils.createPrototypeObject(

if (!atlasTexture) {
this.initTexture();

this._rebindFbo();
this._textureUnit = this._textureUnitBase + lightNumber;
this._texture.setLightNumber(lightNumber);
this._texture.setName('ShadowTexture' + this._textureUnit);
Expand Down Expand Up @@ -475,12 +484,7 @@ utils.createPrototypeObject(
vp.height() !== texture.getHeight()
) {
// if texture size changed update the camera rtt params
camera.detachAll();
camera.attachTexture(FrameBufferObject.COLOR_ATTACHMENT0, texture);
camera.attachRenderBuffer(
FrameBufferObject.DEPTH_ATTACHMENT,
FrameBufferObject.DEPTH_COMPONENT16
);
this._rebindFbo();
vp.setViewport(0, 0, texture.getWidth(), texture.getHeight());
}
}
Expand Down

0 comments on commit c2ad0bf

Please sign in to comment.