ParticleShader.java 文件源码

java
阅读 21 收藏 0 点赞 0 评论 0

项目:nhglib 作者:
protected void bindMaterial(final Renderable renderable) {
    if (currentMaterial == renderable.material) return;

    int cullFace = config.defaultCullFace == -1 ?
            GL20.GL_BACK :
            config.defaultCullFace;

    int depthFunc = config.defaultDepthFunc == -1 ?
            GL20.GL_LEQUAL :
            config.defaultDepthFunc;

    float depthRangeNear = 0f;
    float depthRangeFar = 1f;
    boolean depthMask = true;

    currentMaterial = renderable.material;

    for (final Attribute attr : currentMaterial) {
        final long t = attr.type;

        if (BlendingAttribute.is(t)) {
            context.setBlending(true, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
        } else if ((t & DepthTestAttribute.Type) == DepthTestAttribute.Type) {
            DepthTestAttribute dta = (DepthTestAttribute) attr;
            depthFunc = dta.depthFunc;
            depthRangeNear = dta.depthRangeNear;
            depthRangeFar = dta.depthRangeFar;
            depthMask = dta.depthMask;
        } else if (!config.ignoreUnimplemented) {
            throw new GdxRuntimeException("Unknown material attribute: " + attr.toString());
        }
    }

    context.setCullFace(cullFace);
    context.setDepthTest(depthFunc, depthRangeNear, depthRangeFar);
    context.setDepthMask(depthMask);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号