Sign in to follow this  

Heightmaps problem

This topic is 4298 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi I've got this problem with loading a heightmap as a RAW file using Visual studio .Net 2003 with DirectX 9, I've got a function for building a piece of terrain, using my customvertex structure. my problem is when I try to load in the heightmap file it doesn't seem to load in the values, and in turn crashes my application, can someone help me! This is what I've currently got to load my RAW file: bool GObject::ReadRAWfile(const char *RAWName) { std::vector<BYTE> in(NumVertices); std::ifstream inFile(RAWName, std::ios_base::binary); if( inFile == 0) return false; inFile.read((char*)&in[0], in.size()); inFile.close(); m_heightmap.resize(NumVertices); for(int i = 0; i < in.size(); i++) m_heightmap[i] = in[i]; return true; } m_heightmap is a std::vector<int>

Share this post


Link to post
Share on other sites
It's not reading in the values because you don't tell it to. As far as I can tell, you only read in 1 character and then close the file.
If you want to read in binary files, I'd recommend the C method. The fread function is much more intuitive then the C++ counterpart.

Share this post


Link to post
Share on other sites
sorry about this but I think I accidentally posted the same topic twice, I have solved it and actually I used the C method as it was alot simpler... thanks for your help anyways :D

Share this post


Link to post
Share on other sites

This topic is 4298 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this