GLFW SetWindowIcon [英] GLFW SetWindowIcon

查看:499
本文介绍了GLFW SetWindowIcon的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我正在尝试为glfw窗口设置窗口图标(显然),但是这样做很麻烦,因为我不知道如何使用GLFWimage设置图标. 文档中的代码如下所示:

So, I am trying to set the window icon for my glfw window (obviously) but I am having trouble doing so because I don't know how to set an icon using GLFWimage. The code in the docs is as shown:

GLFWimage images[2];
images[0] = load_icon("my_icon.png");
images[1] = load_icon("my_icon_small.png");
glfwSetWindowIcon(window, 2, images);

但是,这里没有显示如何使用或创建"load_icon"函数. 因此,有人可以帮忙,因为我已经搜索了几个月了.

But there, it doesn't show how to use or create a "load_icon" function. So, can anyone help cause I have been searching for months.

推荐答案

glfwSetWindowIcon(GLFWwindow * window, int count, const GLFWimage * images)

我认为第一个参数2很清楚,第三个参数GLFWimage是具有字段int width, int height, unsigned char * pixels的结构,但是它是您为其提供数据的任务,GLFW并没有提供加载图像的功能,但是有几个库可以执行此操作,或者您可以编写自己的函数来获取图像数据.

I think the first parameters 2 are clear and there is the third, GLFWimage which is a structure with fields int width, int height, unsigned char * pixels but its your task to provide data for it, GLFW does not give you fucntions to load your images but there are several libraries which does or you can write your own funcion to get image data.

我并不是真正的c ++专家,所以我目前尚不清楚最新/最好的库,但是有一些例子可以很好地解决问题.像这样:

I'm not really c++ guy so I'm not aware of the newest/best libraries currently but there is soil for example which would work just fine. Something like this:

GLFWimage icons[1];
icons[0].pixels = SOIL_load_image("icon.png", &icons[0].width, &icons[0].height, 0, SOIL_LOAD_RGBA);
glfwSetWindowIcon(window.window, 1, icons);
SOIL_free_image_data(icons[0].pixels);

这篇关于GLFW SetWindowIcon的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆