Original Post
The topic pretty much sums it up. In my exporter i have a line which *should* write all the vertices to a file but when i remove the ofstream::write call the output file gets even larger! the pointer i pass to the function is 0x27666470(looks ok to me), my vertexsize is 56 an the vertexcount is 2222. But the file is just 68 bytes big(which is little more than 1 vertex! How can this be possible? the file opened okay(it is created) but still he doesn't want to write the vertices. My code: vertex writing code all file writing code: the only reason for the file getting smaller i could think of is that the rest of the data which should be written to the file after the vertices isn't processed. So is there some way to "break" the file so that no more data can be written to it? Can somebody explain me how this is possible? regards, m4gnus [Edited by - m4gnus on June 9, 2006 6:47:19 AM]
std::cerr<<"Final Vertex Count:"<<vertCount<<std::endl; //returns 2222
std::cerr<<"Vertex Size:"<<sizeof(complVertex)<<std::endl; //returns 56
std::cerr<<"VertexPointer addresse:"<<pVerts<<std::endl; //returns 27666470
ofs.write(reinterpret_cast<char*>(pVerts),sizeof(complVertex)*vertCount); //when i make this line a comment the size of the file gets 20bytes bigger( 88bytes )
//vertices:
std::ofstream ofs(filepath.asChar(),std::ios::out | std::ios::binary);
VertexChunkHeader.dwNumVertices=DWORD(vertCount);
ofs.write(reinterpret_cast<char *>(&VertHeader),sizeof(VertHeader));
ofs.write(reinterpret_cast<char *>(&VertexChunkHeader),sizeof(VertexChunkHeader));
ofs.write(reinterpret_cast<char*>(&desc[0]),sizeof(ngVertexDesc)*numDesc);
std::cerr<<"Final Vertex Count:"<<vertCount<<std::endl;
std::cerr<<"Vertex Size:"<<sizeof(complVertex)<<std::endl;
std::cerr<<"VertexPointer addresse:"<<pVerts<<std::endl;
ofs.write(reinterpret_cast<char*>(pVerts),sizeof(complVertex)*vertCount); //<--the strange line
//indices:
IndexChunkHeader.dwNumIndices=indexCount;
std::cerr<<"Final Index Count:"<<indexCount<<std::endl;
IndHeader.dwDataSize=sizeof(IndexChunkHeader)+IndexChunkHeader.dwNumIndices*sizeof(int);
ofs.write(reinterpret_cast<char *>(&IndHeader),sizeof(IndHeader));
ofs.write(reinterpret_cast<char *>(&IndexChunkHeader),sizeof(IndexChunkHeader));
ofs.write(reinterpret_cast<char*>(pIndices),sizeof(int)*indexCount);
//for(int l=0;l<VertexIndices.size();l++) {
//std::vector<short>::pointer ptr = &VertexIndices[0];
//ofs.write(reinterpret_cast<char *>(ptr),sizeof(int)*VertexIndices.size());
//std::vector<short>::pointer ptr2 = &UVIndices[0];
//ofs.write(reinterpret_cast<char *>(ptr2),sizeof(int)*UVIndices.size());
ofs.close();