为什么我需要在代码块中使用 #define 而不是在 Visual Studio 中? (GLFW)

问题描述

我开始学习 openGL。我更喜欢使用代码块,但 GLFW3 的设置在代码块中很奇怪。我从用于 Visual Studio 的 glfw 文档中复制了示例代码。但是在代码块中,我需要添加额外的行 #define GLFW_DLL 才能使其工作?

#define GLFW_DLL
#include <GLFW/glfw3.h>
#include <iostream>


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

那么为什么我需要在代码块中而不是在 Visual Studio添加额外的 #define 行才能使其工作? 我遵循了 this 说明

GLFW 文档示例代码 here

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)