简体   繁体   English

Java jogl applet油漆不起作用?

[英]Java jogl applet paint not working?

My jogl applet screen is blank. 我的慢速小程序屏幕为空白。 I have this for my paint code: 我有我的绘画代码:

 public void paint(Graphics g){
        canvas.update(g);
    }

if I add g.fillRect(0,0,50,50); 如果我添加g.fillRect(0,0,50,50); to it it'll draw the filled rect, but still not the jogl stuff. 它将绘制填充的矩形,但仍然不是轻柔的东西。

I'm not exactly clear what the rest of your program looks like. 我不清楚您程序的其余部分是什么样的。 However you should be aware that JOGL components don't draw like other components; 但是,您应该注意,JOGL组件不会像其他组件那样绘制; in other words if this code is on an instance of GLAutoDrawable (ie GLJPanel or GLCanvas) then it won't do anything useful. 换句话说,如果此代码位于GLAutoDrawable实例(即GLJPanel或GLCanvas)上,则它将无济于事。

What you need to do is create a GLEventListener and attach it to the GLAutoDrawable. 您需要做的是创建一个GLEventListener并将其附加到GLAutoDrawable。 Then you need to implement display (GLDrawable drawable) with code that draws your 3D scene. 然后,您需要使用绘制3D场景的代码来实现display (GLDrawable drawable)

This tutorial is useful in getting you started. 本教程有助于您入门。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM