正如标题所说,我可以在我的计划中这样做:
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? */
/* ... */
答案 0 :(得分:1)
是的,这完全有效。着色器对象仍然由程序对象在内部引用,并且在删除程序对象时将隐式释放。