Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (769)
Games in Android Showcase (230)
games submitted by our members
Games in WIP (856)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Using JOGL with QtJambi  (Read 4009 times)
0 Members and 1 Guest are viewing this topic.
Offline Suisei

Junior Newbie


Exp: 7 years



« Posted 2016-12-20 17:15:29 »

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

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
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);
      this.context = factory.createExternalGLContext();
      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

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
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

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
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 updated the jogamp .jar today and all my other programs using JOGL with swing work well.

Thank you in advance.  Smiley
Offline gouessej
« Reply #1 - Posted 2016-12-27 16:16:31 »

Hi

The questions specific to JOGL should be asked on the official JogAmp forum.

Julien Gouesse | Personal blog | Website | Jogamp
Pages: [1]
  ignore  |  Print  
 
 

 
EgonOlsen (1672 views)
2018-06-10 19:43:48

EgonOlsen (1709 views)
2018-06-10 19:43:44

EgonOlsen (1159 views)
2018-06-10 19:43:20

DesertCoockie (1585 views)
2018-05-13 18:23:11

nelsongames (1186 views)
2018-04-24 18:15:36

nelsongames (1709 views)
2018-04-24 18:14:32

ivj94 (2533 views)
2018-03-24 14:47:39

ivj94 (1758 views)
2018-03-24 14:46:31

ivj94 (2836 views)
2018-03-24 14:43:53

Solater (971 views)
2018-03-17 05:04:08
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!