Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (533)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  [Bug] gl.glGenFramebuffersEXT Causes JVM Crash  (Read 1739 times)
0 Members and 1 Guest are viewing this topic.
Offline Phenix

Junior Newbie





« Posted 2008-06-12 22:00:34 »

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 (The code is called from the display method of my Canvas - so the thread has got context):
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
      //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?
Offline GKW

Senior Member




Revenge is mine!


« Reply #1 - Posted 2008-06-13 16:49:28 »

Does your logic thread access the "ints" variable?  Possibly the logic thread is uninitializing that variable?  There's not much that can go wrong with that method.
Offline Phenix

Junior Newbie





« Reply #2 - Posted 2008-06-14 00:42:46 »

No, at no point does the logic thread even access the FBO class
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline GKW

Senior Member




Revenge is mine!


« Reply #3 - Posted 2008-06-14 08:23:08 »

So you are sure that the "ints" variable is created, initialized and is never modified by the logic thread?  Does the logic thread make any GL calls at all?  That's just a little odd that the code works when the logic thread is paused but doesn't work when it's running, assuming that it doesn't alter the "ints" variable in anyway.
Offline lhkbob

JGO Knight


Medals: 32



« Reply #4 - Posted 2008-06-15 04:14:15 »

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.

I'm pretty sure you can keep fbo's around for a while instead of creating a new one whenever you need it.  Perhaps it's better to initialize them once in the beginning -- where you can stop the logic thread -- and reuse any fbo id's later on for effects.

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

pw (26 views)
2014-07-24 01:59:36

Riven (25 views)
2014-07-23 21:16:32

Riven (20 views)
2014-07-23 21:07:15

Riven (22 views)
2014-07-23 20:56:16

ctomni231 (51 views)
2014-07-18 06:55:21

Zero Volt (46 views)
2014-07-17 23:47:54

danieldean (37 views)
2014-07-17 23:41:23

MustardPeter (40 views)
2014-07-16 23:30:00

Cero (56 views)
2014-07-16 00:42:17

Riven (55 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!