C++ glGenBuffers 未定义?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3032386/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 11:51:47  来源:igfitidea点击:

glGenBuffers not defined?

c++copengl

提问by jmasterx

I'm using windows and I notice that a lot of functions are grayed out because I guess #ifdef GL_GLEXT_PROTOTYPES is not defined. One of these is the VBO extension. Should I just define GL_GLEXT_PROTOTYPES? Otherwise how else can I use VBOs since im using OpenGL32.dll (I want my application to have no dll dependencies not included in Windows by default.) Thanks

我正在使用 Windows,我注意到很多函数都变灰了,因为我猜 #ifdef GL_GLEXT_PROTOTYPES 没有定义。其中之一是 VBO 扩展。我应该只定义 GL_GLEXT_PROTOTYPES 吗?否则我还能如何使用 VBO,因为我使用的是 OpenGL32.dll(我希望我的应用程序没有默认情况下不包含在 Windows 中的 dll 依赖项。)谢谢

采纳答案by Dr. Snoopy

I recommend that you use GLEW to get rid of that problem.

我建议您使用 GLEW 来解决这个问题。

It's a long story, but resuming, Windows' OpenGL library only exposes OpenGL 1.1 entry points, so all functions beyond that version are loaded with wglGetProcAddress. GLEW solves this problem by doing that.

这是一个很长的故事,但回顾一下,Windows 的 OpenGL 库仅公开 OpenGL 1.1 入口点,因此该版本以外的所有函数都使用 wglGetProcAddress 加载。GLEW 通过这样做解决了这个问题。

http://glew.sourceforge.net/

http://glew.sourceforge.net/

Just link to GLEW and GLU/GLUT (if you use them).

只需链接到 GLEW 和 GLU/GLUT(如果您使用它们)。

回答by Jerry Coffin

Yes, it's quite normal and expected to have something like:

是的,这是很正常的,预计会有类似的东西:

#define GL_GLEXT_PROTOTYPES

#include <GL/GL.h>

If you're trying to write OpenGL 3 compliant code, you'd normally change that to:

如果您尝试编写符合 OpenGL 3 的代码,您通常会将其更改为:

#define GL_GLEXT_PROTOTYPES 1
#define GL3_PROTOTYPES 1

#include <GL3/GL3.h>

回答by MinscAndBoo

And if you're using the Glew OpenGL extension, make sure you initialize it.

如果您使用的是 Glew OpenGL 扩展,请确保对其进行初始化。

glewInit();

glewInit();

Otherwise nothing will be drawn.

否则将不会绘制任何内容。

回答by Jichao

You can use gladto provide glGenBuffersfor you.

你可以用高兴glGenBuffers为你提供。