我们可以在链接着色器程序后删除顶点和片段着色器

时间:2013-02-10 08:44:50

标签: opengl glsl

正如标题所说,我可以在我的计划中这样做:

vertex = glCreateShader(GL_VERTEX_SHADER);
/* ... */
fragment = glCreateShader(GL_FRAGMENT_SHADER);
/* ... */
program = glCreateProgram();
glAttachShader(program, vertex);
glAttachShader(program, fragment);
glLinkProgram(program);
/* All things done */

glDeleteShader(vertex); /* <~ Can I do this now? */
glDeleteShader(vertex); /* <~ Can I do this now? */

/* And in render procedure */
glUseProgram(program); /* <~ Still use program without any problem? */
/* ... */

1 个答案:

答案 0 :(得分:1)

是的,这完全有效。着色器对象仍然由程序对象在内部引用,并且在删除程序对象时将隐式释放。