[vtk-developers] GLSL Shader on a vtkActor (VTK 6.1 and Qt 5.2.1)

Carlos Martinez carlinhosmp87 at gmail.com
Tue Jul 8 14:14:23 EDT 2014


Thanks for your answer, i thought it wasn't the right way!

What do you mean when you say i have to load the shaders manually? The
steps i'm doing are:

1- Create a vtkShaderProgram2
2- Create the vtkShader2 (VertexShader) and load it from the file with
SetSourceCode.
3- Add my VertexShader to the vtkShaderProgram2 with
"GetShaders()->AddItem()".
4- Repeat 2 and 3 with the FragmentShader.
5- Build the vtkShaderProgram and check the Build Status (to check if
everything is ok).
6- Create a vtkActor and obtain his property(with GetProperty()).
7- Put ShadingOn to the property and SetPropProgram with the
vtkShaderProgram2 build before (The vtkShaderProgram on debug has only the
2 shaders I put in).

When the actors are going to display into the screen, the warning window
shows up and tells me that the main is defined twice (and shows me the
Default shaders and mine).

Thanks again!!


2014-07-08 18:25 GMT+02:00 Aashish Chaudhary <aashish.chaudhary at kitware.com>
:

> vtkOpenGLProperty::SetPropProgram is the right function but you have load your shaders manually now. I believe the error you are getting is because it is still trying to use the last shader code.
>
> - Aashish
>
>
>
> On Tue, Jul 8, 2014 at 3:15 AM, carlinhos <carlinhosmp87 at gmail.com> wrote:
>
>> Hi all,
>>
>> I'm using Vtk 6.1.0 and Qt 5.2.1 (C++) to develop my app.
>>
>> I have an assembly with different actors into a vtkRenderWindow.
>>
>> I load a shader with the class vtkShader2, and create the program with
>> vtkShaderProgram2, all ok with this. After that, i wanted to attach the
>> shader to the actors (i'm going to use different shaders, depending on the
>> actors). The problem is i didn't find examples or documentation to do this
>> and i'm not capable to use the classes for the shaders correctly.
>>
>> I searched into the class vtkOpenGLProperty to set the vtkShaderProgram2
>> with the method "SetPropProgram" and i set the property of the actors with
>> that one, but vtk shows me a warning window with a conflict between the
>> default shaders and mine (total 4 shaders, 2 vertex and 2 fragment).
>>
>> Can someone help me? Thanks in advance!!
>>
>>
>>
>> --
>> View this message in context:
>> http://vtk.1045678.n5.nabble.com/GLSL-Shader-on-a-vtkActor-VTK-6-1-and-Qt-5-2-1-tp5727788.html
>> Sent from the VTK - Dev mailing list archive at Nabble.com.
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/vtk-developers
>>
>>
>
>
> --
>
>
>
> *| Aashish Chaudhary | Technical Leader         | Kitware Inc.            *
> *| http://www.kitware.com/company/team/chaudhary.html
> <http://www.kitware.com/company/team/chaudhary.html>*
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20140708/0d9f7e80/attachment-0002.html>


More information about the vtk-developers mailing list