Re: JVM crash
Posted by Warkst on Jul 01, 2017; 1:25pm
URL: https://forum.jogamp.org/JVM-crash-tp4038046p4038049.html
I think I found the problem... the code calling the GL libraries was running on the wrong thread (I think?). I started adding glGetError after every possible call to figure out where it went wrong and I noticed that every call on the keypress callback resulted in error 1282. Literally the first line of code in the callback was glGetError and it returned 1282, and a new call right after it also returned 1282 even though the flag should have been reset. So i figured maybe the problem was that I was not allowed to make gl calls from whatever thread the keypress callback runs on... so in the keypress callback I now generate data and copy it to a float array, and set a boolean to true. In the render loop I test to see if the boolean is true. If it is, i replace my VBO's data with the new data and everything works peachy. To verify my suspicions I printed Thread.currentThread().toString() in the keypress callback and in the display method and indeed, these are different threads: the display thread is "Thread[main-AWTAnimator#00,5,main]" and the keypress one is "Thread[main-Display-.windows_nil-1-EDT-1,5,main]" (note I am now working at this from home where I use a windows10 machine instead of a macbook, which is why it says windows and not macos like I stated in my original post). I've started looking this up and indeed, only one thread can have the OpenGL context as "current", so all gl operations must happen in the 4 callbacks from GLEventListener.