Re: Setting up a Java Maven project for using JOGL

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: Setting up a Java Maven project for using JOGL

chinnaswamyg
Hi All, I have set-up a Java maven project and added the following snippet in pom file to download all necessary jar files of JOGL usage from Maven repository.


<dependency>
    <groupId>org.jogamp.jogl</groupId>
    <artifactId>jogl-all-main</artifactId>
    <version>2.3.2</version>
</dependency>

 
<dependency>
    <groupId>org.jogamp.gluegen</groupId>
    <artifactId>gluegen-rt-main</artifactId>
    <version>2.3.2</version>
</dependency> 

It works fine for GLWindow and GLJPanel, but results in the following error when I opted for GLCanvas.

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 1
        at jogamp.opengl.windows.wgl.awt.WindowsAWTWGLGraphicsConfigurationFactory.chooseGraphicsConfigurationImpl(WindowsAWTWGLGraphicsConfigurationFactory.java:171)
        at com.jogamp.nativewindow.GraphicsConfigurationFactory.chooseGraphicsConfiguration(GraphicsConfigurationFactory.java:424)
        at com.jogamp.opengl.awt.GLCanvas.chooseGraphicsConfiguration(GLCanvas.java:1560)
        at com.jogamp.opengl.awt.GLCanvas.addNotify(GLCanvas.java:611)
        at java.desktop/java.awt.Container.addNotify(Container.java:2804)
        at java.desktop/javax.swing.JComponent.addNotify(JComponent.java:4839)
        at java.desktop/java.awt.Container.addNotify(Container.java:2804)
        at java.desktop/javax.swing.JComponent.addNotify(JComponent.java:4839)
        at java.desktop/java.awt.Container.addNotify(Container.java:2804)
        at java.desktop/javax.swing.JComponent.addNotify(JComponent.java:4839)
        at java.desktop/javax.swing.JRootPane.addNotify(JRootPane.java:729)
        at java.desktop/java.awt.Container.addNotify(Container.java:2804)
        at java.desktop/java.awt.Window.addNotify(Window.java:791)
        at java.desktop/java.awt.Frame.addNotify(Frame.java:495)
        at java.desktop/java.awt.Window.show(Window.java:1053)
        at java.desktop/java.awt.Component.show(Component.java:1728)
        at java.desktop/java.awt.Component.setVisible(Component.java:1675)
        at java.desktop/java.awt.Window.setVisible(Window.java:1036)
        at acs.engg.main.jogl.BasicFrameNew.main(BasicFrameNew.java:50)


When I debugged the program, line 171 where the error occurred is highlighted below where cgIdx seems  to be -1.

                if(DEBUG) {
                    System.err.println("WindowsAWTWGLGraphicsConfigurationFactory: PFD IDs: "+pfdIDs.length+", unique: "+pfdIDOSet.size());
                }
                winConfig.preselectGraphicsConfiguration(drawableFactory, pfdIDs);
                final int gcIdx = pfdIDOSet.indexOf(Integer.valueOf(winConfig.getPixelFormatID()));
                if( 0 > gcIdx ) {
 

                  chosenGC = configs[gcIdx];

                    if(DEBUG) {
                        System.err.println("WindowsAWTWGLGraphicsConfigurationFactory: Found matching AWT PFD ID "+winConfig.getPixelFormatID()+" -> "+winConfig);
                    }
                }
            }
        } else {
            chosenGC = device.getDefaultConfiguration();
        }

        if ( null == chosenGC ) {
            throw new GLException("Unable to determine GraphicsConfiguration: "+winConfig);
        }
        return new AWTGraphicsConfiguration(awtScreen, winConfig.getChosenCapabilities(), winConfig.getRequestedCapabilities(),
                                            chosenGC, winConfig);
    }
}


May I request for your advice to get rid of this problem.  

Thanks and regards

Swamy






Reply | Threaded
Open this post in threaded view
|

Re: Setting up a Java Maven project for using JOGL

chinnaswamyg
Hi All, I could figure out after seeing one of Julien Gouesse's response of the same problem posted on 2019-08-16. In the RunConfiguration of Eclipse IDE, by adding the following lines as VM arguements. --add-exports java.base/java.lang=ALL-UNNAMED --add-exports java.desktop/sun.awt=ALL-UNNAMED --add-exports java.desktop/sun.java2d=ALL-UNNAMED, it works! Thanks and regards
Reply | Threaded
Open this post in threaded view
|

Re: Setting up a Java Maven project for using JOGL

gouessej
Administrator
You're welcome. Think about using JOGL 2.4.0 instead of JOGL 2.3.2.

N.B: you need to use the development repository in this case:
https://jogamp.org/deployment/maven

Please look at my example using Maven:
https://jogamp.org/cgit/ardor3d.git/tree/pom.xml#n51
Julien Gouesse | Personal blog | Website