How to pass an std::string to glShaderSource?

后端 未结 7 1840
感情败类
感情败类 2020-12-05 04:47

I have the following code:

glShaderSource(shader, 1, (const char **)data.c_str(), NULL);

But it makes my program crash. How do I convert

7条回答
  •  臣服心动
    2020-12-05 05:13

    data.c_str() returns a const char*, so do this:

    const char *c_str = data.c_str();
    glShaderSource(shader, 1, &c_str, NULL);
    

提交回复
热议问题