[vtkusers] Cg compile erro in VTK

捷 冯 conan0316 at yahoo.com.cn
Mon Mar 3 23:55:20 EST 2008


Hi everyone,
    Recently, I have been working on shaders in VTK. I use vtkProperty::LoadMaterial() to load the xml file successfully. But an error comes out while compiling the code. 
  It says:
  ERROR: In ..\..\VTK\Rendering\vtkCgShader.cxx, line 303
vtkCgShader (032BB718): CG ERROR : The compile returned an error.
  ERROR: In ..\..\VTK\Rendering\vtkCgShader.cxx, line 306
vtkCgShader (032BB718): (51) : error C0000: syntax error, unexpected $undefined at token "<undefined>"
(51) : error C0501: type name expected at token "<undefined>"
  
ERROR: In ..\..\VTK\Rendering\vtkCgShader.cxx, line 265
vtkCgShader (032BB718): Failed to create Cg program. 
   
  I don't know why and want your help. Thanks.
   
  My shader code is:
  vertex shader:
  struct C2E1v_Output {
  float4 position : POSITION;
  float4 color    : COLOR;
};
  C2E1v_Output main(uniform float2 position : POSITION)
{
  C2E1v_Output OUT;
    OUT.position = float4(position, 0, 1);
  OUT.color    = float4(0, 1, 0, 1);  // RGBA green
    return OUT; 
}

  fragment shader:
  struct C2E2f_Output {
  float4 color : COLOR;
};
  C2E2f_Output main(uniform float4 color : COLOR)
{
  C2E2f_Output OUT;
  OUT.color = color;
  return OUT;
}
   
  xml file is:
  <?xml version="1.0" encoding="UTF-8"?>
<Material name="Mat1" NumberOfProperties="1" NumberOfVertexShaders="1" NumberOfFragmentShaders="1">>
    <Shader scope="Vertex" name="Vertex" location="Vertex.cg" language="Cg" entry="main" args="-DVERTEX_PROGRAM">
  </Shader>
    <Shader scope="Fragment" name="TestCgStructureFrag" location="StructureFragmentTest.cg" language="Cg" entry="fragment_program" args="-DFRAGMENT_PROGRAM">
  </Shader>
  </Material>
It's very simple.
   
  I hope you guys can help me.
  Thanks again.

       
---------------------------------
雅虎邮箱传递新年祝福,个性贺卡送亲朋! 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080304/2991dd80/attachment.htm>


More information about the vtkusers mailing list