We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOpenGL and 3D Libraries › Cannot import net.java.games.jogl
Page Index Toggle Pages: 1
Cannot import net.java.games.jogl (Read 3678 times)
Cannot import net.java.games.jogl
Sep 18th, 2006, 12:02pm
 
Hi,

I've tried to run the examples pasted in this section, but I aways get an error for "Jikes cannot find the package "net.java.games.jogl".

And actually what does the line "import javax.xxx.xxxxx." and "import net.xxxx" means?

Thank you!
Re: Cannot import net.java.games.jogl
Reply #1 - Sep 18th, 2006, 1:48pm
 
that's part of jogl, which is included when you use import library -> opengl. however, that syntax is from outdated code, and that won't work with newer processing releases.
Re: Cannot import net.java.games.jogl
Reply #2 - Sep 18th, 2006, 4:03pm
 
I've deleted that import line, however when I tried this line "GL gl = ((PGraphicsGL)g).gl;", an error "Type GL is not found"is shown.
Re: Cannot import net.java.games.jogl
Reply #3 - Sep 18th, 2006, 4:43pm
 
You need to change "import net.java.games.jogl.*" to "import javax.media.opengl.*" to get old code to work.
Re: Cannot import net.java.games.jogl
Reply #4 - Sep 18th, 2006, 5:11pm
 
I've tried to import the "javax.media.opengl.*;", the error is  "java.lang.NullPointerException" for "GL gl = ((PGraphicsGL)g).gl;"

What is it about the new and old library? And when I write the line import javax.media.opengl.*, where is the library located? Because I don't know about the external import method, I thought all library should be included in the processing/library, or there is something else?

What is the meaning of "new code" and "old code" as describe in the previous posts? I'm really new on java and processing, thank you for you guys response.
Re: Cannot import net.java.games.jogl
Reply #5 - Sep 18th, 2006, 6:16pm
 
The "new" and "old" part refers to the OpenGL library that processing uses.

Could you paste all of your code, to make it easier to see what could be causing the problem?
Re: Cannot import net.java.games.jogl
Reply #6 - Sep 18th, 2006, 6:35pm
 
Yes ofcoz, I should have do it earlier...

Actually all I want to do is to conver the function I written in opengl into processing

void point3d(float x, float y, float z, int colorR, int colorG, int colorB)
{
glBegin(GL_POINTS);
glColor3ub(colorR, colorG, colorB);
glVertex3f(x, y, z);
glEnd();
}

So what I did is

import javax.media.opengl.*
GL gl = ((PGraphicsGL)g).gl;

void point3d(float x, float y, float z, int colorR, int colorG, int colorB)
{
gl.glBegin(gl.GL_POINTS);
gl.glColor3ub(colorR, colorG, colorB);
gl.glVertex3f(x, y, z);
gl.glEnd();
}

It seems the glColor3ub doesn't work, so I commented it out, and then I got a NullPointerException..


Re: Cannot import net.java.games.jogl
Reply #7 - Sep 18th, 2006, 7:03pm
 
This may not be the answer you are looking for, but if you are going to use Processing, you might as well do it the Processing way. . .

Code:

beginShape(POINTS);
fill(r,g,b);
vertex(x,y,z);
endShape();


if you want openGL rendering, select OPENGL mode (and import the openGL library):

Code:

size(200,200,OPENGL);

Re: Cannot import net.java.games.jogl
Reply #8 - Sep 18th, 2006, 8:57pm
 
hamletbon wrote on Sep 18th, 2006, 6:35pm:
Code:
import javax.media.opengl.*;

GL gl = ((PGraphicsGL)g).gl;



the NullPointerExcption is caused by the fact that you try to get the reference to the OpenGL context, before processing has actually initialized it. try the following:

Code:
import javax.media.opengl.*;

GL gl;

void setup() {
size(200, 200, OPENGL);
gl = ((PGraphicsGL)g).gl;
}

void draw() {
// do opengl stuff here.
}

Page Index Toggle Pages: 1