问题描述
我的SSCE是:
public static void main(final String[] args) throws IOException {
try {
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
int bitdepth = 10;
GLProfile.initSingleton();
GLProfile glProfile = GLProfile.getDefault();
GLCapabilities glCapabilities = new GLCapabilities( glProfile );
glCapabilities.setBlueBits(bitdepth);
glCapabilities.setGreenBits(bitdepth);
glCapabilities.setRedBits(bitdepth);
glCapabilities.setAlphaBits(2);
glCapabilities.setDoubleBuffered(true);
glCapabilities.setHardwareAccelerated(true);
glCapabilities.setNumSamples(4);
glCapabilities.setBackgroundOpaque(false);
glCapabilities.setSampleBuffers(true);
GraphicsConfiguration gc = getSomeGC();
JFrame jf = new JFrame(gc);
jf.setExtendedState(JFrame.MAXIMIZED_BOTH);
GLCanvas canvas = new GLCanvas(glCapabilities);
canvas.addGLEventListener(new GLEventListener() {
@Override
public void reshape(GLAutoDrawable arg0, int arg1, int arg2, int arg3,
int arg4) {
// TODO Auto-generated method stub
}
@Override
public void init(GLAutoDrawable arg0) {
// TODO Auto-generated method stub
}
@Override
public void dispose(GLAutoDrawable arg0) {
// TODO Auto-generated method stub
}
@Override
public void display(GLAutoDrawable drawable) {
System.out.println("Painting");
BufferedImage image = null;
try {
image = ImageIO.read(new File("img.tiff"));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(image!=null){
GL2 gl2 = drawable.getGL().getGL2();
//gl2.glClear(GL.GL_COLOR_BUFFER_BIT);
int format = GL.GL_LUMINANCE;
int type = GL.GL_UNSIGNED_SHORT;
DataBufferUShort db = (DataBufferUShort) image.getRaster().getDataBuffer();
short[] shorts = db.getData(0);
Buffer buffer = ShortBuffer.wrap(shorts);
//gl2.glViewport(0, 0, image.getWidth(), image.getHeight());
gl2.glDrawPixels(image.getWidth(), image.getHeight(), format , type, buffer );
}
}
});
JPanel jp = new JPanel();
jp.setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.fill = GridBagConstraints.BOTH;
gbc.gridx=0;
gbc.gridy=0;
gbc.gridwidth=1;
gbc.gridheight=1;
gbc.weightx=1;
gbc.weighty=1;
gbc.anchor= GridBagConstraints.CENTER;
jp.add(canvas,gbc);
JScrollPane jsp = new JScrollPane();
jsp.getViewport().add(jp);
JLayeredPane jlp = new JLayeredPane();
jlp.setLayout(new GridBagLayout());
jlp.add(jsp, gbc);
//jsp.getViewport().add(dsc);
gbc = new GridBagConstraints();
gbc.gridx=0;
gbc.gridy=0;
gbc.gridwidth=1;
gbc.gridheight=1;
gbc.weightx=1;
gbc.weighty=1;
gbc.fill=GridBagConstraints.BOTH;
gbc.anchor= GridBagConstraints.CENTER;
jf.getContentPane().setLayout(new GridBagLayout());
jf.getContentPane().add(jlp,gbc);
jf.setVisible(true);
}
});
} catch (InvocationTargetException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
我在GLJPanel上为GLCanvas得到了两种不同的显示.我试图在具有10位灰度的监视器上获得10位显示.
I get two different displays for GLCanvas over GLJPanel. I trying to get 10 bit display on a monitor capable of 10bit grayscale.
GLJPanel使用8位,而GLCanvas引发异常,但我相信10位可以正确显示.
The GLJPanel is in 8 bit while the GLCanvas throws an exception but is I believe displayed correctly at 10 bit.
Exception in thread "AWT-EventQueue-0" javax.media.opengl.GLException: Error making context 0x20000 current on Thread AWT-EventQueue-0, drawableWrite 0x42011b9a, drawableRead 0x42011b9a, werr: 0, WindowsWGLContext [Version 4.2 (Compat profile, arb, ES2 compat, ES3 compat, FBO, hardware) - 4.2.12327 Compatibility Profile Context FireGL 12.104.2.3000 [GL 4.2.0, vendor 12.104.2 (Compatibility Profile Context FireGL 12.104.2.3000)], options 0x1c03, this 0x263ce8f2, handle 0x20000, isShared false, jogamp.opengl.gl4.GL4bcImpl@633cca0,
quirks: [NoDoubleBufferedBitmap],
Drawable: WindowsOnscreenWGLDrawable[Realized true,
Factory jogamp.opengl.windows.wgl.WindowsWGLDrawableFactory@5dba26,
Handle 0x42011b9a,
推荐答案
由于这是一个jogl错误报告,请在 https://jogamp.org/bugzilla/不要忘记附加源代码和img.tiff
Since this is a jogl bugreport please post the complete compilable SSCE with all includes into a bugreport at https://jogamp.org/bugzilla/don't forget to attach the source code and the img.tiff
从技术上来说,您正在报告两个错误,因此您应该提交两个错误:
You are technically reporting two bugs thus you should file two bugs:
错误一:我们需要更多地了解您的用例,以及在使用GLCanvas和GLJPanel时在两个图像中看到的差异.
bug one:We need to know more about your use-case and what kind of differences you see in the two images when using a GLCanvas and GLJPanel.
错误二:我们需要GLException的复制器:在线程上使上下文0x20000当前为错误
bug two:We need a reproducer for the GLException: Error making context 0x20000 current on Thread
有关更多详细信息,请阅读JOGL Bugreports&测试常见问题解答: http://jogamp.org/wiki/index.php/Jogl_FAQ#Bugreports_.26_Testing
For more details read the JOGL Bugreports & Testing FAQ:http://jogamp.org/wiki/index.php/Jogl_FAQ#Bugreports_.26_Testing
这篇关于GLCanvas和GLJPanel产生不同的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!