DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
View Events Video Library
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Integrating PostgreSQL Databases with ANF: Join this workshop to learn how to create a PostgreSQL server using Instaclustr’s managed service

Mobile Database Essentials: Assess data needs, storage requirements, and more when leveraging databases for cloud and edge applications.

Monitoring and Observability for LLMs: Datadog and Google Cloud discuss how to achieve optimal AI model performance.

Automated Testing: The latest on architecture, TDD, and the benefits of AI and low-code tools.

Related

  • JDev Flies on NetBeans
  • NetBeans Platform Control Application for Testing of Cellular Networks
  • My Experiences with Maven in IntelliJ IDEA and NetBeans IDE
  • NetBeans Platform Offshore

Trending

  • Development of Custom Web Applications Within SAP Business Technology Platform
  • Streamlined Infrastructure Deployment: Harnessing the Power of Terraform and Feature Toggles
  • Effective Tips for Debugging Complex Code in Java
  • Architecting a Completely Private VPC Network and Automating the Deployment
  1. DZone
  2. Coding
  3. Tools
  4. Getting Started with JOGL on the NetBeans Platform

Getting Started with JOGL on the NetBeans Platform

Geertjan Wielenga user avatar by
Geertjan Wielenga
·
Feb. 16, 12 · News
Like (0)
Save
Tweet
Share
39.77K Views

Join the DZone community and get the full member experience.

Join For Free

JOGL is a cool Java 3D library and I was amazed to find I had a working sample on the NetBeans Platform within about 10 minutes of getting started.

  1. Start by clicking the Download button here:

    http://plugins.netbeans.org/plugin/3260/netbeans-opengl-pack

  2. OK. Now you have lots of NBMs. In NetBeans IDE 7.1, go to Tools | Plugins and then, in the Downloaded tab (which is shown below), add all the plugins you downloaded from the site above. However, uncheck the "GLSL editor" module from the list below, since it doesn't install into 7.1 and you will get errors when you try to install it, but don't worry because we won't need it anyway:

    Then click Install above and everything, except the one you excluded, will be installed.

  3. Now go to the Projects window and you'll find lots of samples:


  4. In the list above, choose "GearsDemo.zip" and then click Next. In the next page, shown below, accept all the defaults and click Finish:


  5. Run the application and you should see the following, which is what we're going to be porting to the NetBeans Platform:


  6. Now create a new NetBeans Platform application. In the application, create a module named "JOGLGears", where your functionality will live. There, create a new TopComponent, with whatever name you like. Then add two library wrapper modules (right-click on the Modules node of the application and choose "Add New Library"), one for the gluegen-rt.jar and the other for the jogl.jar. You will find these JARs in the NetBeans user directory (not the installation directory), e.g., ".netbeans" in Linux systems. Then set the dependencies between them as shown below, i.e., importantly, jogl should depend on gluegen-rt and JOGLGears should depend on jogl:


  7. Now switch to the Files window and put the native libraries into a folder named "release/modules/lib", as shown below, which you can create in any of the modules, since they'll all end up in the same place when the application is compiled:


    Next, add this line to "platform.properties" in the "JOGLGearsApp" (i.e., you will find this file in the "Important Files" node of the main application):

    run.args.extra=-J-Djava.library.path=../JOGLGearsApp/release/modules/lib

    For further advice on the above, see this link, which is where I got the tip above.
  8. Copy the "JOGLGearsDemo.java" file from the sample into your "JOGLGears" module. Then copy the annotations from your TopComponent into the file you copied and let the class extend TopComponent. I.e., the end result should be as follows, for the class declaration and the replacement of the Main method:
    @TopComponent.Description(preferredID = "GearsTopComponent",
    //iconBase="SET/PATH/TO/ICON/HERE", 
    persistenceType = TopComponent.PERSISTENCE_ALWAYS)
    @TopComponent.Registration(mode = "editor", openAtStartup = true)
    @ActionID(category = "Window", id = "org.jogl.gears.GearsTopComponent")
    @ActionReference(path = "Menu/Window" /*
     * , position = 333
     */)
    @TopComponent.OpenActionRegistration(displayName = "#CTL_GearsAction",
    preferredID = "GearsTopComponent")
    @NbBundle.Messages({
        "CTL_GearsAction=Gears",
        "CTL_GearsTopComponent=Gears Window",
        "HINT_GearsTopComponent=This is a Gears window"
    })
    public class JOGLGearsDemo extends TopComponent implements GLEventListener, MouseListener, MouseMotionListener {
    
        public JOGLGearsDemo() {
            setLayout(new BorderLayout());
            GLCanvas canvas = new GLCanvas();
    
            canvas.addGLEventListener(this);
            add(canvas, BorderLayout.CENTER);
            final Animator animator = new Animator(canvas);
            addComponentListener(new ComponentAdapter() {
    
                public void windowClosing(WindowEvent e) {
                    // Run this on another thread than the AWT event queue to
                    // make sure the call to Animator.stop() completes before
                    // exiting
                    new Thread(new Runnable() {
    
                        public void run() {
                            animator.stop();
                            System.exit(0);
                        }
                    }).start();
                }
            });
            animator.start();
        }
    
  9. Run the application and you should see the following, which is not static but spinning gears, this time in the NetBeans Platform:

Drag with your mouse in the TopComponent to change the position and angle of the gears. That's it, you're done. You can now continue working with JOGL. Have fun!

NetBeans

Opinions expressed by DZone contributors are their own.

Related

  • JDev Flies on NetBeans
  • NetBeans Platform Control Application for Testing of Cellular Networks
  • My Experiences with Maven in IntelliJ IDEA and NetBeans IDE
  • NetBeans Platform Offshore

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: