ImGui设置程序图标

环境:Win10, OpenGL+GLFW
首先需包含stb_image.h头文件

#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"

然后添加代码:

    // Create window with graphics context
    GLFWwindow *window = glfwCreateWindow(1280, 720, title, NULL, NULL);
    if (window == NULL)
        return 1;

    //设置程序图标
    GLFWimage images[1];
    images[0].pixels = stbi_load("assets/debug.png", &images[0].width, &images[0].height, 0, 4); //rgba channels
    glfwSetWindowIcon(window, 1, images);
    stbi_image_free(images[0].pixels);

    glfwMakeContextCurrent(window);
    glfwSwapInterval(1); // Enable vsync

注意,图片文件的相对路径为目标程序所在的目录.

posted @ 2024-05-30 11:41  yinsua  阅读(395)  评论(0)    收藏  举报