Jump to content
  • Advertisement
Sign in to follow this  

C++ Stack Overflow Error?

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

So I am having this error with my code and keep getting the Stack Overflow Error and cannot fix it no matter what I try. I was hoping someone could point out what is wrong.


Here is my model loading and drawing code:



#include "model.h"



void Model::Load(LPCSTR Filename, LPDIRECT3DDEVICE9 GraphicsDevice)
    HR = D3DXLoadMeshFromX("Content/m.x", D3DXMESH_SYSTEMMEM,
        GraphicsDevice, NULL, &MaterialBuffer, NULL, &MaterialCount,
    if (FAILED(HR))
        MessageBox(NULL, "Can't load model!", "ERROR", MB_OK);
    Materials = (D3DXMATERIAL*)MaterialBuffer->GetBufferPointer();
    MeshMaterials = new D3DMATERIAL9[MaterialCount];
    MeshTextures = new LPDIRECT3DTEXTURE9[MaterialCount];
    for (DWORD i = 0; i < MaterialCount; i++)
        MeshMaterials = Materials.MatD3D;
        MeshMaterials.Ambient = MeshMaterials.Diffuse;
        MeshTextures = NULL;
        if (Materials.pTextureFilename)
            Materials.pTextureFilename, &MeshTextures);

void Model::Render(LPDIRECT3DDEVICE9 GraphicsDevice)
    D3DXMATRIX World;
    GraphicsDevice->SetTransform(D3DTS_WORLD, &World);
    for (DWORD i = 0; i < MaterialCount; i++)
        GraphicsDevice->SetTexture(0, MeshTextures);



#ifndef _MODEL_H_
#define _MODEL_H_
#include <d3d9.h>
#include <d3dx9.h>

class Model
        LPD3DXMESH Mesh;
        LPD3DXBUFFER MaterialBuffer;
        DWORD MaterialCount;
        D3DXMATERIAL* Materials;
        D3DMATERIAL9* MeshMaterials;
        LPDIRECT3DTEXTURE9* MeshTextures;
        void Load(LPCSTR, LPDIRECT3DDEVICE9);
        void Render(LPDIRECT3DDEVICE9);



Does anyone spot why this would be calling a stackoverflow error?

Share this post

Link to post
Share on other sites

Do we get to know where the stack overflow occurs?


Also, where is the code that calls the function that is throwing the stack overflow?

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!