glsl shader in 1.7.0

Can anyone provide me working code to use OpenGL shaders?

All I get is errors like that, even with simplest samples and there is no ‘j’ symbol in my shader code

:display:gsg:glgsg(error): An error occurred while compiling shader!
Vertex shader failed to compile with the following errors:
ERROR: 0:1: error(#132) Syntax error: 'j' parse error
ERROR: error(#273) 1 compilation errors.  No code generated
:display:gsg:glgsg(error): at 413 of c:\panda3d-1.7.0\panda\src\glstuff\glShader
Context_src.cxx : GL error 1281

python code is following:

shader = Shader.load(Shader.SLGLSL, "vertexprog.glsl", "fragmentprog.glsl") 

and shader:

void main()
{	
    gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex;
}

Wow, hm, that’s weird. Can you put together a small but working script that demonstrates the problem?

here are the files
zed.ee/temp/glsl.zip

I downloaded and (re)installed 1.7.0 version this morning.

Last error was this:

C:\Users\Kasutaja\Desktop\cg_tutorial\glsl>c:\Panda3D-1.7.0\python\python.exe 3.py
DirectStart: Starting the game.
Known pipe types:
  wglGraphicsPipe
(all display modules loaded.)
:display:gsg:glgsg(error): An error occurred while compiling shader!
Vertex shader failed to compile with the following errors:
ERROR: 0:1: error(#132) Syntax error: '╚' parse error
ERROR: error(#273) 1 compilation errors.  No code generated
:display:gsg:glgsg(error): at 413 of c:\panda3d-1.7.0\panda\src\glstuff\glShader
Context_src.cxx : GL error 1281

Weird, it works for me. Perhaps it’s an issue in your driver.

I tried with ubuntu on same machine and it works also.

Vertex shader was successfully compiled to run on hardware.

Seems there might be a problem with ATI drivers on Windows 7.
So I’ll have to move my development to linux.

Thanks

That syntax error makes me think of the two hidden bytes that many Microsoft editors like to write at the beginning of a document to indicate the character encoding convention. Since this is a Microsoft-only convention, you don’t see these bytes when you load the file with another Microsoft editor, but they cause problems when you load them in another tool (for instance, the shader compiler).

Do the files you create on Linux, and copy unchanged to Windows, work there?

David

I used nodepad++ to create/edit files and encoding selected is ansi, so there shouldn’t be any extra symbols. The same files work fine under linux.

Also hex editor shows no extra symbols in the beginning.

i do have also problems to execute a basic gl shader under windows.

PT(Shader) myRuler = Shader::load(Shader.SL_GLSL,“myRuler.glsl”,"","");
Token ‘.’ after UDT ‘Shader’ illegal

i need to def. the empty strings. if not, my application crashs.

if im using, Shader.SLGLSL i get a declaration error. so i had to look into shader.h file to figure the right one out.

and while execution:

ERROR: compilation errors. No code generated.

ERROR: 0:1: ‘defined’ : syntax error parse error
ERROR: compilation errors. No code generated.

im using this fundamental shader from above.

would be cool if this bugs get fixed soon for windows.
i really wanna learn more about shaders, but if i cant execute the ones i need…

This is just a problem with C++ syntax. In C++, the scoping operator is “::”, not “.”, so this should be:
PT(Shader) myRuler =

Shader::load(Shader::SL_GLSL,"myRuler.glsl","","");

David

cool thanks.

but im getting still this error:

displaygsg_glgsg(error): An error occurred ...
vertex shader failed to compile with the following errors:
ERROR:  compilation errors.  No code generated.

ERROR: 0:1: 'defined' : syntax error parse error
ERROR:  compilation errors.  No code generated.
PT(Shader) myRuler = Shader::load(Shader::SL_GLSL,"myRuler.glsl","fragment.glsl","");
//GLSL
void main() {
  gl_Position = ftransform();
}
//GLSL
void main() {
  gl_FragColor = vec4(gl_Color.g, gl_Color.r, gl_Color.b, 1.0);
}

Here is visualisation for my issue

seems that c_str() returns invalid value.
replacing the line in question with this solves the issue

  string sText = _shader->get_text(type);
  const char* text = sText.c_str();

Ah, sorry! We just tracked down that very same bug in this other thread: https://discourse.panda3d.org/viewtopic.php?t=8579&start=30

The short answer is, this is now fixed in CVS, so you can download and compile your own version of Panda with the fix; or you can wait for the 1.7.1 which will include the fix.

David

Ok, I was pretty close to checkout 1.7.x. So I’ll give it a try.

I’m also getting some random assertion erros, hopefully these are fixed to.