Original Post
Hello GD! This is my first post here, nice to meet you all! Currently I'm taking baby steps into DirectX, and I have a question that I'm not sure if it fits into this forum...so admins please move it to the correct one if needed! Thanks!
I am making a game where a spaceship is flying through space avoiding asteroids. There are four kinds of asteroids, each differing in shape, and they are loaded in as meshes. I find that loading the mesh each time an asteroid is created is a waste of CPU, so I've decided to make a manager class for it. The manager class will be responsible for loading each mesh at runtime and passing out pointers to these meshes for each instance of the asteroid to be drawn. My first question is, is this approach appropriate?
And my second question, here's my code:
AsteroidManager.h:
AsteroidManager.cpp:
loadMeshes is called during initialization of my game. When I compile my program, it gives:
Am I declaring my variables correctly? Please guide me :(
Thanks alot for your time!
I am making a game where a spaceship is flying through space avoiding asteroids. There are four kinds of asteroids, each differing in shape, and they are loaded in as meshes. I find that loading the mesh each time an asteroid is created is a waste of CPU, so I've decided to make a manager class for it. The manager class will be responsible for loading each mesh at runtime and passing out pointers to these meshes for each instance of the asteroid to be drawn. My first question is, is this approach appropriate?
And my second question, here's my code:
AsteroidManager.h:
class AsteroidManager { const static int NUM_MESHES = 4; static LPD3DXMESH _mesh[NUM_MESHES]; static D3DMATERIAL9 **_materials; static LPDIRECT3DTEXTURE9 **_textures; static DWORD *_numMat; public: static bool loadMeshes();};AsteroidManager.cpp:
#inclulde "AsteroidManager.h"LPD3DXMESH AsteroidManager::_mesh[NUM_MESHES];D3DMATERIAL9 AsteroidManager::**_materials;LPDIRECT3DTEXTURE9 AsteroidManager::**_textures;DWORD AsteroidManager::*_numMat;bool AsteroidManager::loadMeshes() { _materials = new D3DMATERIAL9*[NUM_MESHES]; _textures = new LPDIRECT3DTEXTURE9*[NUM_MESHES]; _numMat = new DWORD[NUM_MESHES]; // The rest goes here // ... return true;}loadMeshes is called during initialization of my game. When I compile my program, it gives:
error LNK2001: unresolved external symbol "private: static unsigned long * AsteroidManager::_numMat" (?_numMat@AsteroidManager@@0PAKA)error LNK2001: unresolved external symbol "private: static struct IDirect3DTexture9 * * * AsteroidManager::_textures" (?_textures@AsteroidManager@@0PAPAPAUIDirect3DTexture9@@A)error LNK2001: unresolved external symbol "private: static struct _D3DMATERIAL9 * * AsteroidManager::_materials" (?_materials@MeteorManager@@0PAPAU_D3DMATERIAL9@@A)Am I declaring my variables correctly? Please guide me :(
Thanks alot for your time!