Teaching myself

I have found a website that i am going to start learning java 3D from

currently I have this to create a scene graph and empty space

import javax.media.j3d.*;

import javax.swing.JFrame;

import java.awt.*;

publicclass Testextends JFrame

{

Test()

{

setSize(400, 300);

Canvas3D canvas =new Canvas3D(null);

add(canvas);

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

setVisible(true);

View myView = constructView(canvas);

Locale myLocale = constructViewBranch(myView);

constructContentBranch(myLocale);

}

private View constructView(Canvas3D myCanvas3D)

{

View myView =new View();

myView.addCanvas3D(myCanvas3D);

myView.setPhysicalBody(new PhysicalBody());

myView.setPhysicalEnvironment(new PhysicalEnvironment());

return myView;

}

private Locale constructViewBranch(View myView)

{

VirtualUniverse myUniverse =new VirtualUniverse();

Locale myLocale =new Locale(myUniverse);

BranchGroup myBranchGroup =new BranchGroup();

TransformGroup myTransformGroup =new TransformGroup();

ViewPlatform myViewPlatform =new ViewPlatform();

myTransformGroup.addChild(myViewPlatform);

myBranchGroup.addChild(myTransformGroup);

myLocale.addBranchGraph(myBranchGroup);

myView.attachViewPlatform(myViewPlatform);

return myLocale;

}

privatevoid constructContentBranch(Locale myLocale)

{

}

publicstaticvoid main(String args[])

{

new Test();

}

}

it compiles but i get the folling error when running

Exception in thread"main" java.lang.NullPointerException: Canvas3D:null Graphi

csConfiguration

at javax.media.j3d.Canvas3D.checkForValidGraphicsConfig(Canvas3D.java:95

4)

at javax.media.j3d.Canvas3D.<init>(Canvas3D.java:997)

at Test.<init>(Test.java:13)

at Test.main(Test.java:57)

any ideas as to why?

[3302 byte] By [Drogo_Nevetsa] at [2007-11-27 0:50:31]
# 1

Read what the error message says. You haven't passed a graphics configuration to the Canvas3D, which you need to do. Alter your code like so:

Test() {

...

GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();

Canvas3D canvas = new Canvas3D(config);

...

}

That should work out fine.

Message was edited by:

mokopa

mokopaa at 2007-7-11 23:20:38 > top of Java-index,Security,Cryptography...
# 2

er kinda worked - i now get

Java 3D ERROR : wglGetExtensionsStringARB not support !

- The specified procedure could not be found.

Fallback to use standard ChoosePixelFormat.

Java 3D ERROR : OpenGL 1.2 or better is required (GL_VERSION=1.1)

javax.media.j3d.IllegalRenderingStateException: GL_VERSION

at javax.media.j3d.NativePipeline.createNewContext(Native Method)

at javax.media.j3d.NativePipeline.createNewContext(NativePipeline.java:2

681)

at javax.media.j3d.Canvas3D.createNewContext(Canvas3D.java:4823)

at javax.media.j3d.Canvas3D.createNewContext(Canvas3D.java:2372)

at javax.media.j3d.Renderer.doWork(Renderer.java:876)

at javax.media.j3d.J3dThread.run(J3dThread.java:256)

DefaultRenderingErrorListener.errorOccurred:

CONTEXT_CREATION_ERROR: Renderer: Error creating Canvas3D graphics context

graphicsDevice = Win32GraphicsDevice[screen=0]

canvas = javax.media.j3d.Canvas3D[canvas0,0,0,392x273]

lol, im guessing the site im using may not be the best - can anyone suggest a different one?

Drogo_Nevetsa at 2007-7-11 23:20:38 > top of Java-index,Security,Cryptography...
# 3

Again, read the error message.

You need OpenGL v 1.2, you have OpenGL v 1.1

I've tested the code and it works on my machine.

The best, sorry, the only solution for this is to download and install the latest drivers for your graphics card. If you have an older Matrox card (440 range if not mistaken), forget it, the card does not support v1.2. There are a number of older cards (mid to late 90's) that also do not support OpenGL v1.2, so hopefully you're not in possession of such a card.

If however that's the case, there are plenty of newer cards that you could pick up second-hand that will cost you virtually nothing. Unfortunately, if you can't find a driver for your current hardware, you'll not be able to continue. I wouldn't recommend that you install an earlier version of Java3D because of issues which only got addressed in later releases.

mokopaa at 2007-7-11 23:20:38 > top of Java-index,Security,Cryptography...
# 4

Hello,

Here is my my code and I get the same trouble :

import java.awt.*;

import java.swing.*;

import java.media.j3d.*;

import java.vecmath.*;

import com.sun.j3d.utils.geometry.ColorCube;

public class Test extends JFrame {

public Test() {

VirtualUniverse u = new VirtualUniverse();

Locale L = new Locale();

Canvas3D c = new Canvas3D(null);

.....

}

} // end of class

I get a NullPointerException too.

Should I always use a SimpleUniverse object ?

Thanks,

Marie

oredon2a at 2007-7-11 23:20:38 > top of Java-index,Security,Cryptography...
# 5
You pass null to Canvas3D. Exactly what do you expect canvas3D to do with that null object?If I give you NO MONEY, and I tell you to go to the shop and buy some stuff, you will ALSO throw and exception, right? You will complain about the NULL dollars I gave you.
mokopaa at 2007-7-11 23:20:38 > top of Java-index,Security,Cryptography...
# 6
I solved my problem using a SimpleUniverse Object and getPreferredConfiguration method.Marie
oredon2a at 2007-7-11 23:20:38 > top of Java-index,Security,Cryptography...