Andrew Zitsew
Andrew Zitsew

Reputation: 45

GLUT segmentation fault on glCreateShader

I am writing C++ program with use of glew,glut and GLM. When I am creating shader like this:

GLuint VertexShaderID = glCreateShader(GL_VERTEX_SHADER);

it says "Segmentation fault(core dumped)".
My hardware is Intel Atom CPU.
OS:OpenSuse 13.2 32-bit.
What I need to do to make it work?

Upvotes: 1

Views: 826

Answers (1)

Sumit Gemini
Sumit Gemini

Reputation: 1836

You're not checking OpenGL extensions, version, or etc.

GLenum err = glewInit();
if (err != GLEW_OK)
  exit(1); // or handle the error in a nicer way
if (!GLEW_VERSION_2_1)  // check that the machine supports the 2.1 API.
  exit(1); // or handle the error in a nicer way

This code needs to happen after creating the OpenGL context, but before using any potentially-not-existing functions. More details on the GLEW web page

Upvotes: 2

Related Questions