开发者

refresh a canvas to draw a new object

Hello everybody i'm new here and new on the opengl and 3d world i have successfuly load and display an obj file but whene i reload a new one by pressing开发者_开发知识库 a jbutton the new one is drawn under the old one please can you help me to refresh the glcanvas.


You do not say what your jbutton does so im guessing you are reinitializing your drawable when you load your new object.. In my experience this only adds a new drawable to your canvas.. I would prefer to just change whats beeing drawn but if not heres how to close your current drawable/canvas:

        try {
            canvas.getContext().makeCurrent();
            canvas.getContext().release();
            canvas.getContext().destroy();
            drawable.getContext().makeCurrent();
            drawable.getContext().release();
            drawable.getContext().destroy();

        } catch (GLException releaseFailure) {
            releaseFailure.printStackTrace();
        }

And then reinitialize them when you add the new object..

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜