📄 polygon.h
字号:
/*******************************************************************
* Advanced 3D Game Programming using DirectX 9.0
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* copyright (c) 2003 by Peter A Walsh and Adrian Perez
* See license.txt for modification and distribution information
******************************************************************/
#ifndef _POLYGON3_H
#define _POLYGON3_H
template <class type>
struct polygon
{
int nElem; // number of elements in the polygon
int maxElem;
type *pList;
polygon()
{
nElem = 0;
maxElem = 0;
pList = NULL;
}
polygon( int maxSize )
{
maxElem = maxSize;
pList = new type[maxSize];
}
polygon( const polygon &in )
{
CloneData( in );
}
~polygon()
{
DestroyData();
}
void CloneData( const polygon &in )
{
if( !in.pList )
return;
pList = new type[in.maxElem];
maxElem = in.maxElem;
nElem = in.nElem;
for( int i=0; i<in.nElem; i++ )
{
pList[i] = in.pList[i];
}
}
void DestroyData( )
{
if( pList )
{
delete[] pList;
}
pList = NULL;
}
polygon& operator=( const polygon<type> &in )
{
if( &in != this )
{
DestroyData();
CloneData( in );
}
return *this;
}
};
#endif /*_POLYGON3_H*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -