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;
}

  

 

posted @ 2017-09-15 00:48  dniw_eerf  阅读(1662)  评论(0编辑  收藏  举报