1

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

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? */
/* ... */
4

1 回答 1

1

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

于 2013-02-10T10:18:54.923 回答