[vtk-developers] vtkGLSLShaderStuff
Utkarsh Ayachit
utkarsh.ayachit at kitware.com
Tue Nov 29 09:17:12 EST 2005
One solution is to use an Adaptor (just as the"Painters" use the
vtkPainterDeviceAdapter). The GLSLAdaptor can provide the GL
extension/version independent API to create program etc. The
GLSLShaderProgram/GLSLShader can safely defer the instantiation of the
adaptor until after the rendering context is available.
Utkarsh
John Biddiscombe wrote:
> The vtkGLSLShader and vtkGLSLShaderProgram code use OpenGL2 calls to do
> their stuff. However, OpenGL1.5+extensions is adequate for many GLSL
> programs. I've altered the code so that it will use extensions if
> available but I have a question...
>
> Currently, I've modified vtkGLSLShaderProgram, vtkGLSLShader so that all
> calls to vtkgl::CreateProgram(...) are replaced with something like
> if (GL2Supported())
> vtkgl::CreateProgram(...)
> }
> else {
> vtkgl::CreateProgramARB(...)
> }
>
> with all the GL2 calls replaced by equivalent functionality for
> GL1.5+ext, however I don't like it because it's untidy and I'd much
> rather create new classes like vtkGL15ShaderProgram & vtkGL15Shader
> which will simply be implementations using the extension code.
>
> The trouble is that the vtkGLSLShaderXXX classes are instantiated inside
> vtkShaderProgram:::CreateShaderProgram and the vtkShaderProgram only
> knows if OpenGL2 is available (or which extensions are available) when a
> rendering context is ready and this happens when the property first
> calls "render". Unfortunately, by this time the
> Cg/GLSL/XXXX/shaderprograms have been created and so it's too late to
> instantiate an extension specific class.
>
> I'd like to keep the GLSL code clean and have an extension specific
> class. Some kind of proxy maybe. Would anyone like to make a suggestion.
>
> thanks
>
> JB
> PS. Kitware people, please may I have cvs write access back.
>
More information about the vtk-developers
mailing list