Can someone help a newbie?

Started by
4 comments, last by galop1n 6 years, 2 months ago

I include the source code from what I am playing with. It's an exercise from Frank Luna's DirectX 12 book about rendering a skull from a text file. I get a stack overflow error and the program quits. I don't know where I went wrong it's messy programming on the parts I added but maybe one of you masterminds can tell me where I went wrong.

Chapter_7_Drawing_in_Direct3D_Part_II.zip

Advertisement

I think I know what I did wrong but not sure how to fix it. In reading the vertex data from the text file I created an array larger than can be allowed. The sample code in the next chapter shows the skull I will just try to copy what he did and learn from that.

Your Vertex structure contains float3+float3+float4+float2, that's 44 bytes (if packed).

You declare this on stack: Vertex v[31076];

That's 1367344 bytes or 1.3 MB. That's too much for a typical stack, which is 1 MB IIRC.

Why don't you allocate a std::vector<Vector>, do a resize() on it, and load it into it? That'll solve it. You can access its data by ::data().

Thanks, that fixed the stack overflow error.

The best help i can give you is to stick with DX11, DX12 is not here to replace DX11, but to allow extremely rare application scenario that need it to be able to go beyond what is doable with DX11.

If your application is not at least a GTA V or similar, DX12 will only give you trouble for no benefits

This topic is closed to new replies.

Advertisement