I have the following code:
glShaderSource(shader, 1, (const char **)data.c_str(), NULL);
But it makes my program crash. How do I convert
You can get a reasonable-looking call by using a helper class. Define this class:
struct StringHelper {
const char *p;
StringHelper(const std::string& s) : p(s.c_str()) {}
operator const char**() { return &p; }
};
Then, when you need to call glShaderSource, do it this way:
glShaderSource(shader, 1, StringHelper(data), NULL);