[vtkusers] [Fwd: Re: Using OpenGl with VTK]
Mohammed Amine SAHTARI
msahtari at gmail.com
Tue Aug 19 09:22:44 EDT 2008
I use vtkStandardNewMacro to add New macro. The problem is that I got 5 link
errors even if I include the librairies of VTK (In VS 8).
Hereby, you find my derived class (.h & .cxx).
---------------- vtkMyDerivedProp.h -------------------------
#ifndef __vtkMyDerivedProp_h
#define __vtkMyDerivedProp_h
#include "vtkProp.h"
class VTK_RENDERING_EXPORT vtkMyDerivedProp : public vtkProp
{
public:
vtkTypeRevisionMacro(vtkMyDerivedProp,vtkProp);
void PrintSelf(ostream& os, vtkIndent indent);
static vtkMyDerivedProp* New();
protected:
vtkMyDerivedProp();
~vtkMyDerivedProp();
private:
vtkMyDerivedProp(const vtkMyDerivedProp&); // Not implemented.
void operator=(const vtkMyDerivedProp&); // Not implemented.
};
#endif
---------------- vtkMyDerivedProp.cxx -------------------------
#include "vtkMyDerivedProp.h"
#include "vtkObjectFactory.h"
vtkCxxRevisionMacro(vtkMyDerivedProp, "$Revision: 1.36 $");
vtkStandardNewMacro(vtkMyDerivedProp);
vtkMyDerivedProp::vtkMyDerivedProp(){}
vtkMyDerivedProp::~vtkMyDerivedProp(){}
void vtkMyDerivedProp::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os,indent);
}
-------------------------------------- Errors
------------------------------------------
*I got 5 errors *
1>vtkMyDerivedProp.obj : error LNK2001: unresolved external symbol "private:
virtual char const * __thiscall
vtkMyDerivedProp::GetClassNameInternal(void)const "
(?GetClassNameInternal at vtkMyDerivedProp@@EBEPBDXZ)
1>vtkMyDerivedProp.obj : error LNK2001: unresolved external symbol "public:
virtual int __thiscall vtkMyDerivedProp::IsA(char const *)"
(?IsA at vtkMyDerivedProp@@UAEHPBD at Z)
1>vtkMyDerivedProp.obj : error LNK2001: unresolved external symbol
"protected: virtual class vtkObjectBase * __thiscall
vtkMyDerivedProp::NewInstanceInternal(void)const "
(?NewInstanceInternal at vtkMyDerivedProp@@MBEPAVvtkObjectBase@@XZ)
1>vtkMyDerivedProp.obj : error LNK2019: unresolved external symbol
"__declspec(dllimport) const vtkMyDerivedProp::`vftable'"
(__imp_??_7vtkMyDerivedProp@@6B@) referenced in function "protected:
__thiscall vtkMyDerivedProp::vtkMyDerivedProp(void)" (??0vtkMyDerivedProp@
@IAE at XZ)
1>C:\Documents and Settings\asahtari\Mes
documents\Projet\Bibillothéques\VTK\MyTest\MyLib.dll : fatal error LNK1120:
4 unresolved externals
When I put vtkMyDerivedProp instead of vtkProp3D, it compiles without any
error.
I don't understand .Is it a matter of VTK librairies ? Please Help!
Amine
2008/8/14 Utkarsh Ayachit <utkarsh.ayachit at kitware.com>
> 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
>>
>>
>>
> _______________________________________________
> 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/20080819/2b87c287/attachment.htm>
More information about the vtkusers
mailing list