Hello! I have a problem with checking the linking errors. My program works but my function still prints a linker error and I don’t have any ideas what is wrong (printing errors for vertex and fragment shader works correctly). However when I use gl = new DebugGL3(gl); I get some errors (refer to gl.glGetShaderiv(shaderProgramID, GL3.GL_LINK_STATUS, IntBuffer.wrap(statusLinker))) and the program doesn’t start:
Exception in thread “Timer-0” javax.media.opengl.GLException: javax.media.opengl.GLException: Thread[AWT-EventQueue-0,6,main] glGetError() returned the following error codes after a call to glGetShaderiv( 0x1, 0x8B82, <java.nio.IntBuffer> java.nio.HeapIntBuffer[pos=0 lim=1 cap=1]): GL_INVALID_OPERATION ( 1282 0x502),
My initShaders function:
private void initShaders(GL3 gl)
{
shaderProgramID = gl.glCreateProgram();
int vertexShaderID = gl.glCreateShader(GL3.GL_VERTEX_SHADER);
gl.glShaderSource(vertexShaderID, 1, new String[]{vertexShader}, null);
gl.glCompileShader(vertexShaderID);
int statusVertexShader[] = new int[1];
gl.glGetShaderiv(vertexShaderID, GL3.GL_COMPILE_STATUS, IntBuffer.wrap(statusVertexShader));
if(statusVertexShader[0] == GL3.GL_FALSE)
{
int infoLogLenght[] = new int[1];
gl.glGetShaderiv(vertexShaderID, GL3.GL_INFO_LOG_LENGTH, IntBuffer.wrap(infoLogLenght));
ByteBuffer infoLog = Buffers.newDirectByteBuffer(infoLogLenght[0]);
gl.glGetShaderInfoLog(vertexShaderID, infoLogLenght[0], null, infoLog);
byte[] infoBytes =new byte[infoLogLenght[0]];
infoLog.get(infoBytes);
String out =new String(infoBytes);
System.out.println("Vertex shader error:\n" + out);
}
gl.glAttachShader(shaderProgramID, vertexShaderID);
gl.glDeleteShader(vertexShaderID);
int fragmentShaderID = gl.glCreateShader(GL3.GL_FRAGMENT_SHADER);
gl.glShaderSource(fragmentShaderID, 1, new String[]{fragmentShader}, null);
gl.glCompileShader(fragmentShaderID);
int statusFragmentShader[] = new int[1];
gl.glGetShaderiv(fragmentShaderID, GL3.GL_COMPILE_STATUS, IntBuffer.wrap(statusFragmentShader));
if(statusFragmentShader[0] == GL3.GL_FALSE)
{
int infoLogLenght[] = new int[1];
gl.glGetShaderiv(fragmentShaderID, GL3.GL_INFO_LOG_LENGTH, IntBuffer.wrap(infoLogLenght));
ByteBuffer infoLog = Buffers.newDirectByteBuffer(infoLogLenght[0]);
gl.glGetShaderInfoLog(fragmentShaderID, infoLogLenght[0], null, infoLog);
byte[] infoBytes =new byte[infoLogLenght[0]];
infoLog.get(infoBytes);
String out =new String(infoBytes);
System.out.println("Fragment shader error:\n" + out);
}
gl.glAttachShader(shaderProgramID, fragmentShaderID);
gl.glDeleteShader(fragmentShaderID);
gl.glLinkProgram(shaderProgramID);
gl.glValidateProgram(shaderProgramID);
int statusLinker[] = new int[1];
gl.glGetShaderiv(shaderProgramID, GL3.GL_LINK_STATUS, IntBuffer.wrap(statusLinker));
if(statusLinker[0] == GL3.GL_FALSE)
{
int infoLogLenght[] = new int[1];
gl.glGetShaderiv(shaderProgramID, GL3.GL_INFO_LOG_LENGTH, IntBuffer.wrap(infoLogLenght));
ByteBuffer infoLog = Buffers.newDirectByteBuffer(infoLogLenght[0]);
gl.glGetShaderInfoLog(shaderProgramID, infoLogLenght[0], null, infoLog);
byte[] infoBytes =new byte[infoLogLenght[0]];
infoLog.get(infoBytes);
String out =new String(infoBytes);
System.out.println("Linker error:\n" + out);
}
}