glfw配置-静态链接

1、下载glfw

地址:http://www.glfw.org/download.html

下载32-bit windows binaries

在文件夹中找到glfw3.h,和适应于自己vs版本的glfw3.lib,glfw3.lib,(glfw3dll.lib,glfw3.dll暂且用不上)

将上述.h和.lib库放置任意文件夹中。

2、创建项目

创建win32控制台程序,点击空项目。

3、引入.h库和.lib链接库。

在包含目录中加入glfw.h所在的文件夹,我设置为F:\software\vs2015_necessary_install_software\vs2015\GL_ku\include

在库目录中加入glfw3.lib所在的文件夹,我设置为F:\software\vs2015_necessary_install_software\vs2015\GL_ku\lib

在链接器->输入->附加依赖项中添加glfw3.lib和open32.lib

提示:当将库放在安装目录下的include和lib文件中,不能正常引用,于是另建了,一个目录GL_ku来放置glfw库。因为是静态链接没有用到glfw3dll.lib和glfw3.dll。

4、测试

#include <GLFW/glfw3.h>

int main(void)
{
    GLFWwindow* window;

    /* Initialize the library */
    if (!glfwInit())
        return -1;

    /* Create a windowed mode window and its OpenGL context */
    window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);
    if (!window)
    {
        glfwTerminate();
        return -1;
    }

    /* Make the window's context current */
    glfwMakeContextCurrent(window);

    /* Loop until the user closes the window */
    while (!glfwWindowShouldClose(window))
    {
        /* Render here */
        glClear(GL_COLOR_BUFFER_BIT);

        /* Swap front and back buffers */
        glfwSwapBuffers(window);

        /* Poll for and process events */
        glfwPollEvents();
    }

    glfwTerminate();
    return 0;
}

  

 

转载于:https://www.cnblogs.com/zclblog/p/7524187.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值