[vtkusers] How to direct use GLSL in vtk?

Patrik Spring patrikspring at yahoo.com.cn
Fri Jan 12 11:50:34 EST 2007


Hi:
   I write a function using GLSL like in C++; It can compile and link! but could not run!
  
   I do not know how to add it into vtk pipeline?
  
   Who can give me some good suggest?
  
  thanks!
  
  
  void initShader()
  {
  
      const vtkgl::GLchar* vs = "void  main(){    gl_Position = gl_ModelViewProjectionMatrix *  gl_Vertex ;    gl_FrontColor = gl_Color;} ";
      const vtkgl::GLchar* fs = "void main(){     gl_FragColor = vec4(1.0,0.0,0.0,0.0); }";
  
  
      /*
  run exception information:
  
  The thread 'Win32 Thread' (0x95c) has exited with code 0 (0x0).
  Unhandled exception at 0x00000000 in rainbow.exe: 0xC0000005: Access violation reading location 0x00000000.
  
      */
      vertShader = vtkgl::CreateShader(vtkgl::VERTEX_SHADER_ARB) ;  //error 
      fragShader = vtkgl::CreateShader(vtkgl::FRAGMENT_SHADER_ARB);
  
  
      const char * vv = vs;
      const char * ff = fs;
  
      vtkgl::ShaderSource( vertShader, 1, &vs, NULL );
      vtkgl::ShaderSource( fragShader, 1, &fs, NULL );
  
      vtkgl::CompileShader(vertShader);
      vtkgl::CompileShader(fragShader);
  
      programHandle = static_cast<GLuint>(vtkgl::CreateProgram());
      vtkgl::AttachShader(programHandle,vertShader);
      vtkgl::AttachShader(programHandle,fragShader);
  
      vtkgl::LinkProgram(programHandle);
  
      vtkgl::UseProgram(programHandle);
  
  }
    
  
  
 		
---------------------------------
抢注雅虎免费邮箱-3.5G容量,20M附件! 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20070113/6d492082/attachment.htm>


More information about the vtkusers mailing list