Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. Using JOGL with QtJambi

Using JOGL with QtJambi

Scheduled Pinned Locked Moved Unsolved Language Bindings
qtjambijogljava
5 Posts 2 Posters 1.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Suisei
    wrote on 21 Dec 2016, 10:02 last edited by Suisei
    #1

    Hi !

    I’m trying to use JOGL with QtJambi. I’m using code I found in tutorials (some of them are very old) and forums but nothing is displayed. The QGLWidget initialization prevents the window to be displayed. I have no error in the console. The program is running, but there is no window.

    Is there something I’m doing wrong ?

    Here is my code.

    The GLWidget

    public class QtJOGLTestGLWidget extends QGLWidget
    {
        protected GLContext context; 
        protected GL gl; 
    
        public QtJOGLTestGLWidget()
        {
            this(null); 
        }
    
        public QtJOGLTestGLWidget(QWidget parent)
        {
            super(parent); 
        }
    
        @Override
        protected void initializeGL()
        {
            GLProfile profile = GLProfile.get(GLProfile.GL2); 
            GLCapabilities glCaps = new GLCapabilities(profile); 
            glCaps.setPBuffer(true); 
            GLDrawableFactory factory = GLDrawableFactory.getFactory(profile); 
            context().makeCurrent(); 
            this.context = factory.createExternalGLContext(); 
            this.context.makeCurrent(); 
            this.gl = this.context.getGL(); 
        }
    
        @Override 
        protected void resizeGL(int w, int h)
        {
            GL2 gl2 = this.gl.getGL2(); 
            gl2.glViewport(0, 0, w, h);
            gl2.glMatrixMode(GL2.GL_PROJECTION);
            float r = 3.0f / 2.0f;
            gl2.glLoadIdentity();
            gl2.glFrustum(-0.2, 1 * r, -0.2, 1.2, 1, 2000);
        }
    
        @Override
        protected void paintGL()
        {
            GL2 gl2 = this.gl.getGL2(); 
    
            gl2.glMatrixMode(GL2.GL_MODELVIEW);
            gl2.glLoadIdentity();
    
            gl2.glBegin(GL.GL_TRIANGLES);
            {
                gl2.glColor3f(1, 0, 0);
                gl2.glVertex3f(0, 0, -1);
                gl2.glColor3f(0, 1, 0);
                gl2.glVertex3f(0, 1, -1);
                gl2.glColor3f(0, 0, 1);
                gl2.glVertex3f(1, 0, -1);
            }
            gl2.glEnd();
        }
    }
    

    The window

    public class QtJOGLTestFrame extends QMainWindow
    {
        protected QtJOGLTestGLWidget glWidget; 
        protected QGridLayout gridLayout; 
    
        public QtJOGLTestFrame()
        {
            this.gridLayout = new QGridLayout(); 
            this.glWidget = new QtJOGLTestGLWidget(this); // This line prevents the window to be displayed 
            this.gridLayout.addWidget(this.glWidget, 0, 0); 
    
            QWidget widget = new QWidget(); 
            widget.setLayout(this.gridLayout); 
            this.setCentralWidget(widget); 
            this.setWindowTitle("Hello JOGL");
        }
    }
    

    Main

    public class QtJOGLTest
    {
        public static void main(String[] args)
        {
            QApplication.initialize(args);
            QtJOGLTestFrame frame = new QtJOGLTestFrame(); 
            frame.resize(800, 600); 
            frame.show(); 
            QApplication.execStatic();
        }
    }
    

    I'm using the last version of JOGL and Mac OS X Sierra.

    Thank you in advance.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 21 Dec 2016, 22:46 last edited by
      #2

      Hi,

      What version of Qt are you using ?

      Did you test that everything is working fine in C++ before using Java ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • S Offline
        S Offline
        Suisei
        wrote on 22 Dec 2016, 00:00 last edited by Suisei
        #3

        Hi !

        QtJambi is using the 4.8.6 version of Qt.
        I didn't test with C++ because of lack of experience with this language.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 22 Dec 2016, 08:59 last edited by SGaist
          #4

          Qt 4.8.6 might be working properly or not on Sierra. The thing is that latest and last version of Qt 4 is 4.8.7 and it was released long before Sierra so I might or might not work as intended because of changes from Apple.

          I'd recommend contacting the folks who are currently handling the QtJambi module which was officially retired in 2010.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • S Offline
            S Offline
            Suisei
            wrote on 22 Dec 2016, 14:37 last edited by Suisei
            #5

            Thanks for the information.
            I tested on a Windows 7 virtual machine and it works. So I suppose you are right about a compatibility problem with Sierra.
            I'll contact the current dev team of QtJambi.

            1 Reply Last reply
            0

            2/5

            21 Dec 2016, 22:46

            • Login

            • Login or register to search.
            2 out of 5
            • First post
              2/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved