I am trying to make my java program cross platform which is why i tested it on linux and the results are pretty bad. Basically, after fixing some bugs and getting the native libraries to load correctly, i am greeted by this error message as the program quits after a second or less:
X Error of failed request: RenderBadPicture (invalid Picture parameter)
Major opcode of failed request: 139 (RENDER)
Minor opcode of failed request: 7 (RenderFreePicture)
Picture id in failed request: 0x4c0002b
Serial number of failed request: 766
Current serial number in output stream: 778
This is the program setup routine:
//Initializes lwjgl
loadLibrary();
//creates the glfw window
System.out.println("Initializing window...");
window=new Window();
//This is not relevant and does not cause any problem
System.out.println("Initializing camera...");
camera = new Camera(window.getWidth(),window.getHeight());
//This is where the error happens
System.out.println("Creating context...");
//"Creating context..." is output correctly of course
GL.createCapabilities();
/*Right after this function is called, there is only a 0,5-1 seconds window in which the program
will stay open before showing the X Error (and it continues normally in that time with the
initialization stuff, confirming that the error is asynchronous*/
The code for window initialization (i will only include relevant parts and not the whole class for better readability):
public Window() {
Dimension d = defaultD();
int w = (int)(d.getWidth()*0.7d);
int h = (int)(d.getHeight()*0.7d);
width=w;
height=h;
createWindow(w, h);
}
public Dimension defaultD() {
GLFWVidMode mode = glfwGetVideoMode(glfwGetPrimaryMonitor());
int w = mode.width();
int h = mode.height();
return new Dimension(w,h);
}
public void createWindow(int width, int height) {
Dimension d = defaultD();
window = glfwCreateWindow(width, height, title, 0, 0);
if(window==0) {
JOptionPane.showMessageDialog(null, "Failed to initialize window");
System.exit(1);
}
glfwSetWindowSizeLimits(window, width, height, width, height);
glfwSetWindowPos(window, (int)((d.getWidth()-width)/2), (int)((d.getHeight()-height)/2));
//this is necessary before calling GL.createcapabilities(), otherwise the program crashes
glfwMakeContextCurrent(window);
destroyed=false;
}
I really have no idea what this is caused by (also because, i repeat, this exact same code works perfectly fine on windows), also i have no way to catch this error and preventing it from aborting execution, as it is not a java exception. Any help that can point me in the right direction is highly appreciated. If more code samples are needed, just let me know and i'll update my post.