So recently I have been working on porting a game from Java2D to JOGL. The process has been going well, but I ran into an error about 2 weeks ago and it’s been pretty elusive. I did the shaders like I’ve done in all my other projects, but this is the error I’m getting:
GLDebugEvent[ id 0x1
type Error
severity High: dangerous undefined behavior
source GL API
msg GL_INVALID_OPERATION in glGetAttribLocation(program not linked)
when 1442422448181
source 3.3 (Core profile, arb, debug, compat[ES2, ES3], FBO, hardware) - 3.3 (Core Profile) Mesa 10.6.2 - hash 0x6009cf80]
Here is the code for loading shaders:
shaders[B_V] = glo.glCreateShader(GL3.GL_VERTEX_SHADER);
shaders[B_F] = glo.glCreateShader(GL3.GL_FRAGMENT_SHADER);
shaders[U_V] = glo.glCreateShader(GL3.GL_VERTEX_SHADER);
shaders[U_F] = glo.glCreateShader(GL3.GL_FRAGMENT_SHADER);
String tempString = "";
try {
//Background vertex shader
BufferedReader read = new BufferedReader(new InputStreamReader(RenderUtils.class.getResourceAsStream("BackgroundShaderV.glsl")));
while((tempString = read.readLine()) != null)
{
shaderSources[B_V][0] += (tempString + System.lineSeparator());
}
tempString = "";
//Background fragment shader
read = new BufferedReader(new InputStreamReader(RenderUtils.class.getResourceAsStream("BackgroundShaderF.glsl")));
while((tempString = read.readLine()) != null)
{
shaderSources[B_F][0] += (tempString + System.lineSeparator());
}
tempString = "";
//Unit vertex shader
read = new BufferedReader(new InputStreamReader(RenderUtils.class.getResourceAsStream("UnitShaderV.glsl")));
while((tempString = read.readLine()) != null)
{
shaderSources[U_V][0] += (tempString + System.lineSeparator());
}
tempString = "";
//Unit fragment shader
read = new BufferedReader(new InputStreamReader(RenderUtils.class.getResourceAsStream("UnitShaderF.glsl")));
while((tempString = read.readLine()) != null)
{
shaderSources[U_F][0] += (tempString + System.lineSeparator());
}
//compile shaders
glo.glShaderSource(shaders[B_V], 1, shaderSources[B_V], null, 0);
glo.glCompileShader(shaders[B_V]);
glo.glShaderSource(shaders[B_F], 1, shaderSources[B_F], null, 0);
glo.glCompileShader(shaders[B_F]);
glo.glShaderSource(shaders[U_V], 1, shaderSources[U_V], null, 0);
glo.glCompileShader(shaders[U_V]);
glo.glShaderSource(shaders[U_F], 1, shaderSources[U_F], null, 0);
glo.glCompileShader(shaders[U_F]);
//link shaders
backgroundShader = glo.glCreateProgram();
glo.glAttachShader(backgroundShader, shaders[B_V]);
glo.glAttachShader(backgroundShader, shaders[B_F]);
glo.glLinkProgram(backgroundShader);
unitShader = glo.glCreateProgram();
glo.glAttachShader(unitShader, shaders[U_V]);
glo.glAttachShader(unitShader, shaders[U_F]);
glo.glLinkProgram(unitShader);
glo.glUseProgram(backgroundShader);
If anyone has run into this issue before and could give some advice it would be most appreciated.