Sign in to follow this  
PorkBag

[java] Initializing java3D

Recommended Posts

Java3D won't start, I get a "wglCreateContext failed: Invalid Pixel format" error. I'm guessing that this is because the bitdepth of the GraphicsConfiguration object is 24, which for whatever reason my system can't handle. From what I understand getConfigurations() is supposed to return all possible configurations, but they all have the same bitdepth of 24. This is the code:
		GraphicsConfiguration Config2=SimpleUniverse.getPreferredConfiguration ();
		GraphicsEnvironment gf = GraphicsEnvironment.getLocalGraphicsEnvironment();
		GraphicsDevice Device=gf.getDefaultScreenDevice();
		GraphicsConfiguration []Configs=Device.getConfigurations ();
		
		System.out.println (Configs.length);
		//print out configurations
		for (int X=0; X<Configs.length; X++)
		{
			ColorModel Temp=Configs[X].getColorModel ();
			System.out.println ("Bit Depth: " + Temp.getPixelSize() + "  Channels: " + Temp.getNumComponents());
		}
		
		Canvas3D Screen = new Canvas3D (Config2);
		Universe = new SimpleUniverse (Screen);
		
		setLayout (new BorderLayout ());
		add (Screen, BorderLayout.CENTER);

There isn't a setBitdepth() function that I can find, so I don't know how to create a Config with a different bitdepth, or is that not the problem in the first place? thanks,

Share this post


Link to post
Share on other sites

i tested the code above (modifying some tiny details) and it worked fine here. I'm using the openGL version of J3D and also have a bitdepth of 24 for every configuration, however it works fine.
Maybe your drivers aren't up to date, is it possible?
...else, i've no clue.

Share this post


Link to post
Share on other sites
Looks like it works if I get rid of the opengl version and install the directx version instead. I just installed all the latest drivers (before that I got even ickier errors) and I don't get why it wouldn't work for opengl, but whatever. One question though, is code made with the java's directx SDK still going to be system independent and whatnot?

Share this post


Link to post
Share on other sites
Quote:
Original post by PorkBag
One question though, is code made with the java's directx SDK still going to be system independent and whatnot?

Yes and no.

API-wise, you use a single interface so your code is the same. However there are differences based on which version the user actually installs. There may be feature differences (such as the DX version not supporting thick lines, which the GL version does) or performance quirks (what runs fast on your machine with one version does not nessisarity run fast on someone elses with a different version).

IMHO, if you use something slightly lower level like LWJGL you get identical behaviour across all platforms (and more flexibility and performance as an added bonus).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this