I apologize, you are right : I mean glPopAttrib() for (3). I try it but it doesn't work......do you have any suggestion please?<br><br>
<div><span class="gmail_quote">2008/8/20, Francois Bertel <<a href="mailto:francois.bertel@kitware.com">francois.bertel@kitware.com</a>>:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">What do you mean by glPopAttrib() for (2)? It should be for (3).<br><br><br><br>On Wed, Aug 20, 2008 at 12:04 PM, Mohammed Amine SAHTARI<br>
<<a href="mailto:msahtari@gmail.com">msahtari@gmail.com</a>> wrote:<br>><br>> Thank you very much François. It works!<br>><br>> In order to be able ,in future, to copy a large code of OpenGl directly<br>
> without checking each time all the OpenGl states. Is there a way to:<br>><br>> 1) Store the whole state of the VTK/OpenGl properties : light,colors,.....<br>> 2) copy the code OpenGl code in my function<br>
> 3) restore VTK/OpenGl state properties<br>><br>> For example, I try glPushAttrib(GL_ALL_ATTRIB_BITS) for (1) , and<br>> glPopAttrib() for (2) but it doesn't work.<br>><br>> Do you have any idea ?<br>
><br>> Thank you for responding,<br>><br>> Amine<br>><br>> 2008/8/20 Francois Bertel <<a href="mailto:francois.bertel@kitware.com">francois.bertel@kitware.com</a>><br>>><br>>> Maybe lighting is on. In this case, the color is the result of the<br>
>> lighting equation involving material properties, normals and lights<br>>> properties instead of the current OpenGL color:<br>>><br>>> Try glDisable(GL_LIGHTING);<br>>><br>>> On Wed, Aug 20, 2008 at 4:43 AM, Mohammed Amine SAHTARI<br>
>> <<a href="mailto:msahtari@gmail.com">msahtari@gmail.com</a>> wrote:<br>>> > The background is gray and The OpenGl lines has been dispalyed as gray !<br>>> > When I change the background of my screen I was able to visualize<br>
>> > the<br>>> > Opengl lines/faces.<br>>> ><br>>> > I am wondering why the OpenGL lines is grey knowing that i am using<br>>> > glColor3f [(1,0,0);(0,1,0),..] in RenderOpaqueGeometry which should<br>
>> > affect<br>>> > other colors to the lines ?!<br>>> ><br>>> > Shall I enable/change an option to fix this matter ? ...Please help!<br>>> ><br>>> > Amine<br>>> ><br>
>> ><br>>> ><br>>> > 2008/8/19 Mohammed Amine SAHTARI <<a href="mailto:msahtari@gmail.com">msahtari@gmail.com</a>><br>>> >><br>>> >> Thank you very much Amy. The program compiles without any errors!<br>
>> >><br>>> >> However , I still have a problem : The OpenGl lines doesn't display<br>>> >> on<br>>> >> the screen.<br>>> >><br>>> >> I check In Debug Mode, the RenderOpaqueGeometry function is executed<br>
>> >> permanently ( following the pipeline).<br>>> >><br>>> >><br>>> >><br>>> >> ----- In the main propram----------<br>>> >><br>>> >> .............<br>
>> >><br>>> >> vtkRenderer *renderer = vtkRenderer ::New();<br>>> >><br>>> >> vtkMyDerivedProp-> RenderOpaqueGeometry(renderer);<br>>> >><br>>> >> renderer->AddProp(vtkMyDerivedProp);<br>
>> >><br>>> >> ...........<br>>> >><br>>> >> ---- In Myderived class----------------<br>>> >><br>>> >> virtual int RenderOpaqueGeometry(vtkViewPort* )<br>
>> >><br>>> >> {<br>>> >><br>>> >> glBegin (GL_LINES);<br>>> >><br>>> >> glVertex2f (-2.5, 2.5);<br>>> >> glVertex2f (2.5, -2.5);<br>
>> >> glEnd ();<br>>> >> }<br>>> >><br>>> >> Any suggestions ? Did I miss something ?<br>>> >><br>>> >> Thank you in advance,<br>>> >> Amine<br>
>> >><br>>> >><br>>> >> 2008/8/19 Amy Squillacote <<a href="mailto:ahs@cfdrc.com">ahs@cfdrc.com</a>><br>>> >>><br>>> >>> Hi Amine,<br>>> >>><br>
>> >>> You cannot use VTK_RENDERING_EXPORT since you are not adding your<br>>> >>> class<br>>> >>> to the vtkRendering library. You'll need to create your own export<br>>> >>> macro.<br>
>> >>> There is an example of setting up your own additional library for VTK<br>>> >>> in the<br>>> >>> VTK/Examples/Build/vtkLocal directory of the VTK source tree.<br>>> >>><br>
>> >>> - Amy<br>>> >>><br>>> >>> Mohammed Amine SAHTARI wrote:<br>>> >>>><br>>> >>>> I use vtkStandardNewMacro to add New macro. The problem is that I got<br>
>> >>>> 5<br>>> >>>> link errors even if I include the librairies of VTK (In VS 8).<br>>> >>>><br>>> >>>> Hereby, you find my derived class (.h & .cxx).<br>
>> >>>><br>>> >>>> ---------------- vtkMyDerivedProp.h -------------------------<br>>> >>>><br>>> >>>> #ifndef __vtkMyDerivedProp_h<br>>> >>>> #define __vtkMyDerivedProp_h<br>
>> >>>> #include "vtkProp.h"<br>>> >>>><br>>> >>>> class VTK_RENDERING_EXPORT vtkMyDerivedProp : public vtkProp<br>>> >>>> {<br>>> >>>> public:<br>
>> >>>><br>>> >>>> vtkTypeRevisionMacro(vtkMyDerivedProp,vtkProp);<br>>> >>>> void PrintSelf(ostream& os, vtkIndent indent);<br>>> >>>> static vtkMyDerivedProp* New();<br>
>> >>>><br>>> >>>> protected:<br>>> >>>><br>>> >>>> vtkMyDerivedProp();<br>>> >>>> ~vtkMyDerivedProp();<br>>> >>>><br>
>> >>>> private:<br>>> >>>><br>>> >>>> vtkMyDerivedProp(const vtkMyDerivedProp&); // Not implemented.<br>>> >>>> void<br>>> >>>> operator=(const vtkMyDerivedProp&); // Not implemented.<br>
>> >>>><br>>> >>>> };<br>>> >>>><br>>> >>>> #endif<br>>> >>>><br>>> >>>> ---------------- vtkMyDerivedProp.cxx -------------------------<br>
>> >>>><br>>> >>>> #include "vtkMyDerivedProp.h"<br>>> >>>><br>>> >>>> #include "vtkObjectFactory.h"<br>>> >>>><br>
>> >>>> vtkCxxRevisionMacro(vtkMyDerivedProp, "$Revision: 1.36 $");<br>>> >>>><br>>> >>>> vtkStandardNewMacro(vtkMyDerivedProp);<br>>> >>>><br>
>> >>>> vtkMyDerivedProp::vtkMyDerivedProp(){}<br>>> >>>><br>>> >>>> vtkMyDerivedProp::~vtkMyDerivedProp(){}<br>>> >>>><br>>> >>>> void vtkMyDerivedProp::PrintSelf(ostream& os, vtkIndent indent)<br>
>> >>>> {<br>>> >>>> this->Superclass::PrintSelf(os,indent);<br>>> >>>> }<br>>> >>>><br>>> >>>> -------------------------------------- Errors<br>
>> >>>> ------------------------------------------<br>>> >>>><br>>> >>>> *I got 5 errors *<br>>> >>>><br>>> >>>> 1>vtkMyDerivedProp.obj : error LNK2001: unresolved external symbol<br>
>> >>>> "private: virtual char const * __thiscall<br>>> >>>> vtkMyDerivedProp::GetClassNameInternal(void)const "<br>>> >>>> (?GetClassNameInternal@vtkMyDerivedProp@@EBEPBDXZ)<br>
>> >>>><br>>> >>>> 1>vtkMyDerivedProp.obj : error LNK2001: unresolved external symbol<br>>> >>>> "public: virtual int __thiscall vtkMyDerivedProp::IsA(char const *)"<br>
>> >>>> (?IsA@vtkMyDerivedProp@@UAEHPBD@Z)<br>>> >>>><br>>> >>>> 1>vtkMyDerivedProp.obj : error LNK2001: unresolved external symbol<br>>> >>>> "protected: virtual class vtkObjectBase * __thiscall<br>
>> >>>> vtkMyDerivedProp::NewInstanceInternal(void)const "<br>>> >>>> (?NewInstanceInternal@vtkMyDerivedProp@@MBEPAVvtkObjectBase@@XZ)<br>>> >>>><br>>> >>>> 1>vtkMyDerivedProp.obj : error LNK2019: unresolved external symbol<br>
>> >>>> "__declspec(dllimport) const vtkMyDerivedProp::`vftable'"<br>>> >>>> (__imp_??_7vtkMyDerivedProp@@6B@) referenced in function "protected:<br>>> >>>> __thiscall vtkMyDerivedProp::vtkMyDerivedProp(void)"<br>
>> >>>> (??0vtkMyDerivedProp@@IAE@XZ)<br>>> >>>><br>>> >>>> 1>C:\Documents and Settings\asahtari\Mes<br>>> >>>> documents\Projet\Bibillothéques\VTK\MyTest\MyLib.dll : fatal error<br>
>> >>>> LNK1120:<br>>> >>>> 4 unresolved externals<br>>> >>>><br>>> >>>> When I put vtkMyDerivedProp instead of vtkProp3D, it compiles without<br>>> >>>> any error.<br>
>> >>>> I don't understand .Is it a matter of VTK librairies ? Please Help!<br>>> >>>><br>>> >>>> Amine<br>>> >>>><br>>> >>>> 2008/8/14 Utkarsh Ayachit <<a href="mailto:utkarsh.ayachit@kitware.com">utkarsh.ayachit@kitware.com</a><br>
>> >>>> <mailto:<a href="mailto:utkarsh.ayachit@kitware.com">utkarsh.ayachit@kitware.com</a>>><br>>> >>>><br>>> >>>> Please keep the questions to the mailing list, so that others can<br>
>> >>>> benefit/contribute as well.<br>>> >>>><br>>> >>>> To add New():<br>>> >>>> * take a look at any concrete class in VTK eg. vtkCollection (the<br>
>> >>>> New is<br>>> >>>> declared in the header and defined using<br>>> >>>> vtkStandardNewMacro(vtkCollection); in the cxx.<br>>> >>>><br>
>> >>>> * not using the viewport in the RenderOpaqueGeometry should not be<br>>> >>>> a<br>>> >>>> problem. It's only provided if needed.<br>>> >>>><br>
>> >>>> Utkarsh<br>>> >>>><br>>> >>>><br>>> >>>><br>>> >>>><br>>> >>>> Mohammed Amine SAHTARI wrote:<br>>> >>>><br>
>> >>>> Thank you very much Utkarsh.<br>>> >>>><br>>> >>>> I am tring to implement your solution but I have some<br>>> >>>> problems.<br>
>> >>>><br>>> >>>> 1) I create vtkMyDerivedProp.h and vtkMyDerivedProp.cxx<br>>> >>>><br>>> >>>> I subclass vtkProp :<br>>> >>>> - I copy the class code of vtkProp3D (.h and .c files)<br>
>> >>>> - I replace all the words :<br>>> >>>> vtkProp3D /by/ /vtkMyDerivedProp /and Prop3D by<br>>> >>>> /MyDerivedProp/<br>>> >>>> - I include /"vtkGl.h"/ in vtkMyDerivedProp.h<br>
>> >>>> - I add RenderOpaqueGeometry() in vtkMyDerivedProp.h<br>>> >>>> like this :<br>>> >>>> /virtual int RenderOpaqueGeometry(vtkViewPort* )<br>
>> >>>> {/<br>>> >>>><br>>> >>>> / glBegin (GL_LINES);<br>>> >>>><br>>> >>>> glVertex2f (-2.5, 2.5);<br>
>> >>>><br>>> >>>> glVertex2f (2.5, -2.5);<br>>> >>>><br>>> >>>><br>>> >>>> glEnd ();/<br>>> >>>><br>
>> >>>> / }/<br>>> >>>><br>>> >>>> 2) In my program : - I include and instantiate<br>>> >>>> vtkMyDerivedProp :<br>
>> >>>><br>>> >>>> / //# include "vtkMyDerivedProp.h"<br>>> >>>> vtkMyDerivedProp *MyDerivedProp;/<br>>> >>>><br>>> >>>> - I use vtkMyDerivedProp :<br>
>> >>>><br>>> >>>> / vtkRenderer *renderer = vtkRenderer ::New();/<br>>> >>>><br>>> >>>> / vtkMyDerivedProp-> RenderOpaqueGeometry(renderer);/<br>
>> >>>><br>>> >>>> / renderer->AddProp(vtkMyDerivedProp);/<br>>> >>>><br>>> >>>><br>>> >>>> *Problem *: vtkMyDerivedProp is used without been defined!<br>
>> >>>><br>>> >>>> *Question 1 :* How can I define it ?<br>>> >>>> (vtkMyDerivedProp::New() doesn't work)<br>>> >>>><br>>> >>>> *Question 2 :* RenderOpaqueGeometry has vtkViewPort* in input<br>
>> >>>> but doesn't use it. Is it a problem ?<br>>> >>>><br>>> >>>> How can I fix this?<br>>> >>>><br>>> >>>> Looking forward to hear from you soon,<br>
>> >>>><br>>> >>>> Amine**<br>>> >>>><br>>> >>>><br>>> >>>><br>>> >>>><br>>> >>>><br>>> >>>> 2008/8/14 Utkarsh Ayachit <<a href="mailto:utkarsh.ayachit@kitware.com">utkarsh.ayachit@kitware.com</a><br>
>> >>>> <mailto:<a href="mailto:utkarsh.ayachit@kitware.com">utkarsh.ayachit@kitware.com</a>><br>>> >>>> <mailto:<a href="mailto:utkarsh.ayachit@kitware.com">utkarsh.ayachit@kitware.com</a><br>
>> >>>> <mailto:<a href="mailto:utkarsh.ayachit@kitware.com">utkarsh.ayachit@kitware.com</a>>>><br>>> >>>><br>>> >>>> iren->Start() results in repeated calls to renWin->Render()<br>
>> >>>> on<br>>> >>>> interaction. This will clear whatever you had drawn. A<br>>> >>>> better<br>>> >>>> approach is to subclass vtkProp(or one of it's subclasses)<br>
>> >>>> and put<br>>> >>>> your rendering code in RenderOpaqueGeometry() /<br>>> >>>> RenderTranslucentPolygonalGeometry()/ RenderOverlay() etc.<br>
>> >>>> depending<br>>> >>>> upon what pass you want it to be rendered and then add the<br>>> >>>> prop to<br>>> >>>> the renderer. That way every time the renderer re-renders,<br>
>> >>>> your code<br>>> >>>> will be executed.<br>>> >>>><br>>> >>>><br>>> >>>> Utkarsh<br>>> >>>><br>
>> >>>> Mohammed Amine SAHTARI wrote:<br>>> >>>><br>>> >>>><br>>> >>>> I want to add an OpenGl code in an application of VTK.<br>
>> >>>><br>>> >>>> For this purpose, I try to draw lines using commands<br>>> >>>> OpenGL.:<br>>> >>>><br>>> >>>> *1) I add this on the top of the program :*<br>
>> >>>><br>>> >>>> #include <GL/gl.h><br>>> >>>> *2) I place my OpenGL commands after renWin->Render()<br>>> >>>> but before<br>
>> >>>> iren->Start()** : *<br>>> >>>><br>>> >>>><br>>> >>>> renWin->Render();<br>>> >>>><br>>> >>>> glBegin (GL_LINES);<br>
>> >>>> glVertex2f (-2.5, 2.5);<br>>> >>>> glVertex2f (2.5, -2.5);<br>>> >>>> glEnd ();<br>>> >>>><br>
>> >>>> iren->Start();<br>>> >>>><br>>> >>>><br>>> >>>> *But it doesn't appears.*<br>>> >>>><br>
>> >>>> did I miss something ? How can I do this work ?<br>>> >>>> Looking forward to hear from you soon,<br>>> >>>><br>>> >>>> Amine<br>
>> >>>><br>>> >>>><br>>> >>>><br>>> >>>><br>>> >>>><br>>> >>>> ------------------------------------------------------------------------<br>
>> >>>><br>>> >>>> _______________________________________________<br>>> >>>> This is the private VTK discussion list.<br>>> >>>> Please keep messages on-topic. Check the FAQ at:<br>
>> >>>> <a href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a><br>>> >>>> Follow this link to subscribe/unsubscribe:<br>>> >>>> <a href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
>> >>>><br>>> >>>><br>>> >>>><br>>> >>>> _______________________________________________<br>>> >>>> This is the private VTK discussion list.<br>
>> >>>> Please keep messages on-topic. Check the FAQ at:<br>>> >>>> <a href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a><br>>> >>>> Follow this link to subscribe/unsubscribe:<br>
>> >>>> <a href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>>> >>>><br>>> >>>><br>>> >>>><br>
>> >>>> ------------------------------------------------------------------------<br>>> >>>><br>>> >>>> _______________________________________________<br>>> >>>> This is the private VTK discussion list.<br>
>> >>>> Please keep messages on-topic. Check the FAQ at:<br>>> >>>> <a href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a><br>>> >>>> Follow this link to subscribe/unsubscribe:<br>
>> >>>> <a href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>>> >>>><br>>> >>><br>>> >>> --<br>>> >>> Amy Squillacote Phone: (256) 726-4839<br>
>> >>> Computer Scientist Fax: (256) 726-4806<br>>> >>> CFD Research Corporation Web: <a href="http://www.cfdrc.com">http://www.cfdrc.com</a><br>>> >>> 215 Wynn Drive, Suite 501<br>
>> >>> Huntsville, AL 35805<br>>> >>><br>>> >>><br>>> >><br>>> ><br>>> ><br>>> > _______________________________________________<br>>> > This is the private VTK discussion list.<br>
>> > Please keep messages on-topic. Check the FAQ at:<br>>> > <a href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a><br>>> > Follow this link to subscribe/unsubscribe:<br>
>> > <a href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>>> ><br>>> ><br>>><br>>><br>>><br>>> --<br>>> François Bertel, PhD | Kitware Inc. Suite 204<br>
>> 1 (518) 371 3971 x113 | 28 Corporate Drive<br>>> | Clifton Park NY 12065, USA<br>>> _______________________________________________<br>>> This is the private VTK discussion list.<br>>> Please keep messages on-topic. Check the FAQ at:<br>
>> <a href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a><br>>> Follow this link to subscribe/unsubscribe:<br>>> <a href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
><br>><br><br><br><br>--<br>François Bertel, PhD | Kitware Inc. Suite 204<br>1 (518) 371 3971 x113 | 28 Corporate Drive<br>| Clifton Park NY 12065, USA<br>_______________________________________________<br>This is the private VTK discussion list.<br>
Please keep messages on-topic. Check the FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a><br>Follow this link to subscribe/unsubscribe:<br><a href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
</blockquote></div><br>