开发者

Why Could glGetString(GL_VERSION) Be Causing a Seg Fault?

I'm learning OpenGL on Fedora 13 and noticed that a call to glGetString is causing a seg fault. I've scraped Google, but come up with no solutions.

The code is simple:

#include <GL/gl.h>

int main() {
    glGetString(GL_VERSION);
    return 0;
}

Compile Command:

g++ -lGL main.cpp -o test.bin

Run result:

$ ./test.bin 
Segmentation fault (core dumped)

OpenGL Info:

$ glxinfo | grep OpenGL
OpenGL vendor string: Tungsten Graphics, Inc
OpenGL renderer string: Mesa DRI Intel(R) IGDNG_M GEM 20100328 2010Q1 
OpenGL version string: 2.1 Mesa 7.8.1
OpenGL shadin开发者_Go百科g language version string: 1.20
OpenGL extensions:

Any ideas or references are greatly appreciated.

Solution:

#include <iostream>
#include <GL/freeglut.h>

int main(int argc, char **argv) {
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGBA);
    glutCreateWindow("test");
    glutFullScreen();
    std::cout << glGetString(GL_VERSION) << std::endl;
    return 0;
}


I doubt you can call even something as simple as glGetString without an OpenGL context.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜