Jump to content
  • Advertisement
Sign in to follow this  
BluePhenix

[java] JOGL Causes EXCEPTION_ACCESS_VIOLATION

This topic is 3778 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am writing a small game in java and started coded a FBO class. When I tested it the following appeared in my console
Quote:
# # An unexpected error has been detected by Java Runtime Environment: # # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6959e29b, pid=1872, tid=3616 # # Java VM: Java HotSpot(TM) Client VM (10.0-b22 mixed mode, sharing windows-x86) # Problematic frame: # C [nvoglv32.dll+0x9e29b] # # An error report file with more information is saved as: # J:\Programming\Java\Game Workspace\Game\hs_err_pid1872.log # # If you would like to submit a bug report, please visit: # http://java.sun.com/webapps/bugreport/crash.jsp # The crash happened outside the Java Virtual Machine in native code. # See problematic frame for where to report the bug. #
Using the following code:
		//Get the openGL object (with context!)
		GL gl = GraphicsManager.getGL();
		
		//Create a valid handle to manage the frame buffer
		//this.intBuffer = IntBuffer.allocate(1);
		//gl.glGenFramebuffersEXT(1, this.intBuffer);
		gl.glGenFramebuffersEXT(1, ints, 0);
		this.fbo = ints[0]; 
		//this.fbo = this.intBuffer.get(0);
		
		//Bind the FBO
		gl.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, this.fbo);
		
		//Create a depth buffer
		//this.intBuffer = IntBuffer.allocate(1);
		gl.glGenRenderbuffersEXT(1, ints, 1); //this.intBuffer);
		this.depthBuffer = ints[1];
		//this.depthBuffer = this.intBuffer.get(0);
		
		//Bind the render buffer
		gl.glBindRenderbufferEXT(GL.GL_RENDERBUFFER_EXT, this.depthBuffer);
		
		//Tell openGL how much storeage space we want for the render buffer
		gl.glRenderbufferStorageEXT(GL.GL_RENDERBUFFER_EXT, GL.GL_DEPTH_COMPONENT, width, height);
		
		//Now attach the render buffer to the FBO we created
		gl.glFramebufferRenderbufferEXT(GL.GL_FRAMEBUFFER_EXT, GL.GL_DEPTH_ATTACHMENT_EXT, GL.GL_RENDERBUFFER_EXT, this.depthBuffer);
		
		//Create a texture handle
		//this.intBuffer = IntBuffer.allocate(1);
		gl.glGenTextures(1, ints, 2); //this.intBuffer);
		this.color_texture = ints[2];
		//this.color_texture = this.intBuffer.get(0);
		
		//Bind the handle as a 2D texture
		gl.glBindTexture(GL.GL_TEXTURE_2D, this.color_texture);
		
		//Set texture parameters
		gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR);
		gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR);
		gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_CLAMP_TO_EDGE);
		gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_CLAMP_TO_EDGE);

		//Create a image of the same width and height as the render buffer
		gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGBA8, width, height, 0, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, null);
		
		//Attach the colour texture to the FBO
		gl.glFramebufferTexture2DEXT(GL.GL_FRAMEBUFFER_EXT, GL.GL_COLOR_ATTACHMENT0_EXT, GL.GL_TEXTURE_2D, this.color_texture, 0);
		
		
		int status = gl.glCheckFramebufferStatusEXT(GL.GL_FRAMEBUFFER_EXT);
		
		this.active = true;
		
		if (status != GL.GL_FRAMEBUFFER_COMPLETE_EXT)
			throw new Exception("FBO Creation Error");
		//Get the openGL object (with context!)
		GL gl = GraphicsManager.getGL();
		
		//Create a valid handle to manage the frame buffer
		//this.intBuffer = IntBuffer.allocate(1);
		//gl.glGenFramebuffersEXT(1, this.intBuffer);
		gl.glGenFramebuffersEXT(1, ints, 0);
		this.fbo = ints[0]; 
		//this.fbo = this.intBuffer.get(0);
		
		//Bind the FBO
		gl.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, this.fbo);
		
		//Create a depth buffer
		//this.intBuffer = IntBuffer.allocate(1);
		gl.glGenRenderbuffersEXT(1, ints, 1); //this.intBuffer);
		this.depthBuffer = ints[1];
		//this.depthBuffer = this.intBuffer.get(0);
		
		//Bind the render buffer
		gl.glBindRenderbufferEXT(GL.GL_RENDERBUFFER_EXT, this.depthBuffer);
		
		//Tell openGL how much storeage space we want for the render buffer
		gl.glRenderbufferStorageEXT(GL.GL_RENDERBUFFER_EXT, GL.GL_DEPTH_COMPONENT, width, height);
		
		//Now attach the render buffer to the FBO we created
		gl.glFramebufferRenderbufferEXT(GL.GL_FRAMEBUFFER_EXT, GL.GL_DEPTH_ATTACHMENT_EXT, GL.GL_RENDERBUFFER_EXT, this.depthBuffer);
		
		//Create a texture handle
		//this.intBuffer = IntBuffer.allocate(1);
		gl.glGenTextures(1, ints, 2); //this.intBuffer);
		this.color_texture = ints[2];
		//this.color_texture = this.intBuffer.get(0);
		
		//Bind the handle as a 2D texture
		gl.glBindTexture(GL.GL_TEXTURE_2D, this.color_texture);
		
		//Set texture parameters
		gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR);
		gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR);
		gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_CLAMP_TO_EDGE);
		gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_CLAMP_TO_EDGE);

		//Create a image of the same width and height as the render buffer
		gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGBA8, width, height, 0, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, null);
		
		//Attach the colour texture to the FBO
		gl.glFramebufferTexture2DEXT(GL.GL_FRAMEBUFFER_EXT, GL.GL_COLOR_ATTACHMENT0_EXT, GL.GL_TEXTURE_2D, this.color_texture, 0);
		
		
		int status = gl.glCheckFramebufferStatusEXT(GL.GL_FRAMEBUFFER_EXT);
		
		this.active = true;
		
		if (status != GL.GL_FRAMEBUFFER_COMPLETE_EXT)
			throw new Exception("FBO Creation Error");

I have narrowed the line of code which caused the error to the third line; gl.glGenFramebuffersEXT(1, ints, 0); I have a game logic thread running as well as a render thread. When I do not run the game logic thread the FBO is created without an issue. However stopping my logic thread to create FBO's when I need them doesnt really lend itself to good game play. The logic thread does no interact with the FBO class in any way so I am at a lost of why it is happening. Does anybody have a solution with does not involve either pausing my logic thread or creating all fbo's at engine startup?

Share this post


Link to post
Share on other sites
Advertisement
This is definitely something you'd want to ask the JOGL devs about. JVM crashes are *always* bad and never should be worked around.

Share this post


Link to post
Share on other sites
Quote:
This is definitely something you'd want to ask the JOGL devs about. JVM crashes are *always* bad and never should be worked around.
Actually it might be best to isolate the JOGL call that causes the exception then check the OpenGL documentation for the offending function. You might actually be doing something illegal.

From a performance point of view, it's better just to let these things crash the JVM, because the alternative is testing for and catching these errors on the native side and propogating them to Java exceptions, which would slow down your program too much.

Also, have you tried testing this against LWJGL?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!