【问题标题】:Freeglut fgInitGL2: fghGenBuffers is NULLFreeglut fgInitGL2:fghGenBuffers 为 NULL
【发布时间】:2015-10-16 09:29:23
【问题描述】:

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

【问题讨论】:

    标签: c++ opengl glut glew freeglut


    【解决方案1】:

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

    我花了一些时间,但问题的原因在于 硬件。我在虚拟机 (VMware) 上运行,虽然 规范说它支持最高 2.1 的 OpenGL 我发现 它根本不支持OpenGL。

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

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

    martinvb

    据我所知,它是一种硬件。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-12-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多