I run in a little problem now
at the top you see the typedef with 256 which created a cross:map with an array
T[256][256]
so far so good everything works ok as long as i don t insert a nummer > 256
if i insert 512 the application instantly crashes without printing the std:cerr at all
so something must be screwed i use the VC++ toolkit 2003
any idea on what s going wrong?
this piece of code instanciates the map
typedef cross::map<float,256> map32;int main(int argc,char *argv[]){ std::cerr<<"short: "<<map32::MAP_SIZE<<std::endl; map32 maps; cross::fillmap<map32>(maps); cross::smoothmap<map32>(maps); cross::smoothmap<map32>(maps); cross::smoothmap<map32>(maps); maps.dump8(std::string("test.raw")); return 0;}
2. class declaration and implementation of fillmap +dump8
//template quadratic map class template<class T, uint32 uiSize> class map { public: //typedefs and enums //type specific definition of size to allow unrolling of loops enum {MAP_SIZE = uiSize}; typedef T type_name; public: //member functions constructors & destructors //fills the map with zero map():m_uiSize(uiSize) { T tFill = 0; std::fill<T*,T>(&m_Map[0][0],&m_Map[uiSize-1][uiSize-1],tFill); }; //dumps a 8bit heightmap void dump8(std::string strFilename) { uint32 i; uint32 j; std::ofstream file; file.open(strFilename.c_str()); for(i=0;i<uiSize;i++) { for(j=0;j<uiSize;j++) { file << static_cast<uchar8>((m_Map[j] + 1.0f)*127); } } file.close(); }; public: //friend function declarations to access private members template<class U> friend void fillmap(U &x); template<class U> friend void smoothmap(U &x); private: uint32 m_uiSize; T m_Map[MAP_SIZE][uiSize]; };//template function for noise generation template<class T> void fillmap(T &x) { uint32 i; uint32 j; //loop through the rows for(i=0;i<T::MAP_SIZE;i++) { //loop through the colums for(j=0;j<T::MAP_SIZE;j++) { //set a new random seed everytime srand(static_cast<int>(time(NULL))); //retrieve a noise value with a new random pattern x.m_Map[j] = noise(i,j,rand()); } } };
Just found the problem it caused a stack overflow i moved the instance of map32 maps out of the main function and it worked fine
i didn t know that the stack is so tiny
the map32 class is only 1 mb large