当我渲染到FBO并将此FBO blit到窗口并且窗口被最小化时,Java会抛出EXCEPTION_ACCESS_VIOLATION异常。
这是我的屏幕和我的理解,它做什么的代码。
GL30.glBindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, 0); //Bind the draw framebuffer to the default (0)
GL30.glBindFramebuffer(GL30.GL_READ_FRAMEBUFFER, frameBufferID); //Bind the read framebuffer to the fbo id
GL11.glDrawBuffer(GL11.GL_BACK); //Setting the draw buffer to the screen
GL11.glReadBuffer(GL30.GL_COLOR_ATTACHMENT0); //Settiing the read buffer to the color attachment of the fbo
if(GL30.glCheckFramebufferStatus(GL30.GL_FRAMEBUFFER) == GL30.GL_FRAMEBUFFER_COMPLETE) //Checking if the framebuffer is complete
{
GL30.glBlitFramebuffer(0, 0, fboWidth, fboHeight, 0, 0, windowWidth, windowHeight, GL11.GL_COLOR_BUFFER_BIT, GL11.GL_NEAREST); //Blitting the frambuffer to the screen
}
GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, 0); //Unbinding the framebuffer
为防止崩溃,我添加了一项检查以检查窗口是否已最小化
if(isWindowIconified) return; //check if window is minimized
GL30.glBindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, 0); //Bind the draw framebuffer to the default (0)
GL30.glBindFramebuffer(GL30.GL_READ_FRAMEBUFFER, frameBufferID); //Bind the read framebuffer to the fbo
GL11.glDrawBuffer(GL11.GL_BACK); //Setting the draw buffer to the screen
GL11.glReadBuffer(GL30.GL_COLOR_ATTACHMENT0); //Settiing the read buffer to the color attachment of the fbo
if(GL30.glCheckFramebufferStatus(GL30.GL_FRAMEBUFFER) == GL30.GL_FRAMEBUFFER_COMPLETE) //Checking if the framebuffer is complete
{
GL30.glBlitFramebuffer(0, 0, fboWidth, fboHeight, 0, 0, windowWidth, windowHeight, GL11.GL_COLOR_BUFFER_BIT, GL11.GL_NEAREST); //Blitting the frambuffer to the screen
}
GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, 0); //Unbinding the framebuffer
我在初始化窗口时也添加了这段代码
//Setting the window minimisazion callback
glfwSetWindowIconifyCallback(window, new GLFWWindowIconifyCallbackI() {
@Override
public void invoke(long window, boolean iconified) {
isWindowIconified = iconified;
}
});
现在程序在我最小化时不会崩溃,但当我按Windows + D进入桌面时程序仍然崩溃。
现在我的问题: 什么是防止崩溃的最佳方法? 为什么会这样?
文件:
系统信息:
操作系统:Windows 10 Home,版本10.0.15063
GPU:英特尔高清显卡520
驱动程序版本:20.19.15.4642
OpenGL版本:4.4
答案 0 :(得分:0)
如果Java抛出EXCEPTION_ACCESS_VIOLATION异常并且它发生在ig9icd64.dll中,可能是因为您使用了旧的Intel GPU驱动程序。在这种情况下,这似乎是问题所在,因为当我使用我的NVIDIA GPU启动程序时它并没有发生,并且在我更新我的英特尔GPU驱动程序后它并没有崩溃。
如果您不确定错误发生的位置,请查看"原生帧:"和#34; Java框架:"在崩溃报告中。最上面一行显示错误发生的位置。