Login  Register

No Window opens when using GLCanvas

Posted by FieryToken on Jan 08, 2021; 3:58pm
URL: https://forum.jogamp.org/No-Window-opens-when-using-GLCanvas-tp4040945.html

So i am experiencing a weird problem currently. I want to use WorldWind in my Java application but when i want to create a WorldWindowGLCanvas the thread with which i want to create it just "freezes" and does nothing. It throws no error message or anything that could give a clue to what the problem is. There is just no window opening. I also tried one of my older OpenGL Projects that use a GLCanvas and the same problem happens there. No window opens up but it worked before.
If i comment the creation of the GLCanvas or WorldWindowGLCanvas out and just start the JFrame i see the JFrame. So i guess it must have something to do with OpenGL.
Some Info
My IDE is: IntelliJ Ultimate
Graphics Card is: Intel HD graphics 520(newest driver installed)
Jogl version is: 2.3.2

Maybe someone experienced something simillar and can help me ^^? If i missed some info that you may need feel free to ask for it.

Code:

import gov.nasa.worldwind.BasicModel;
import gov.nasa.worldwind.WorldWindowGLDrawable;
import gov.nasa.worldwind.avlist.AVKey;
import gov.nasa.worldwind.awt.WorldWindowGLCanvas;
import gov.nasa.worldwind.globes.Earth;
import gov.nasa.worldwind.layers.IconLayer;
import gov.nasa.worldwind.layers.RenderableLayer;
import gov.nasa.worldwind.render.Renderable;
import gov.nasa.worldwind.util.WWUtil;

import javax.swing.*;
import java.awt.*;

public class ViewVolume extends JFrame {

    //CustomClass responsible for rendering the Globe and Layers
    protected WWPanel wwp;

    //Displays all the Layers and enables them to be turned on and off
    protected LayerPanel layerPanel;

    //Layer to display the CityIcons
    protected IconLayer iconLayer;

    //Renderable Layer for PointClouds
    protected RenderableLayer renderableLayer;

    public ViewVolume(){
        this.getContentPane().setLayout(new BorderLayout(5,5));
        this.wwp = new WWPanel(new Dimension(650,500));
        this.getContentPane().add(wwp);

        this.pack();
        this.setResizable(true);
        WWUtil.alignComponent(null,this, AVKey.CENTER);

        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        //Adding the LayerPanel to toggle different Layers on and off
        layerPanel = new LayerPanel(wwp.wwd);
        //this.getContentPane().add(this.layerPanel, BorderLayout.WEST);
    }

    protected static class WWPanel extends JPanel {
        WorldWindowGLCanvas wwd;
        public WWPanel(Dimension size){
            //Create a WorldWindowGlCanvas -> needed to display the Globe, Layers etc.
            this.wwd = new WorldWindowGLCanvas();     //<- If i comment this out(and everything related to it) i can see the JFrame)
            //set the Window size
            this.wwd.setSize(size);

            //Create a BasicModel with earth as its Globe
            BasicModel bm = new BasicModel();
            bm.setGlobe(new Earth());

            //assign the Model to the WorldWindowGlCanvas
            this.wwd.setModel(bm);

            //add a BorderLayout to this JPanel
            this.setLayout(new BorderLayout(5,5));

            //add the WorldWindowGlCanvas to this JPanel centered
            this.add(this.wwd, BorderLayout.CENTER);

        }
    }

    public static void main(String[] args){
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                ViewVolume vv = new ViewVolume();
                vv.setVisible(true);
            }
        });
    }
}