Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/apache-spark/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ ';标准::基本字符串<;char,std::char_traits<;char>;,std::分配器<;char>>;::c#u街';:非标准语法;使用'&';创建指向成员的指针的步骤_C++_Opengl - Fatal编程技术网

C++ ';标准::基本字符串<;char,std::char_traits<;char>;,std::分配器<;char>>;::c#u街';:非标准语法;使用'&';创建指向成员的指针的步骤

C++ ';标准::基本字符串<;char,std::char_traits<;char>;,std::分配器<;char>>;::c#u街';:非标准语法;使用'&';创建指向成员的指针的步骤,c++,opengl,C++,Opengl,我正在尝试创建一个可以读取和编译opengl顶点和片段着色器文件的函数,但遇到以下错误: 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>::c_str': non-standard syntax; use '&' to create a pointer to member “std::basic_string::c_str”:非标准语法;使用“&”创建指向成员的

我正在尝试创建一个可以读取和编译opengl顶点和片段着色器文件的函数,但遇到以下错误:

'std::basic_string<char,std::char_traits<char>,std::allocator<char>>::c_str': non-standard syntax; use '&' to create a pointer to member
“std::basic_string::c_str”:非标准语法;使用“&”创建指向成员的指针
我不太确定如何修理它。这是我的密码:

GLuint shader_load(const GLchar* vertex, const GLchar* fragment) {

std::string ver = file_read_all(vertex);
std::string frag = file_read_all(fragment);

const GLchar* verCode = ver.c_str;
const GLchar* fragCode = frag.c_str;

GLuint program;

GLuint verShader, fragShader;
GLint success;
GLchar log[512];

verShader = glCreateShader(GL_VERTEX_SHADER);
glShaderSource(verShader, 1, &verCode, NULL);
glCompileShader(verShader);
glGetShaderiv(verShader, GL_COMPILE_STATUS, &success);

if (!success) {
    glGetShaderInfoLog(verShader, 512, NULL, log);
    std::cout << "Failed to compile Vertex Shader\n" << log << std::endl;
    return NULL;
}

fragShader = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(fragShader, 1, &fragCode, NULL);
glCompileShader(fragShader);
glGetShaderiv(fragShader, GL_COMPILE_STATUS, &success);

if (!success) {
    glGetShaderInfoLog(fragShader, 512, NULL, log);
    std::cout << "Failed to compile Fragment Shader\n" << log << std::endl;
    return NULL;
}

program = glCreateProgram();

glAttachShader(program, verShader);
glAttachShader(program, fragShader);

glLinkProgram(program);

glGetProgramiv(program, GL_LINK_STATUS, &success);
if (!success)
{
    glGetProgramInfoLog(program, 512, NULL, log);
    std::cout << "Failed to Link Shader\n" << log << std::endl;
}

glDeleteShader(verShader);
glDeleteShader(fragShader);
}
GLuint着色器加载(常量GLchar*顶点,常量GLchar*片段){
std::string ver=file\u read\u all(顶点);
std::string frag=file\u read\u all(片段);
const GLchar*verCode=ver.c_str;
常量GLchar*fragCode=frag.c_str;
GLuint程序;
GLuint verShader,fragShader;
辉煌的成功;
GLchar日志[512];
verShader=glCreateShader(GL_顶点_着色器);
glShaderSource(verShader,1,&verCode,NULL);
glCompileShader(verShader);
glGetShaderiv(verShader、GL编译状态和成功);
如果(!成功){
glGetShaderInfoLog(verShader,512,NULL,log);
std::cout是一个成员函数,如果要调用它,应该添加
()

const GLchar* verCode = ver.c_str();
                                 ~~