Re: Setting up a Java Maven project for using JOGL
Posted by chinnaswamyg on Mar 02, 2023; 9:17am
URL: https://forum.jogamp.org/Re-Setting-up-a-Java-Maven-project-for-using-JOGL-tp4042259.html
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