欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Canvas3D

程序员文章站 2022-07-14 10:05:45
...
最近在做一些有关于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

推荐阅读