gpt4 book ai didi

c++ - 作为字符串的 OpenGL 统一名称指针

转载 作者:行者123 更新时间:2023-12-02 19:43:01 24 4
gpt4 key购买 nike

Set_Up_Shader(unsigned int sShader, string Uni_s, glm::vec3 V3){
int isu = glGetUniformLocation(sShader, &Uni_s[0]);
glUniform3fv(isu, 1, glm::value_ptr(V3));
}

我的问题是:显然 glGetUniformLocation 参数 2 应该是 const char*。 OpenGL 会延迟/需要 const 对象吗?将 OpenGL 引用发送到很快就会被销毁的字符串对象是否危险?

最佳答案

Is it dangerous to sent OpenGL reference to string object that soon will be destroyed?

没有。

参见OpenGL 4.6 API Core Profile Specification - 2.1 Execution Model :

Data binding occurs on call. This means that data passed to a GL command are interpreted when that command is received. Even if the command requires a pointer to data, those data are interpreted when the call is made, and any subsequent changes to the data have no effect on the GL

关于c++ - 作为字符串的 OpenGL 统一名称指针,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59712670/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com