Jump to content
  • Advertisement
Sign in to follow this  
Larsey

Why cant I make big maps?

This topic is 3749 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

Im working on Wendy Jones' book Beginning DX10, and now i want to make something of my own. Took her last project containing a small app to a "game". As I said i took her kode and made it so that I can read heightmap. It works, but the map size is really small. I use the following varbs: // Grid Information #define NUM_COLS 128 #define NUM_ROWS 128 #define NUM_VERTSX (NUM_COLS + 1) #define NUM_VERTSY (NUM_ROWS + 1) // The width and height of each cell in the grid #define CELL_WIDTH 32 #define CELL_HEIGHT 32 NUM_COLS / NUM_ROWS is (as I see it) the controller for the size. The problem is that im not allowed (getting stack owerflow) when im trying to make NUM_COLS / NUM_ROWS bigger then 128. How do you guys make big maps? How can i fix this? I really dont want to make the CELL_WIDTH / CELL_HEIGHT any bigger because I would then loose detail.

Share this post


Link to post
Share on other sites
Advertisement
There's probably an array being made on the stack with a size that depends on the value of NUM_COLS and NUM_ROWS. You'll need to find it and change it to allocate the array on the heap instead.

Share this post


Link to post
Share on other sites
Quote:
Original post by Evil Steve
There's probably an array being made on the stack with a size that depends on the value of NUM_COLS and NUM_ROWS. You'll need to find it and change it to allocate the array on the heap instead.


Yes,

// create the vertices array large enough to hold all those needed
VertexPosColorTexStruct vertices[NUM_VERTSX * NUM_VERTSY];

// Create the indices array
DWORD indices[NUM_VERTSX * NUM_VERTSY * 6];

but sry, how do i allicate the array on the heap instead.

- _newb_ :)

Share this post


Link to post
Share on other sites
Quote:
Original post by Larsey
Quote:
Original post by Evil Steve
There's probably an array being made on the stack with a size that depends on the value of NUM_COLS and NUM_ROWS. You'll need to find it and change it to allocate the array on the heap instead.


Yes,

// create the vertices array large enough to hold all those needed
VertexPosColorTexStruct vertices[NUM_VERTSX * NUM_VERTSY];

// Create the indices array
DWORD indices[NUM_VERTSX * NUM_VERTSY * 6];

but sry, how do i allicate the array on the heap instead.

- _newb_ :)

vertices = new VertexPosColorTexStruct[NUM_VERTSX * NUM_VERTSY];
and make sure you delete[] it when you're done with it.

I'd strongly recommend not jumping into DirectX development if you don't have a good understanding of C++ though, you're only going to keep running into problems like this. Most if not all DirectX books, the documentation, and pretty much every resource on the web will assume that you have a good grasp of C++, and trying to learn two things at once is only going to cause you grief.

Share this post


Link to post
Share on other sites
Quote:
Original post by Evil Steve
Quote:
Original post by Larsey
Quote:
Original post by Evil Steve
There's probably an array being made on the stack with a size that depends on the value of NUM_COLS and NUM_ROWS. You'll need to find it and change it to allocate the array on the heap instead.


Yes,

// create the vertices array large enough to hold all those needed
VertexPosColorTexStruct vertices[NUM_VERTSX * NUM_VERTSY];

// Create the indices array
DWORD indices[NUM_VERTSX * NUM_VERTSY * 6];

but sry, how do i allicate the array on the heap instead.

- _newb_ :)

vertices = new VertexPosColorTexStruct[NUM_VERTSX * NUM_VERTSY];
and make sure you delete[] it when you're done with it.

I'd strongly recommend not jumping into DirectX development if you don't have a good understanding of C++ though, you're only going to keep running into problems like this. Most if not all DirectX books, the documentation, and pretty much every resource on the web will assume that you have a good grasp of C++, and trying to learn two things at once is only going to cause you grief.


Thank you for ur response! Yes, ill need to read up on c++. i know some, but only basics really. We learn more about c++ in the next semester(taking a bachelor in computer science). Untill now we only touched java and c# :( :(. But im looking forward to the next semester!

Again thank you for your response, this forum is really nice and supporting!

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!