Can't Run Project in Eclipse on Mac

Started by Firal, July 15, 2015, 05:08:14

Previous topic - Next topic

Firal

Hello everyone, I have searched all over Google looking for another instance of this problem and I can't seem to find one. I am trying to learn LWJGL 3 to use in GameJolt's upcoming Indies vs. Gamers Game Jam because of its cross-platform features. However, when I try to run the small sample project I made after setting the -XstartOnFirstThread flag, I get these Exceptions: (I am running Yosemite)

2015-07-14 22:03:04.865 java[673:52709] *** Assertion failure in +[NSUndoManager _endTopLevelGroupings], /SourceCache/Foundation/Foundation-1153.20/Misc.subproj/NSUndoManager.m:340
2015-07-14 22:03:04.865 java[673:52709] +[NSUndoManager(NSInternal) _endTopLevelGroupings] is only safe to invoke on the main thread.
2015-07-14 22:03:04.866 java[673:52709] (
   0   CoreFoundation                      0x00007fff8facd03c __exceptionPreprocess + 172
   1   libobjc.A.dylib                     0x00007fff8d24576e objc_exception_throw + 43
   2   CoreFoundation                      0x00007fff8facce1a +[NSException raise:format:arguments:] + 106
   3   Foundation                          0x00007fff8f42b8cb -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195
   4   Foundation                          0x00007fff8f3ad57f +[NSUndoManager(NSPrivate) _endTopLevelGroupings] + 156
   5   AppKit                              0x00007fff9751eb95 -[NSApplication run] + 756
   6   liblwjgl.dylib                      0x0000000121a9ca2e _glfwPlatformCreateWindow + 1406
   7   liblwjgl.dylib                      0x0000000121a98d9b glfwCreateWindow + 443
   8   ???                                 0x0000000110665698 0x0 + 4570109592
   9   ???                                 0x0000000110659175 0x0 + 4570059125
   10  ???                                 0x0000000110659175 0x0 + 4570059125
   11  ???                                 0x0000000110659058 0x0 + 4570058840
   12  ???                                 0x0000000110659706 0x0 + 4570060550
)
2015-07-14 22:03:04.866 java[673:52709] *** Assertion failure in +[NSUndoManager _endTopLevelGroupings], /SourceCache/Foundation/Foundation-1153.20/Misc.subproj/NSUndoManager.m:340
2015-07-14 22:03:04.866 java[673:52709] An uncaught exception was raised
2015-07-14 22:03:04.867 java[673:52709] +[NSUndoManager(NSInternal) _endTopLevelGroupings] is only safe to invoke on the main thread.
2015-07-14 22:03:04.867 java[673:52709] (
   0   CoreFoundation                      0x00007fff8facd03c __exceptionPreprocess + 172
   1   libobjc.A.dylib                     0x00007fff8d24576e objc_exception_throw + 43
   2   CoreFoundation                      0x00007fff8facce1a +[NSException raise:format:arguments:] + 106
   3   Foundation                          0x00007fff8f42b8cb -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195
   4   Foundation                          0x00007fff8f3ad57f +[NSUndoManager(NSPrivate) _endTopLevelGroupings] + 156
   5   AppKit                              0x00007fff9751ec41 -[NSApplication run] + 928
   6   liblwjgl.dylib                      0x0000000121a9ca2e _glfwPlatformCreateWindow + 1406
   7   liblwjgl.dylib                      0x0000000121a98d9b glfwCreateWindow + 443
   8   ???                                 0x0000000110665698 0x0 + 4570109592
   9   ???                                 0x0000000110659175 0x0 + 4570059125
   10  ???                                 0x0000000110659175 0x0 + 4570059125
   11  ???                                 0x0000000110659058 0x0 + 4570058840
   12  ???                                 0x0000000110659706 0x0 + 4570060550
)
2015-07-14 22:03:04.867 java[673:52709] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '+[NSUndoManager(NSInternal) _endTopLevelGroupings] is only safe to invoke on the main thread.'
*** First throw call stack:
(
   0   CoreFoundation                      0x00007fff8facd03c __exceptionPreprocess + 172
   1   libobjc.A.dylib                     0x00007fff8d24576e objc_exception_throw + 43
   2   CoreFoundation                      0x00007fff8facce1a +[NSException raise:format:arguments:] + 106
   3   Foundation                          0x00007fff8f42b8cb -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195
   4   Foundation                          0x00007fff8f3ad57f +[NSUndoManager(NSPrivate) _endTopLevelGroupings] + 156
   5   AppKit                              0x00007fff9751ec41 -[NSApplication run] + 928
   6   liblwjgl.dylib                      0x0000000121a9ca2e _glfwPlatformCreateWindow + 1406
   7   liblwjgl.dylib                      0x0000000121a98d9b glfwCreateWindow + 443
   8   ???                                 0x0000000110665698 0x0 + 4570109592
   9   ???                                 0x0000000110659175 0x0 + 4570059125
   10  ???                                 0x0000000110659175 0x0 + 4570059125
   11  ???                                 0x0000000110659058 0x0 + 4570058840
   12  ???                                 0x0000000110659706 0x0 + 4570060550
)
libc++abi.dylib: terminating with uncaught exception of type NSException

My Code ::

public class Driver {
   private int width = 1280;
   private int height = 720;
   
   public static void main(String args[]){
      new Driver().start();
   }
   
   private Thread thread;
   boolean running = true;
   private long window;
   
   public void start(){
      thread = new Thread(this, "Game");
      thread.start(); // runs the run method
   }
   
   private void init(){
      if(glfwInit() != GL_TRUE){
         // handle fail
         return;
      }
      glfwWindowHint(GLFW_RESIZABLE, GL_TRUE);
      window = glfwCreateWindow(width, height, "Flappy", NULL, NULL);
      if(window == NULL){
         // to be handled
         return;
      }
      ByteBuffer vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor());
      glfwSetWindowPos(window, (GLFWvidmode.width(vidmode)-width) / 2, (GLFWvidmode.height(vidmode)-height) / 2);
      glfwMakeContextCurrent(window);
      glfwShowWindow(window);
                GLContext.createFromCurrent();
      glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
      glEnable(GL_DEPTH_TEST);
      System.out.println("OpenGL: " + glGetString(GL_VERSION));
   }
   
   public void run(){
      init();
      while(running){
         update();
         render();
         if(glfwWindowShouldClose(window) == GL_TRUE){
            running = false;
         }
      }
   }
   
   private void update(){
      glfwPollEvents();
   }
   
   private void render(){
      glfwSwapBuffers(window);
   }
}

If anyone could help me I would really appreciate it.

SHC

The GLFW windows are not thread safe, I mean, you should only create the window on the main thread. Just remove the thread and call the run method yourself.