Getting up and running with Visual Studio Code and JOGL

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Getting up and running with Visual Studio Code and JOGL

EatingBeansAgain
I'm new to OpenGL in Java, and Java in general. I am following a textbook and trying to create my first window. However, when I run my code, I get the error that "package com.jogamp.opengl does not exist". I have added the .JAR files to my project's reference libraries as shown:



My code reads:

import javax.swing.*;
import static com.jogamp.opengl.GL4.*;
import com.jogamp.opengl.*;
import com.jogamp.opengl.awt.GLCanvas;

public class Code extends JFrame implements GLEventListener {
private GLCanvas myCanvas;

public Code() {
    setTitle("Chapter 2 - program 1");
    setSize(600, 400);
    setLocation(200, 200);
    myCanvas = new GLCanvas();
    myCanvas.addGLEventListener(this);
    this.add(myCanvas);
    this.setVisible(true);
}

public void display(GLAutoDrawable drawable) {
    GL4 gl = (GL4) GLContext.getCurrentGL();
    gl.glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
    gl.glClear(GL_COLOR_BUFFER_BIT);
}

public static void main(String[] args) {
    new Code();
}

public void init(GLAutoDrawable drawable) {
}

public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
}

public void dispose(GLAutoDrawable drawable) {
}
}

Any advice would be great - I'm guessing it is some simple step I've missed, but I've gone over the section in the book a couple of times now so I'm nto sure what I'm missing.
Reply | Threaded
Open this post in threaded view
|

Re: Getting up and running with Visual Studio Code and JOGL

gouessej
Administrator
Hello

Please can you indicate which version of JOGL you use? Where did you find the two JARs you use?
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Getting up and running with Visual Studio Code and JOGL

EatingBeansAgain
Hi! Sorry, here are those details:

-I am using version 2.3.2.

-I got the .jars from the jogamp-all-platforms.7z from here: https://jogamp.org/deployment/jogamp-current/archive/

Reply | Threaded
Open this post in threaded view
|

Re: Getting up and running with Visual Studio Code and JOGL

gouessej
Administrator
I'm really surprised, it should work. I'm sad to suggest that but please try to compile and run your example without VisualStudio Code in order to determine whether the problem comes from this integrated development environment or something else:
https://jogamp.org/wiki/index.php?title=Setting_up_a_JogAmp_project_in_your_favorite_IDE#Compile_and_run_your_project_from_the_command_line
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Getting up and running with Visual Studio Code and JOGL

gouessej
Administrator
In reply to this post by EatingBeansAgain
Which version of VisualStudio Code do you use? Maybe you're concerned by this problem:
https://stackoverflow.com/questions/50232557/visual-studio-code-java-extension-howto-add-jar-to-classpath

P.S: The feature "Referenced Libraries" seems to be still broken on some platforms. In my humble opinion, don't waste your time with this IDE if you really want to learn Java.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Getting up and running with Visual Studio Code and JOGL

EatingBeansAgain
Thanks for the help! I was able to compile the code in command line, but when running it I still got the same error. I've been using Visual Studio Code 1.6.

I might just start again with a different IDE, a lot of things I've read seem to state VSC isn't really a goer for Java.
Reply | Threaded
Open this post in threaded view
|

Re: Getting up and running with Visual Studio Code and JOGL

gouessej
Administrator
Please tell me exactly which command line you use, we're probably missing something simple. Sorry for the dummy check but look at the content of your JARs just in case you still use an older version by mistake.
Julien Gouesse | Personal blog | Website