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?
# 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?
# 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.