use of org.terasology.engine.rendering.opengl.FboConfig in project Terasology by MovingBlocks.
the class ShadowMapResolutionDependentFbo method propertyChange.
/**
* Triggers the regeneration of the shadow map FBOs, if necessary.
*
* Once triggered this method checks if "dynamic shadows" are enabled.
* If dynamics shadows are enabled it obtains the new Shadow Map resolution from the event
* passed to the method and regenerates the shadow map FBOs.
*
* @param evt a PropertyChangeEvent, containing the shadow map resolution.
*/
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (renderingConfig.isDynamicShadows()) {
int shadowMapResFromSettings = (int) evt.getNewValue();
shadowMapResolution = new FBO.Dimensions(shadowMapResFromSettings, shadowMapResFromSettings);
for (Map.Entry<SimpleUri, FboConfig> entry : fboConfigs.entrySet()) {
SimpleUri fboName = entry.getKey();
FboConfig fboConfig = entry.getValue();
if (fboLookup.containsKey(fboName)) {
FBO fbo = fboLookup.get(fboName);
if (fbo != null) {
// TODO: validate if necessary
fbo.dispose();
}
}
FBO shadowMapResDependentFBO = generateWithDimensions(fboConfig, shadowMapResolution);
if (shadowMapResDependentFBO.getStatus() == FBO.Status.DISPOSED) {
logger.warn("Failed to generate ShadowMap FBO. Turning off shadows.");
renderingConfig.setDynamicShadows(false);
break;
}
fboLookup.put(fboName, shadowMapResDependentFBO);
}
}
}
use of org.terasology.engine.rendering.opengl.FboConfig in project Terasology by MovingBlocks.
the class ModuleRendering method createBufferPair.
protected BufferPair createBufferPair(String primaryBufferName, String secondaryBufferName, ScalingFactors sharedBufferScale, FBO.Type sharedBufferType, FBO.Dimensions scale) {
FBO buffer1 = generateWithDimensions(new FboConfig(new SimpleUri(providingModule + ":fbo." + primaryBufferName), sharedBufferScale, sharedBufferType).useDepthBuffer().useNormalBuffer().useLightBuffer().useStencilBuffer(), scale);
FBO buffer2 = generateWithDimensions(new FboConfig(new SimpleUri(providingModule + ":fbo." + secondaryBufferName), sharedBufferScale, sharedBufferType).useDepthBuffer().useNormalBuffer().useLightBuffer().useStencilBuffer(), scale);
return new BufferPair(buffer1, buffer2);
}
use of org.terasology.engine.rendering.opengl.FboConfig in project Terasology by MovingBlocks.
the class DisplayResolutionDependentFbo method generateDefaultFBOs.
private void generateDefaultFBOs() {
FBO gBuffer1 = generateWithDimensions(new FboConfig(new SimpleUri("engine:fbo.gBuffer1"), FULL_SCALE, FBO.Type.HDR).useDepthBuffer().useNormalBuffer().useLightBuffer().useStencilBuffer(), fullScale);
FBO gBuffer2 = generateWithDimensions(new FboConfig(new SimpleUri("engine:fbo.gBuffer2"), FULL_SCALE, FBO.Type.HDR).useDepthBuffer().useNormalBuffer().useLightBuffer().useStencilBuffer(), fullScale);
generateWithDimensions(new FboConfig(FINAL_BUFFER, FULL_SCALE, FBO.Type.DEFAULT), fullScale);
gBufferPair = new SwappableFBO(gBuffer1, gBuffer2);
}
use of org.terasology.engine.rendering.opengl.FboConfig in project Terasology by MovingBlocks.
the class DisplayResolutionDependentFbo method regenerateFbos.
private void regenerateFbos() {
propertyChangeSupport.firePropertyChange(PRE_FBO_REGENERATION, 0, 1);
for (SimpleUri urn : fboConfigs.keySet()) {
FboConfig fboConfig = getFboConfig(urn);
fboConfig.setDimensions(fullScale.multiplyBy(fboConfig.getScale()));
FBO.recreate(get(urn), getFboConfig(urn));
}
propertyChangeSupport.firePropertyChange(POST_FBO_REGENERATION, 0, 1);
// Note that the "old" and "new" values (0 and 1) in the above calls aren't actually
// used: they are only necessary to ensure that the event is fired up correctly.
}
Aggregations