11

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 shading 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; } 
0

1 Answer 1

17

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

Sign up to request clarification or add additional context in comments.

3 Comments

I think you're right. The docs of glGetString say it returns information about the "current GL connection" but I don't think the original poster has initialized this connection. opengl.org/sdk/docs/man/xhtml/glGetString.xml
Direct hit! Thanks for the help.
wow... been racking my head for half an hour wondering if I had forgotten everything about pointers turns out I was calling it at the wrong time lol! Thanks, as simple as this answer is it is very insightful

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.