template <class arg>
struct VERTEX_BEGIN : arg
{
long FVF;
VERTEX_BEGIN()
{
FVF = 0;
super();
}
};
template <class arg>
struct VERTEX_POS : arg
{
D3DXVECTOR3 pos;
VERTEX_POS()
{
FVF = FVF | D3DFVF_XYZ;
super();
}
};
struct VERTEX_END
{
//NOTHIN
};
as you can see, the template arguements define parent classes. Now as long as I don''t define a vertex, these classes will compile. but if I try to define my_vertex as a VERTEX_BEGIN>, I get the following errors:
d:\Source Code\Isis\Isis\Direct3DRenderer.cpp(13): error C2947: expecting ''>'' to terminate template-argument-list, found ''>>''
d:\Source Code\Isis\Isis\Direct3DRenderer.cpp(13): error C2146: syntax error : missing '','' before identifier ''my_vertex''
d:\Source Code\Isis\Isis\Direct3DRenderer.cpp(13): error C2065: ''my_vertex'' : undeclared identifier
d:\Source Code\Isis\Isis\Direct3DRenderer.cpp(13): error C2143: syntax error : missing ''>'' before '';''
d:\Source Code\Isis\Isis\Direct3DRenderer.cpp(13): error C2976: ''VERTEX_BEGIN'' : too few template arguments
thats about all i can give ya at the moment. Any help would be greatly appreciated. Thanky
Nested C++ templates: Is it possible?
Ok, I''m working on a flexible vertex format system for my engine, and I am just dicking around with some templates (the project isn''t serious, so don''t get on my case about efficiency.
a vertex with a single pos entry would be declared as such:
VERTEX_BEGIN> my_vertex;
here are the structure definitions:
Your post is a little hard to understand completely. Are you doing this?
what are you using to declare your variable?
VERTEX_BEGIN<VERTEX_POS<SomeClassName>> MyVertex;
what are you using to declare your variable?
you have you put a space between your two end template greater than signs otherwise it will be interpreted as the right shift operator.
VERTEX_BEGIN<VERTEX_POS<VERTEX_END> > my_vertex; // note the space/* usually I put spaces always before the end template greater than sign and after the opening one just to make it look more balanced as well */VERTEX_BEGIN< VERTEX_POS< VERTEX_END > > my_vertex2;
thanks, I knew it was something like that
I also had the order screwed up
is what i should have.
now I need to get these working with direct3d
I also had the order screwed up
template <class arg>struct VERTEX_BEGIN : arg{};template <class arg>struct VERTEX_POS : public arg{ D3DXVECTOR3 pos; VERTEX_POS() { FVF = FVF | D3DFVF_XYZ; }};struct VERTEX_END{ long FVF; VERTEX_END() { FVF = 0; }};
is what i should have.
now I need to get these working with direct3d
And also, I can''t have the FVF member IN the class, because it messed up how Direct3D likes its FVFs. How can I make it so FVF isn''t in the class, but there is a unique one for every vertex (it is being modified by all the ctors.
thanks again
thanks again
quote:Original post by Grizwald
the project isn''t serious, so don''t get on my case about efficiency.
Templates are often very efficient.
: Expression Templates: see links at bottom of article
e.g. Matrix Template Library.
quote:Original post by Grizwald
And also, I can't have the FVF member IN the class, because it messed up how Direct3D likes its FVFs. How can I make it so FVF isn't in the class, but there is a unique one for every vertex (it is being modified by all the ctors.
thanks again
You can compute the FVF, IIRC. <-- No it was the otherway around.
You CAN put the FVF in the begin structure, and let each derived class add a flag.
--
You're Welcome,
Rick Wong
- Google | Google for GameDev.net | GameDev.net's DirectX FAQ. (not as cool as the Graphics and Theory FAQ)
[edited by - Pipo DeClown on June 7, 2004 6:12:37 AM]
[edited by - Pipo DeClown on June 7, 2004 6:13:38 AM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement