【问题标题】:Failure to recognize glMatrixMode() or GL_PROJECTION with all needed libraries given无法识别 glMatrixMode() 或 GL_PROJECTION 并给出所有需要的库
【发布时间】:2014-05-04 16:37:38
【问题描述】:

我想使用 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(Visual Studio Express 2012 for Windows Desktop)不同意我的观点:

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

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

更新:在摆弄了一些与 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

【问题讨论】:

  • 您不应该真正将 glload 的标头与旧的 GL/gl.h 标头混合使用。目前还不清楚您要针对什么,但现代核心 GL 没有像 glMatrix() 这样的功能。如果你想要这些东西,你可能应该包含 头文件。你不应该太在意智能感知告诉你什么;它很容易混淆。代码可以编译吗?
  • @derhass:太好了。现在我想出了一堆链接器错误,第一个是Error 1 error LNK2001: unresolved external symbol __funcptr_glClear C:\Users\Andrey\documents\visual studio 2012\Projects\gameLab02\gameLab02\main.obj gameLab02

标签: c++ opengl 3d camera


【解决方案1】:

我看到你在使用 glew,你给glewInit()打过电话吗?

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

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

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

【讨论】:

  • 既然您指出了这一点:尝试同时使用 glload 和 GLEW 似乎也是个坏主意。
  • 同意你的观点,我自己从未使用过 glload,但从他们的介绍here 来看,它也可能使用 glew,因此出现错误?
  • @derhass:你要我说明什么?作为标题和库最终渲染场景,我应该使用的最低限度是多少?
  • @Andrey:很高兴知道您的目标是什么 GL 版本,以及您想使用什么 gl(扩展)加载程序:glload 还是 GLEW?
  • @Andrey:很难说什么最适合你。但是混合这些东西是行不通的。你应该看看这个explanation for the variuos gl loaders
猜你喜欢
  • 2012-05-11
  • 2015-06-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-10-22
  • 2022-01-01
  • 2018-09-02
相关资源
最近更新 更多