Canvas3D

最近在做一些有关于java3D方面的东东。
突然有个想法把Java3D 的场景保存成图片来。可是在保存的过程中出现了点问题。

javax.media.j3d.IllegalRenderingStateException: GL_VERSION
	at javax.media.j3d.NativePipeline.createNewContext(Native Method)
	at javax.media.j3d.NativePipeline.createNewContext(NativePipeline.java:2736)
	at javax.media.j3d.Canvas3D.createNewContext(Canvas3D.java:4895)
	at javax.media.j3d.Canvas3D.createNewContext(Canvas3D.java:2421)
	at javax.media.j3d.Renderer.doWork(Renderer.java:895)
	at javax.media.j3d.J3dThread.run(J3dThread.java:256)
Rendered to offscreen

DefaultRenderingErrorListener.errorOccurred:
CONTEXT_CREATION_ERROR: Renderer: Error creating Canvas3D graphics context
graphicsDevice = Win32GraphicsDevice[screen=0]
canvas = javax.media.j3d.Canvas3D[canvas0,0,0,400x400,invalid]
Saved image.
Java 3D ERROR : OpenGL 1.2 or better is required (GL_VERSION=1.1)


程序代码的:
 protected void onSaveImage() {
	 System.out.println("application stop this !!!");
   offScreenCanvas3D.renderOffScreenBuffer();
   offScreenCanvas3D.waitForOffScreenRendering();
   System.out.println("Rendered to offscreen");

   try {
     FileOutputStream fileOut = new FileOutputStream("C:\\image.jpg");

     JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(fileOut);
     encoder.encode(imageComponent.getImage());

     fileOut.flush();
     fileOut.close();
   } catch (Exception e) {
     System.err.println("Failed to save image: " + e);
   }


这是程序代码的片段:

你可能感兴趣的:(java,qq)