I'm learning OpenGL using the C API and some of the functions' argument types have proven a bit challenging to me.
One example is the function
Code:
glShaderSource(GLuint shader, GLsizei count, GLchar const** string, GLint const* length);
It resides in foo() which receives a vector "data" from elsewhere
Code:
void foo(std::vector<std::pair<GLenum, GLchar const*>> const& data);
To pass the pair's second element to glShaderSource's third argument, I do the following:
Code:
GLchar const* const source[] = {data[0].second};
glShaderSource(..., ..., source, ...);
Now I have two questions regarding this:
1. Can I initialize a char const** via initialization list, the way I do a char const*?
Code:
// this works
std::vector<std::pair<GLenum, GLchar const*>> const shader_sources = {
{GL_VERTEX_SHADER, "sourcecode"},
{GL_FRAGMENT_SHADER, "sourcecode"}
};
// but is this possible?
std::vector<std::pair<GLenum, GLchar const**>> = { ??? };
2. Is there an alternative to creating a temporary GLchar**, even though that's specifically what the function wants?