繁体   English   中英

opengl glew 和 glfw 初始化问题

[英]opengl initialization problem with glew and glfw

我开始学习 OpenGL 的东西,但不幸的是,我无法正确初始化。 我添加了 glfw 和 glew 库,这些函数给了我一个奇怪的错误,我怎样才能让它工作?

编码:

#include <iostream>
#include <GL/glew.h>
#include <GLFW/glfw3.h>

int main(void)
{
GLFWwindow* window;

/* Initialize the library */
if (!glfwInit())
{
    std::cout << "GLFW initialization failed.\n";
    return -1;
}
if (glewInit()!=GLEW_OK)
{
    std::cout << "GLEW initialization failed.\n";
    return -1;
}
window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);

if (!window)
{
    glfwTerminate();
    std::cout << "Wiondow failed.\n";
    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;
}

错误: 显示的错误

要正确链接GLEW库,必须设置正确的预处理器定义。 请参阅GLEW - 安装

[...] 在 Windows 上,您还需要在构建 static 库或可执行文件时定义GLEW_STATIC预处理器令牌,并在构建 Z06416233FE5EC4C5933122E4 时定义GLEW_BUILD预处理器令牌 [...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM