[vtkusers] Using OpenGl with VTK
Mohammed Amine SAHTARI
msahtari at gmail.com
Thu Aug 14 11:43:19 EDT 2008
Thank you very much Utkarsh.
I am tring to implement your solution but I have some problems.
1) I create vtkMyDerivedProp.h and vtkMyDerivedProp.cxx
I subclass vtkProp :
- I copy the class code of vtkProp3D (.h and .c files)
- I replace all the words :
vtkProp3D *by* *vtkMyDerivedProp *and Prop3D by *
MyDerivedProp*
- I include *"vtkGl.h"* in vtkMyDerivedProp.h
- I add RenderOpaqueGeometry() in vtkMyDerivedProp.h like this :
*virtual int RenderOpaqueGeometry(vtkViewPort* )
{*
* glBegin (GL_LINES);
glVertex2f (-2.5, 2.5);
glVertex2f (2.5, -2.5);
glEnd ();*
* }*
2) In my program :
- I include and instantiate vtkMyDerivedProp :
* **# include "vtkMyDerivedProp.h"
vtkMyDerivedProp *MyDerivedProp;*
- I use vtkMyDerivedProp :
* vtkRenderer *renderer = vtkRenderer ::New();*
* vtkMyDerivedProp-> RenderOpaqueGeometry(renderer);*
* renderer->AddProp(vtkMyDerivedProp);*
*Problem *: vtkMyDerivedProp is used without been defined!
*Question 1 :* How can I define it ? (vtkMyDerivedProp::New() doesn't
work)
*Question 2 :* RenderOpaqueGeometry has vtkViewPort* in input but doesn't
use it. Is it a problem ?
How can I fix this?
Looking forward to hear from you soon,
Amine
2008/8/14 Utkarsh Ayachit <utkarsh.ayachit at kitware.com>
> iren->Start() results in repeated calls to renWin->Render() on interaction.
> This will clear whatever you had drawn. A better approach is to subclass
> vtkProp(or one of it's subclasses) and put your rendering code in
> RenderOpaqueGeometry() / RenderTranslucentPolygonalGeometry()/
> RenderOverlay() etc. depending upon what pass you want it to be rendered and
> then add the prop to the renderer. That way every time the renderer
> re-renders, your code will be executed.
>
>
> Utkarsh
>
> Mohammed Amine SAHTARI wrote:
>
>>
>> I want to add an OpenGl code in an application of VTK.
>>
>> For this purpose, I try to draw lines using commands OpenGL.:
>>
>> *1) I add this on the top of the program :*
>>
>> #include <GL/gl.h>
>> *2) I place my OpenGL commands after renWin->Render() but before
>> iren->Start()** : *
>>
>>
>> renWin->Render();
>>
>> glBegin (GL_LINES);
>> glVertex2f (-2.5, 2.5);
>> glVertex2f (2.5, -2.5);
>> glEnd ();
>>
>> iren->Start();
>>
>>
>> *But it doesn't appears.*
>>
>> did I miss something ? How can I do this work ?
>> Looking forward to hear from you soon,
>>
>> Amine
>>
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> This is the private VTK discussion list.
>> Please keep messages on-topic. Check the FAQ at:
>> http://www.vtk.org/Wiki/VTK_FAQ
>> Follow this link to subscribe/unsubscribe:
>> http://www.vtk.org/mailman/listinfo/vtkusers
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080814/27682bfb/attachment.htm>
More information about the vtkusers
mailing list