本文介绍了Java 3D:在哪里可以插入“后期渲染"?外汇?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我扩展了一个 Canvas3D,然后我覆盖了方法postSwap()",但我的奇偶线效果闪烁很多,插入这个过程的另一个好处是什么?

I extended a Canvas3D and then I override the method "postSwap()", but my odd-even line effect is flickering a lot, what could be another good point for inserting this process?

public void postSwap() {
    Graphics2D g2 = (Graphics2D)this.getGraphics();
    Map map = new HashMap();
    map.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
    g2.addRenderingHints(map);
    g2.setColor(WipideaApplet.BCK2);
    int h = this.getHeight(), w = this.getWidth();
    for (int i=0;i<h;i++) {
        if (i%2==0)
            g2.drawLine(0, i, w, i);
    }
}

推荐答案

我自己找到了一个很好的解决方案,我把它贴在这里分享,如果你有其他的请贴出来:-)

I found a good solution by myself which I post here to share it, if you have another one please post it :-)

@Override
public void postRender() {
    super.postRender();
    getGraphics2D().setColor(WipideaApplet.BCK2);
    int h = this.getHeight(), w = this.getWidth();
    for (int i=0;i<h;i++) {
            if (i%2==0) {
                getGraphics2D().drawLine(0, i, w, i);
            }
    }
    getGraphics2D().flush(true);
}

实际上 getGraphics2D().flush(true); 是最重要的,因为避免任何闪烁,至少在我的 centrino duo 上:-)

Pratically getGraphics2D().flush(true); is the most important, because avoid any flickering, at least on my centrino duo :-)

这篇关于Java 3D:在哪里可以插入“后期渲染"?外汇?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 08:37