LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: Andrew_3ds on August 02, 2016, 05:40:13

Title: GLFW icon
Post by: Andrew_3ds on August 02, 2016, 05:40:13
I'm a bit confused as to how GLFWImage and GLFWImage.Buffer work. The glfwSetWindowIcon method takes in a Buffer as a parameter. How exactly do I use these to set the icon? Looking into GLFWImage, I know how to "load" one by setting the width, height, and pixels, (I think), but I don't know how to turn that into a GLFWImage.Buffer to give to the method.
Title: Re: GLFW icon
Post by: spasi on August 02, 2016, 18:44:50
The Events sample has an example, here (https://github.com/LWJGL/lwjgl3/blob/7e1dcb80160d9dbce2b041cbf84eec0da15f2661/modules/core/src/test/java/org/lwjgl/demo/glfw/Events.java#L87). A struct Buffer class basically represents an array of the corresponding struct type. The API is similar to NIO buffers, except each element is a struct value, instead of a primitive value.
Title: Re: GLFW icon
Post by: Andrew_3ds on August 03, 2016, 02:19:29
Ah okay, I got it working, thank you. Would using STB to load the images straight from the disk work, or do they have to be read by the SeekableByteChannel then loaded from memory?
Title: Re: GLFW icon
Post by: spasi on August 03, 2016, 08:48:06
Yes, if the images are plain files.