title: GLFW Window Icon
body: <p>I am working on a project in OpenGL with lwjgl. I was having a hard time loading an icon for the window, as it wanted a GLFWImage buffer. After a long time of scouring the internet, this is what I have:</p>
  
  <pre><code>try {
              BufferedImage originalImage =
                      ImageIO.read(new File("favicon.png"));
              ByteArrayOutputStream baos = new ByteArrayOutputStream();
              ImageIO.write( originalImage, "png", baos );
              baos.flush();
              byte[] imageInByte = baos.toByteArray();
              ByteBuffer buF = ByteBuffer.wrap(imageInByte);
              GLFWImage.Buffer b = new GLFWImage.Buffer(buF);
              glfwSetWindowIcon(window, b);
          } catch (IOException io){
              System.out.println("Could not load window icon!");
              System.out.println(io.toString());
          }
  </code></pre>
  
  <p>The java runtime crashes with an output like this:</p>
  
  <pre><code># A fatal error has been detected by the Java Runtime Environment:
  # The crash happened outside the Java Virtual Machine in native code.
  # See problematic frame for where to report the bug.
  </code></pre>
  
  <p>I haven't been able to find a method to do this that doesn't give this kind of error. The official glfw documentation says to use a method that doesn't seem to exist in LWJGL. If you have any experience with this, it would even be helpful to just point me in the right direction.</p>
  
  <p>Thanks in advance.</p>