-1

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.

bohdloss
  • 1
  • 1
  • 1
  • the fact is i do not use AWT/Swing anywhere in my code. I only use JOptionPane to show error messages when the game crashes, but in normal execution none of them actually appear. Yes, i did a google search and foind that github link, which didn't help me and that's why i decided to ask here. – bohdloss Sep 02 '20 at 21:11
  • I feel really stupid right now but, the problem was that i called a JOptionPane.showMessageDialog(String) right as the application started and somehow forgot to mention it... just removing it made the program work fine. Sorry for wasting everyone's time – bohdloss Sep 03 '20 at 17:22

1 Answers1

0

The problem turned out to be outside of the code i posted in my question. Apparently calling JOptionPane.showMessageDialog(String) is enough to trigger this X error... my bad

bohdloss
  • 1
  • 1
  • 1
  • Also i found out that if i do the same thing but after calling `GL.createcapabilities()` it does not cause any problem – bohdloss Sep 03 '20 at 17:57