Segmentation fault at glCreateShader in wxWidgets


I had a simple graphics program written using OpenGL and using GLUT for windowing. To get more windowing functionality, I wanted to move it to wxWidgets. I picked an example program that uses OpenGL in wxWidgets. It compiled and worked correctly. When I placed my OpenGL code into this example, I got a segmentation fault at the glCreateShader call in my code.


I had a glewInit in my original code. I had put this in the application class constructor. Apparently, wxWidgets requires that the first OpenGL or GLEW call be placed inside the OnPaint event handler function. Look for EVT_PAINT to find this function. Once I did that, the error disappeared and OpenGL worked.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s