I have been making a lwjgl object-oriented wrapper just for fun and have hit a bit of a snag.
To test setting the cursor i have been trying to load a cursor image, but it isn’t working.
When i try to load the image after creating my window, it stalls on ImageIO.read.
When i try to load the image before creating my window, it glitches and doesn’t let me focus on the window. One thing i have noticed is that the application doesn’t show up in my open applications bar (don’t know the name, i’m on a mac) when i do this, but eclipse still shows it as running.
When i try to load the image in another thread started before i create the window it does the same as the first time, it stalls and never loads. The window is also never created.
When i try to load the image in another thread started after i create the window it does the same thing as the first time, it stalls and never loads.
It seems like using
new Thread() {...}.start()
Isn’t actually starting a new thread.
There are no errors, i do have a GLFWErrorCallback set up, and i do know that is working, but it is not throwing any errors either.
Here is my code to load the image:
new Thread() {
public void run() {
try {
System.out.println("Testing... Testing...");
System.out.println("1");
URL url = new URL("http://orig13.deviantart.net/410c/f/2012/010/a/4/sniper_cross_hairs_cursor_by_parodyskillz-d4lxmpf.png");
System.out.println("2");
ImageIO.read(url);
System.out.println("3");
System.out.println("success");
} catch (IOException e) {
e.printStackTrace();
}
}
}.start();
Do note, this does work when i run this code in a fresh project with nothing in it.
My other code is too large to post here, so i will post what i think is relevant.
on startup:
if(glfwInit() != GL_TRUE) {
Error.fatal("Error initalizing GLFW", this);
}
Error.registerGLFWErrorCallback();
Monitor.registerMonitorCallback();
ShutdownHandler.addDisposable("Game", this);
window = Window.create(640, 400, "Cool Window", null, null, null);
window.getCreationHints().setResizable(true);
window.init();
start();
window.init()
if(exists()) {
throw new UnsupportedOperationException("Window is already initialized");
}
creationHints.apply();
windowId = glfwCreateWindow(creationWidth, creationHeight, title, creationMonitor.getId(), share.getId());
if(windowId == NULL) {
Error.fatal("Error creating window", this);
}
add(this);
makeCurrent();
glfwSwapInterval(1);
this.keyInput = new KeyInput(this);
this.mouseInput = new MouseInput(this);
this.windowInput = new WindowInput(this);
I am using the VM Argument -XstartOnFirstThread.
I would really appreciate if someone could help me figure this out, it is extremely frustrating.