Search in sources :

Example 1 with FboConfig

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);
        }
    }
}
Also used : FBO(org.terasology.engine.rendering.opengl.FBO) FboConfig(org.terasology.engine.rendering.opengl.FboConfig) SimpleUri(org.terasology.engine.core.SimpleUri) Map(java.util.Map)

Example 2 with FboConfig

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);
}
Also used : FBO(org.terasology.engine.rendering.opengl.FBO) FboConfig(org.terasology.engine.rendering.opengl.FboConfig) BufferPair(org.terasology.engine.rendering.dag.dependencyConnections.BufferPair) SimpleUri(org.terasology.engine.core.SimpleUri)

Example 3 with FboConfig

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);
}
Also used : FBO(org.terasology.engine.rendering.opengl.FBO) SwappableFBO(org.terasology.engine.rendering.opengl.SwappableFBO) FboConfig(org.terasology.engine.rendering.opengl.FboConfig) SwappableFBO(org.terasology.engine.rendering.opengl.SwappableFBO) SimpleUri(org.terasology.engine.core.SimpleUri)

Example 4 with FboConfig

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.
}
Also used : FboConfig(org.terasology.engine.rendering.opengl.FboConfig) SimpleUri(org.terasology.engine.core.SimpleUri)

Aggregations

SimpleUri (org.terasology.engine.core.SimpleUri)4 FboConfig (org.terasology.engine.rendering.opengl.FboConfig)4 FBO (org.terasology.engine.rendering.opengl.FBO)3 Map (java.util.Map)1 BufferPair (org.terasology.engine.rendering.dag.dependencyConnections.BufferPair)1 SwappableFBO (org.terasology.engine.rendering.opengl.SwappableFBO)1