Jump to content
  • Advertisement
Sign in to follow this  
Swattkidd

[java] Problem installing JOGL

This topic is 4222 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok well here is an odd update, i seem to have gotton JOGL installed, and when i run the program below it works, but when i kept following down the site for some more samples, it could never find the method createGLCanvas (something like that if not exact) which confuses me as a lot of sites use that in their program, why isnt it working? Do i need to download something else to get the whole canvas thing working? Code that works (i had to change the import from import net.java somethin games and so on.
import javax.media.opengl.*;

public class HelloWorld {
  public static void main (String args[]) {
    try {
      System.loadLibrary("jogl");
      System.out.println("Hello World! (The native libraries are installed.)");
      GLCapabilities caps = new GLCapabilities();
      System.out.println("Hello JOGL! (The jar appears to be available.)");
    } catch (Exception e) {
      System.out.println(e);
    }
  }
CODE THAT DOESNT WORK


import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import net.java.games.jogl.*;


/**
 * This is a basic JOGL app. Feel free to 
 * reuse this code or modify it.
 */
public class SimpleJoglApp extends JFrame {

  public static void main(String[] args) {
    final SimpleJoglApp app = new SimpleJoglApp();

    // show what we've done
    SwingUtilities.invokeLater (
      new Runnable() {
        public void run() {
          app.setVisible(true);
        }
      }
    );
  }

  public SimpleJoglApp() {
    //set the JFrame title
    super("Simple JOGL Application");

    //kill the process when the JFrame is closed
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    //only three JOGL lines of code ... and here they are 
    GLCapabilities glcaps = new GLCapabilities();
    GLCanvas glcanvas = GLDrawableFactory.getFactory().createGLCanvas(glcaps);
    glcanvas.addGLEventListener(new SimpleGLEventListener());

    //add the GLCanvas just like we would any Component
    getContentPane().add(glcanvas, BorderLayout.CENTER);
    setSize(500, 300);

    //center the JFrame on the screen
    centerWindow(this);
  }

  public void centerWindow(Component frame) {
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension frameSize  = frame.getSize();

    if (frameSize.width  > screenSize.width ) frameSize.width  = screenSize.width;
    if (frameSize.height > screenSize.height) frameSize.height = screenSize.height;

    frame.setLocation (
      (screenSize.width  - frameSize.width ) >> 1, 
      (screenSize.height - frameSize.height) >> 1
    );
  }
}
[Edited by - Swattkidd on March 25, 2007 2:47:15 PM]

Share this post


Link to post
Share on other sites
Advertisement
You are mixing the old API with the new jars. You don't create GLCanvas with that call anymore. Try GLCanvas glcanvas = new GLCanvas(glcaps);

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!