I want to know how to make std::vector<GLchar> act as an embedded array GLchar

Asked 1 years ago, Updated 1 years ago, 420 views

Question details

The following is a compilation of shaders with the source code characters (indeterminate number of characters), and the type is std::shared_ptr<std::vector<GLchar>>. Is there a way to make it work like the embedded array GLchart[]?As in the example of the correct answer in the presentation, I would like to know how to write it in one line.

What do you want to know

I want to know how to make the std::vector variable behave like the embedded array GLchart[]

Tried

Various experiments like the comment section of the presentation code

Reference Site

http://vivi.dyndns.org/tech/cpp/vector.html


    Type // std::shared_ptr<std::vector<GLchar>>vertexFile;
    //
    GLchar*v=vertexFile->data();
    // glShaderSource (vertexShader, 1, & v, NULL); // Success Example

    // glShaderSource(vertexShader, 1, & (*(GLchar*)vertexFile->data(), NULL);
    glShaderSource(vertexShader, 1, &vertexFile->data(),NULL);

c++

2022-12-20 09:22

1 Answers

The third argument of glShaderSource() requires an array of GLchar. std::vector<GLchar> can only provide an array of GLchar, so it must be included in the variable once.
In other words, it cannot be simpler than the code in the questionnaire.


2022-12-20 09:26

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.