Jump to content
  • Advertisement
Sign in to follow this  
Twitchy

Heightmaps problem

This topic is 4603 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 = in; return true; } m_heightmap is a std::vector<int>

Share this post


Link to post
Share on other sites
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!