Hello Guest

(turns it it wasn't a) Cross platform shader issue (resolved)

  • 5 Replies
  • 6795 Views
Basically I was using lwjgl with Netbeans on windows XP and I made a new partition for windows 7. In windows 7 I loaded up the same project from the XP partition in Netbeans and ran it. It executed fine but the shaders wouldn't create.  To be explicitly clear they're referencing the same project, not a copy of it, just one is done under win7 and from a different drive.
In XP it doesn't enter this if statement:
if (errorCheckValue != GL11.GL_NO_ERROR) {
   System.out.println("ERROR - Could not create the shaders:" + GLU.gluErrorString(errorCheckValue));
   System.exit(-1);
}

The output in win7 is:
ERROR - Could not create the shaders:Invalid operation
I verified that it was accessing the correct file.  The contents of the file didn't matter (even an empty file or a gibberish file gives the same output).
I switched back over to running xp and ran the program again, it worked just like before.
This line:
out.put("Starting OpenGL version: " + GL11.glGetString(GL11.GL_VERSION)+"\n\tlwjgl vrsn:"+Sys.getVersion());
In xp gives:
Starting OpenGL version: 3.2.11927 Core Profile Forward-Compatible Context
   lwjgl vrsn:2.9.1

In win7 gives:
Starting OpenGL version: 3.2.13084 Core Profile Forward-Compatible Context 14.301.1001.0
   lwjgl vrsn:2.9.1

I doubt these slight differences account for the problems I'm having. I barely got it working in xp the first time around and I'm pretty much lost on how to proceed from here short of randomly changing things that appear to be related or reverting back to xp.
I'm interested in any feedback on more in depth debugging the shader or any other suggestions on what to try before I rewind.  Thanks.
« Last Edit: November 13, 2014, 19:39:44 by joeseph_katana »

*

Offline spasi

  • *****
  • 2261
    • WebHotelier
Re: Cross platform shader issues (?)
« Reply #1 on: November 13, 2014, 17:00:05 »
The invalid operation is a general error and may be unrelated to the shader creation. I would recommend the following:

- Print the compilation and link status of your shader and the corresponding information logs (see glGetShaderInfoLog  & glGetProgramInfoLog).
- Enable one of the debug output extensions (ARB/AMD_debug_output or KHR_debug), this way you'll know exactly where and why your program is failing. Depending on the extension used, you may also have to use a debug context (see ContextAttribs.withDebug method).

Re: Cross platform shader issues (?)
« Reply #2 on: November 13, 2014, 18:55:21 »
This is exactly what I needed. I no longer thing its related to the OS switch, its probably a mixed up file path with the textures.  This will help immensely for debugging the shader in the future.

Re: Cross platform shader issues (?)
« Reply #3 on: November 13, 2014, 19:16:53 »
Disregard previous post. I've got it working now. Turns out the problem was in the fragment shader:
gl_FragColor = texture(texture_diffuse, S_T);  // in vec4 S_T;
It doesn't recognize the function texture. I replaced it with a vec4 representing a solid color and it compiles fine now. Any idea why this would get lost between operating systems and/or what I can do access it again?  Since the shader compiles at run-time presumably this would be a big cross platform distribution issue.

*

Offline spasi

  • *****
  • 2261
    • WebHotelier
Re: Cross platform shader issues (?)
« Reply #4 on: November 13, 2014, 19:28:24 »
Shouldn't S_T be a vec2? I'm assuming texture_diffuse is a 2D sampler.

Re: Cross platform shader issues (?)
« Reply #5 on: November 13, 2014, 19:39:03 »
Shouldn't S_T be a vec2? I'm assuming texture_diffuse is a 2D sampler.
It is. That was the problem, for whatever reason the xp version was more permissive then the win7 one. I had it as a vec4 because I was using the extra two values to specify which texture and which layer.  Thanks again.