JOGL project does not work in a different computer
Posted by r.jaoui on Oct 26, 2021; 12:16pm
URL: https://forum.jogamp.org/JOGL-project-does-not-work-in-a-different-computer-tp4041404.html
Hello !
I'm having what seems to be a very basic problem with JOGL : my projects are built in Eclipse, and in the computer I usually work in they run normally, but on another one, some functions can't seem to be found. For instance, here is the simple code that I try to run :
//Main.java
package basic;
public class Main {
public static void main(String[] args) {
@SuppressWarnings("unused")
Frame frame = new Frame(1280, 720);
}
}
//Frame.java
package basic;
import javax.swing.JFrame;
import com.jogamp.opengl.GLCapabilities;
import com.jogamp.opengl.GLProfile;
import com.jogamp.opengl.awt.GLJPanel;
public class Frame extends JFrame{
private static final long serialVersionUID = 1L;
public static GLProfile PROFILE;
public static GLCapabilities CAPABILITIES;
public static GLJPanel panel;
public static PanelListener listener;
public Frame(int width, int height) {
super();
PROFILE = GLProfile.get(GLProfile.GL2);
CAPABILITIES = new GLCapabilities(PROFILE);
CAPABILITIES.setSampleBuffers(true);
CAPABILITIES.setNumSamples(8);
CAPABILITIES.setStencilBits(8);
CAPABILITIES.setDoubleBuffered(true);
CAPABILITIES.setPBuffer(true);
panel = new GLJPanel(CAPABILITIES);
listener = new PanelListener(panel);
panel.addGLEventListener(listener);
this.setContentPane(panel);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(width, height);
run();
}
public void run() {
while(true) {
panel.display();
try {Thread.sleep(1);}
catch (InterruptedException e) {e.printStackTrace();}
}
}
}
//PanelListener.java
package basic;
import com.jogamp.opengl.GL;
import com.jogamp.opengl.GL2;
import com.jogamp.opengl.GLAutoDrawable;
import com.jogamp.opengl.GLEventListener;
import com.jogamp.opengl.awt.GLJPanel;
public class PanelListener implements GLEventListener{
GLJPanel panel;
GL2 gl;
public PanelListener(GLJPanel panel) {
super();
this.panel = panel;
}
@Override
public void display(GLAutoDrawable arg0) {
}
@Override
public void dispose(GLAutoDrawable arg0) {
}
@Override
public void init(GLAutoDrawable arg0) {
if(gl == null) gl = this.panel.getGL().getGL2();
gl.glEnable(GL2.GL_LINE_SMOOTH);
gl.glEnable(GL2.GL_POINT_SMOOTH);
gl.glEnable(GL2.GL_SMOOTH);
gl.glEnable(GL.GL_MULTISAMPLE);
gl.glHint(GL2.GL_LINE_SMOOTH_HINT, GL2.GL_NICEST);
gl.glHint(GL2.GL_POINT_SMOOTH_HINT, GL2.GL_NICEST);
gl.glEnable(GL2.GL_BLEND);
gl.glBlendFuncSeparate(GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA, GL2.GL_ONE, GL2.GL_ONE);
gl.glClearColor(0, 0, 0, 0);
gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
gl.glBegin(GL2.GL_TRIANGLE_STRIP);
gl.glVertex2f(-0.5f, 0f);
gl.glVertex2f(0f, 0.5f);
gl.glVertex2f(0f, -0.5f);
gl.glEnd();
}
@Override
public void reshape(GLAutoDrawable arg0, int arg1, int arg2, int arg3, int arg4) {
}
}
And I'm getting this error :
Exception in thread "AWT-EventQueue-0" com.jogamp.opengl.GLException: Caught GLException: Method "glBlendFuncSeparate" not available on thread AWT-EventQueue-0
If I comment out the glBlendFuncSeparate call, the program runs and I do get my white triangle as expected. This is of course just an example but in more complex projects, a bunch of calls have this behaviour.
Note that on the build path of the project, I have jogl-all.jar, glugen-rt.jar as well as the corresponding Windows natives.
Any help ?
Thanks !