I’ve always set up shaders like so:
handle = GL.glCreateShader(type);
GL.glShaderSource(handle, source);
GL.glCompileShader(handle);
if (GL.glGetShaderiv(handle, ShaderState.COMPILE_STATUS) == GL.FALSE)
throw new OpenGLException("Error compiling shader: " + handle);
And I’ve always set up program objects like so:
handle = GL.glCreateProgram();
for (ShaderObject shaderObj : shaderObjs)
GL.glAttachShader(handle, shaderObj.getHandle());
GL.glLinkProgram(handle);
if (GL.glGetProgramiv(handle, ProgramState.LINK_STATUS) == GL.FALSE)
throw new OpenGLException("Error linking program: " + handle);
for (ShaderObject shaderObj : shaderObjs)
GL.glDetachShader(handle, shaderObj.getHandle());
I’m not exactly sure what else I should do; I’ve previously seen the use of glValidateProgram and checking that the program is validated. However, I’m not sure if it’s necessary. If it’s compiled and linked successfully, won’t that mean that it’s validated for use? Also I’ve known about the use of info-logs and I’m not exactly sure how I should use them and what to use them for. On top of that, is there anything else I should known about?
Oh and I nearly forgot, should I always detach shader objects from the program after the program is linked? Is there any reason that you’d keep them attached?