Freeglut fgInitGL2: fghGenBuffers is NULL
Freeglut fgInitGL2: fghGenBuffers is NULL
在glutCreateWindow上出现这个消息-什么可以导致这样的问题?
下面是我的代码:
#include "pch.h"
#include <stdio.h>
#include "include/glew.h"
#include "include/glut.h"
#include "include/freeglut.h"
#include "Mathematics.h"
GLuint VBO;
static void RenderSceneCB()
{
glClear(GL_COLOR_BUFFER_BIT);
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, VBO);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
glDrawArrays(GL_TRIANGLES, 0, 1);
glDisableVertexAttribArray(0);
glutSwapBuffers();
}
static void InitializeGlutCallbacks()
{
glutDisplayFunc(RenderSceneCB);
}
static void CreateVertexBuffer()
{
Vector3f Vertices[1];
Vertices[0] = Vector3f(-1.0f, -1.0f, 0.0f);
glGenBuffers(1, &VBO);
glBindBuffer(GL_ARRAY_BUFFER, VBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(Vertices), Vertices, GL_STATIC_DRAW);
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGBA);
glutInitWindowSize(1024, 768);
glutInitWindowPosition(100, 100);
glutCreateWindow("My");
// Must be done after glut is initialized!
GLenum res = glewInit();
if (res != GLEW_OK) {
fprintf(stderr, "Error: '%s'n", glewGetErrorString(res));
return 1;
} else {
printf("Glew Inited");
}
InitializeGlutCallbacks();
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
CreateVertexBuffer();
glutMainLoop();
return 0;
}
我刚刚遇到了同样的问题,我找到了这个答案
由martinvb我花了一些时间,但问题的原因在硬件。我在一个虚拟机(VMware)上运行,尽管规格说它支持OpenGL到2.1它根本不支持OpenGL
我的解决方案是找一台旧机器,在上面安装Windows,然后复制所有文件。它的编译和运行都非常流畅。
如果其他人遇到同样的问题,我可以建议得到它在虚拟化之前使用本机安装。它可以保护你很多时间。
据我所知,这是一个硬件。
相关文章:
- 如果我std::dynamic_pointer_cast并且底层dynamic_cast的结果为null,那么返回的sh
- 如何在 c++ 中'NULL'字符串
- c++使用foreach使数组为null
- 当使用通配符和null指针调用函数时,对输出的说明
- Why is UINT32_MAX + 1 = 0?
- C++错误:"error: int aaa::bbb is protected within this context"
- 创建具有 new in 函数和"this is nullptr"异常的对象
- 当字段可以为null时,如何使用C++接口在Avro中写入数据
- 如何在映射中返回null
- 使用 cmake 的 Linux 终端上的"Conversion to non-scalar type is requested"错误
- Is !NaN not a NaN?
- 为什么返回 NULL 不会破坏函数?
- 构造函数中的 QQuickItem 父项 null
- Directx 11 - CompileFromFile() is not compiling
- 检查字符串是否"null" C++
- Centos7 g++ "to_string is not in a member of std"
- getProcAddress - NULL is returned
- pthread_t on mac os x is NULL
- Is it safe to #define NULL nullptr?
- Freeglut fgInitGL2: fghGenBuffers is NULL