gpt4 book ai didi

c++ - 无法识别 glMatrixMode() 或 GL_PROJECTION 并提供所有需要的库

转载 作者:行者123 更新时间:2023-11-28 06:53:33 24 4
gpt4 key购买 nike

我想将 OpenGL 与 C++ 结合使用来创建一个带有“相机”(透视图)和要查看的对象的基本场景。我找到了示例代码 here .但出于某种原因,尽管我已将所有必要的包含和库捆绑在一起(见下文),

// OpenGL init and components:
#include <glload/gl_3_3.h>
#include <glload/gl_load.hpp>
#include <GL/glew.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/freeglut.h>
#include <excpt.h>
#include <glm/glm.hpp>

IDE(适用于 Windows 桌面的 Visual Studio Express 2012)不同意我的观点:

identifier undefined for glMatrixMode() and GL_PROJECTION

如果您需要某种类型的更多信息,请告诉我。

============================================= ==============================

更新:在摆弄了一些与 opengl 相关的文件之后,这就是我想出的:

// Basics:
#include <windows.h>
#include <string>
#include <exception>
#include <stdexcept>
#include <stdio.h>
#include <stdlib.h>

// OpenGL init and components:
#include <glload/gl_3_1_comp.h>
#include <glload/gl_3_2_comp.h>

#include <glload/gl_3_3.h>

#include <glload/gl_4_0_comp.h>
#include <glload/gl_4_1_comp.h>
#include <glload/gl_4_2_comp.h>
#include <glload/gl_4_3_comp.h>
#include <glload/gl_4_4_comp.h>

#include <glload/gl_load.hpp>
#include <GL/glew.h>
#include <GL/freeglut.h>
#include <excpt.h>
#include <glm/glm.hpp>

它告诉我 GLEW_OK 是未定义的,尽管它就在 glew.h 中:

#define GLEW_OK 0

最佳答案

我看到你在使用 glew,你调用了 glewInit() 了吗?

还要确保您正在检查初始化是否成功。

GLenum err = glewInit();
if (GLEW_OK != err)
{
/* Problem: glewInit failed, something is seriously wrong. */
fprintf(stderr, "Error: %s\n", glewGetErrorString(err));
}

或者,它可能类似于 this今天早上发生在我身上,重启解决了我的问题

关于c++ - 无法识别 glMatrixMode() 或 GL_PROJECTION 并提供所有需要的库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23458752/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com