[vtkusers] [Fwd: Re: Using OpenGl with VTK]
Utkarsh Ayachit
utkarsh.ayachit at kitware.com
Thu Aug 14 11:45:17 EDT 2008
Please keep the questions to the mailing list, so that others can
benefit/contribute as well.
To add New():
* take a look at any concrete class in VTK eg. vtkCollection (the New is
declared in the header and defined using
vtkStandardNewMacro(vtkCollection); in the cxx.
* not using the viewport in the RenderOpaqueGeometry should not be a
problem. It's only provided if needed.
Utkarsh
Mohammed Amine SAHTARI wrote:
> 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
> <mailto: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
>
>
More information about the vtkusers
mailing list