Why cant I make big maps?
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.
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.
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_ :)
Quote:Original post by LarseyQuote: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.
Quote:Original post by Evil SteveQuote:Original post by LarseyQuote: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!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement