All Downloads are FREE. Search and download functionalities are using the official Maven repository.

darwin.resourcehandling.shader.ShaderDependecyInspector Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (C) 2012 Daniel Heinrich 
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see .
 */
package darwin.resourcehandling.shader;

import java.io.*;
import java.nio.file.Path;
import java.util.*;

import darwin.annotations.ServiceProvider;
import darwin.renderer.shader.Shader;
import darwin.resourcehandling.ResourceDependecyInspector;
import darwin.resourcehandling.handle.ClasspathFileHandler;

/**
 *
 * @author Daniel Heinrich 
 */
@ServiceProvider(ResourceDependecyInspector.class)
public class ShaderDependecyInspector extends ResourceDependecyInspector {

    public ShaderDependecyInspector()
    {
        super(Shader.class);
    }

    @Override
    public Iterable getDependencys(ClasspathFileHandler resource) {
        ArrayList dependencys = new ArrayList<>();
        try (InputStream stream = resource.getStream()) {
            BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
            String line;
            while ((line = reader.readLine()) != null) {
                line = line.trim();
                if (line.startsWith(ShaderLoader.INCLUDE_PREFIX)) {
                    String path = line.substring(ShaderLoader.INCLUDE_PREFIX.length()).trim();
                    dependencys.add(ShaderLoader.SHADER_PATH.resolve(path));
                }
            }
        } catch (IOException ex) {
        }
        return dependencys;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy