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

标签 c++ opengl 3d camera

我想将 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/

相关文章:

c++ - 无法创建 ICaptureGraphBuilder2 的实例

c++ - 如何在 GLSL 中将 float 量化为无符号字节

opengl - 一般问题 : Are Shading Languages/shaders object-oriented?

javascript - Three.js - 如何获得相对于原点的相机位置

c++ - 将 char 数组传递给函数

c++ - 在 C 中将 char 转换为 int

c++ - C++ `recv` 函数如何处理数据接收?它能收到部分 "packet"吗?

opengl - OpenGL 中的颜色减淡

python - 有没有办法使用 python 比较 3D 模型文件 (STEP)?

Scipy 中的 3d 插值——密度网格