GLEventListener的问题

时间:2016-04-07 21:39:50

标签: java swing opengl 3d jogl

我正在编写3D应用程序。我正试图让JOGL工作,但没有任何显示。我有一个实现GLEventListener的UI类,然后实现displayinit。但是,从我的调试工具中可以看出,displayinit永远不会被调用,并且场景永远不会被渲染。 建议?我使用的是带有El Capitan OS X的MacBook 2013,2.6 GHz Intel Core i5,8 GB RAM。

/**UserInterface class implements tGLEventListener**/

public class UserInterface implements GLEventListener{
    private JTree tree;
    JPopupMenu popupmenu;
    GLRenderer renderer = new GLRenderer();
    JFrame frame = new JFrame("NecroTEK 3D Game Graphics Engine");

    public void initUI()
    {
        System.out.println("Initializing UI");
        TreeDemo();

        //JFrame frame = new JFrame("NecroTek 3D Game Modeling Engine");
        JPopupMenu popupMenu = new JPopupMenu();
        popupMenu.setSize(200, 400);
        popupMenu.setBackground(Color.black);
        popupMenu.setForeground(Color.white);
        popupMenu.setBorder(BorderFactory.createLineBorder(Color.white));

        /**********MENUBAR - TOP MENU***************/

        JMenuBar menuBar = new JMenuBar();

        menuBar.setLayout(new BoxLayout(menuBar, BoxLayout.X_AXIS));        

        JMenu fileMenu = new JMenu("File");
        fileMenu.setFont(new Font("Arial", Font.BOLD, 10));

        fileMenu.setToolTipText("Load and Save Projects and Scenes");

        JMenu EditMenu = new JMenu("Edit");
        EditMenu.setFont(new Font("Arial", Font.BOLD, 10));
        EditMenub.setToolTipText("Cut, Copy and Paste");

       display() and init() should be called by the listener but aren't. Right???
             display is supposed to be called every cycle but
            it is never called.

            public void display(GLAutoDrawable arg0) {
                // TODO Auto-generated method stub
                System.out.println("Display");
                renderer.display(arg0);

            }

            public void dispose(GLAutoDrawable arg0) {
                // TODO Auto-generated method stub
                System.out.println("Dispose");
            }

监听器应至少调用此函数一次。但事实并非如此。

@Override
public void init(GLAutoDrawable arg0) {
    // TODO Auto-generated method stub
    System.out.println("Init");
    renderer.init(arg0);
}
@Override
public void reshape(GLAutoDrawable arg0, int arg1, int arg2, int arg3, int arg4) {
    // TODO Auto-generated method stub
    System.out.println("Reshape");
}

我不明白。它没有调用display函数或init

0 个答案:

没有答案