JOGL project does not work in a different computer

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

JOGL project does not work in a different computer

r.jaoui
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 !
Reply | Threaded
Open this post in threaded view
|

Re: JOGL project does not work in a different computer

Martin
Hi,

This function requires OpenGL4. You are probably using a computer with an older OpenGL version.

There is an example program showing how to read the GL version that your computer support in the recent discussion named “selecting highest possible profile”

https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glBlendFunc.xhtml
Reply | Threaded
Open this post in threaded view
|

Re: JOGL project does not work in a different computer

r.jaoui
I just verified with a tool the supported OpenGL version and it is 3.1...

The issue is  I'm actually working on a rendering engine, that is supposed to work on the widest scale of architectures, so perhaps an unrelated question : can graphics drivers updates cause the supported version to be higher ? Should compatibility issues be solved directly in the engine's code itself ?

Thanks for your help !
Reply | Threaded
Open this post in threaded view
|

Re: JOGL project does not work in a different computer

Martin
I don't think so. This version is the one of OpenGL as implemented by your GPU. The fact that 4.3 is not supported means that the hardware can't do it.

If you want to work on the widest possible computer set, you should include in your code some fallbacks for the case where the some function are missing, or try to do things with a function set that requires lower OpenGL version.

Maybe their exist software renderer to bridge the gap, but I don't know any.

Let us know how you fix this!
Reply | Threaded
Open this post in threaded view
|

Re: JOGL project does not work in a different computer

r.jaoui
Hi !

Well I'm a bit lost now. I decided that I wanted to do the  following things :
- Create a table with all the functions I'm using with the minimal required OpenGL version so that I know which ones are essential (and therefore add a minimal required OpenGL version to use my library).
- For those that can be dealt with another way, simply add a version check in my library and switch to using a different function when the version is too low.

First thing to do was to create the table of OpenGL compatibility :



But when checking the versions I noticed that actually, the function that doesn't work should work :



And for completeness' sake, here is the OpenGL version on this computer (as given by OpenGL Extension Viewer) :



Perhaps I'm missing something on how version are checked in the documentation, but it seems to me that this function should work...

Thanks for your help !
Reply | Threaded
Open this post in threaded view
|

Re: JOGL project does not work in a different computer

Martin
Sorry for misleading you :/

I can't even find the error message you mention in the source code. Can you provide the complete stack trace of your exception?
Reply | Threaded
Open this post in threaded view
|

Re: JOGL project does not work in a different computer

r.jaoui
Haha don't worry, I had to do the  compatibility check either way !

Sure, here is the full stacktrace :

Exception in thread "AWT-EventQueue-0" com.jogamp.opengl.GLException: Caught GLException: Method "glBlendFuncSeparate" not available on thread AWT-EventQueue-0
        at com.jogamp.opengl.GLException.newGLException(GLException.java:76)
        at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1327)
        at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:1147)
        at com.jogamp.opengl.awt.GLJPanel$OffscreenBackend.doPaintComponent(GLJPanel.java:2095)
        at com.jogamp.opengl.awt.GLJPanel.paintComponent(GLJPanel.java:569)
        at javax.swing.JComponent.paint(Unknown Source)
        at javax.swing.JComponent.paintChildren(Unknown Source)
        at javax.swing.JComponent.paint(Unknown Source)
        at javax.swing.JLayeredPane.paint(Unknown Source)
        at javax.swing.JComponent.paintChildren(Unknown Source)
        at javax.swing.JComponent.paintToOffscreen(Unknown Source)
        at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(Unknown Source)
        at javax.swing.RepaintManager$PaintManager.paint(Unknown Source)
        at javax.swing.RepaintManager.paint(Unknown Source)
        at javax.swing.JComponent.paint(Unknown Source)
        at java.awt.GraphicsCallback$PaintCallback.run(Unknown Source)
        at sun.awt.SunGraphicsCallback.runOneComponent(Unknown Source)
        at sun.awt.SunGraphicsCallback.runComponents(Unknown Source)
        at java.awt.Container.paint(Unknown Source)
        at java.awt.Window.paint(Unknown Source)
        at javax.swing.RepaintManager$4.run(Unknown Source)
        at javax.swing.RepaintManager$4.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
        at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
        at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
        at javax.swing.RepaintManager.prePaintDirtyRegions(Unknown Source)
        at javax.swing.RepaintManager.access$1200(Unknown Source)
        at javax.swing.RepaintManager$ProcessingRunnable.run(Unknown Source)
        at java.awt.event.InvocationEvent.dispatch(Unknown Source)
        at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
        at java.awt.EventQueue.access$500(Unknown Source)
        at java.awt.EventQueue$3.run(Unknown Source)
        at java.awt.EventQueue$3.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: com.jogamp.opengl.GLException: Method "glBlendFuncSeparate" not available
        at jogamp.opengl.gl4.GL4bcImpl.glBlendFuncSeparate(GL4bcImpl.java:9048)
        at basic.PanelListener.init(PanelListener.java:42)
        at jogamp.opengl.GLDrawableHelper.reshape(GLDrawableHelper.java:749)
        at com.jogamp.opengl.awt.GLJPanel$Updater.display(GLJPanel.java:1442)
        at com.jogamp.opengl.awt.GLJPanel$10.run(GLJPanel.java:1521)
        at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1293)
        ... 41 more


I initially suspected the library definition to be wrong initially, since it seems that the Eclipse code recommendation don't work either, but I can't be sure... I'll try to create a blank workspace and try to build the library again there this afternoon.

Thanks !
Reply | Threaded
Open this post in threaded view
|

Re: JOGL project does not work in a different computer

r.jaoui
In reply to this post by Martin
Actually, I think that you are right and the issue is with the OpenGL version. I tried using the functions whose compatibility is above 3.0 and none work, while all others do...

I tried to get the version in code, by calling :
System.out.println("OpenGL version : " + gl.glGetString(GL2.GL_VERSION));
And I got :
OpenGL version : 1.1.0

This kind of surprises me, since it seems that the maximum valid version of OpenGL is 3.1 in my computer... And also this computer isn't that old haha.
Reply | Threaded
Open this post in threaded view
|

Re: JOGL project does not work in a different computer

Martin
If you read the discussion concerning profile selection, you may see that following Julien's recommendation I fixed a weird version output by using -Djogl.disable.openglcore=true.
Reply | Threaded
Open this post in threaded view
|

Re: JOGL project does not work in a different computer

r.jaoui
I tried adding that VM argument, but the result is the same (same error and same OpenGL version used).

Also, since I saw that it was important, note that I'm using a GL2 profile here :

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);


I also tried newer profiles, of course the same error occurs :/
Reply | Threaded
Open this post in threaded view
|

Re: JOGL project does not work in a different computer

Martin
I fear GLProfile.get(GLProfile.GL2) tied you below the profile you have on your computer. Despite GL2 that should be sufficient for the function you want to use, you may also use GLProfile.getMaximum(true) to get the highest version capabilities. Maybe JOGL will follow a more consistent path and provide you the capabilities your hardware really offers.

I met inconsistencies in the profile selection on my MacOS computers as you have read in the other discussion. I will try to dive in this and understand why.

Could you describe your OS/GPU/JDK?

Reply | Threaded
Open this post in threaded view
|

Re: JOGL project does not work in a different computer

r.jaoui
Hm well even with GLProfile.getMaximum(true) I still seem to only get OpenGL Version 1.1.0...

This computer is :
- OS : Windows 10, 32 bits
- GPU : Intel(R) HD Graphics 3000 with drivers up to date (I verified them so they should be)
- Java : jre1.8.0_261
Reply | Threaded
Open this post in threaded view
|

Re: JOGL project does not work in a different computer

gouessej
Administrator
Please indicate which options and arguments you pass to the JVM.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: JOGL project does not work in a different computer

gouessej
Administrator
In reply to this post by r.jaoui
By the way, it looks like a known limitation on the Intel drivers for your GPU, they just crash and you just get the crappy Microsoft GDI renderer supporting OpenGL 1.1. I think that there are already some posts and a bug report mentioning this problem. As far as I remember, patching the driver was one possible workaround.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: JOGL project does not work in a different computer

r.jaoui
In reply to this post by gouessej
Hello !

Well the only argument passed to the JVM is -Djogl.disable.openglcore=true, nothing else.

As for the possible bug with the Intel driver, if there is a patch I'd be interested (I'll look for it)

Thanks !
Reply | Threaded
Open this post in threaded view
|

Re: JOGL project does not work in a different computer

gouessej
Administrator
Sorry for the late reply, it's here:
https://jogamp.org/bugzilla/show_bug.cgi?id=1278
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: JOGL project does not work in a different computer

Martin
Hi r.jaoui,

Did the fix suggested by Julien worked for you?

Thanks!