Freeglut fgInitGL2: fghGenBuffers is NULL

Freeglut fgInitGL2: fghGenBuffers is NULL

本文关键字:is NULL fghGenBuffers fgInitGL2 Freeglut      更新时间:2023-10-16

在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;
}

我刚刚遇到了同样的问题,我找到了这个答案

我花了一些时间,但问题的原因在硬件。我在一个虚拟机(VMware)上运行,尽管规格说它支持OpenGL到2.1它根本不支持OpenGL

我的解决方案是找一台旧机器,在上面安装Windows,然后复制所有文件。它的编译和运行都非常流畅。

如果其他人遇到同样的问题,我可以建议得到它在虚拟化之前使用本机安装。它可以保护你很多时间。

由martinvb

据我所知,这是一个硬件。