GLFW icon

Started by Andrew_3ds, August 02, 2016, 05:40:13

Previous topic - Next topic

Andrew_3ds

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.

spasi

The Events sample has an example, here. 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.

Andrew_3ds

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?

spasi

Yes, if the images are plain files.