As my program is getting larger, my class is getting larger too, this is what i now have:
There is a pointer to that class GlobalDef* g;Code:class GlobalDef { public: //global variables: /////////////////// //General DirectX8 variables struct GeneralDX { IDirect3D8 *d3d8; IDirect3DDevice8 *device8; D3DDISPLAYMODE dmode; D3DPRESENT_PARAMETERS e_present; D3DCAPS8 Caps; //----------------------------- D3DDEVTYPE rastermode; DWORD vertexmode; D3DVIEWPORT8 viewport; float aspect; //tris/sec specific. }GeneralDX; //Time and FPS struct TimeAndFPS { INT64 nFreq; INT64 lTickCount; INT64 cTickCount; int mFrameRate; int mFrameCount; bool mInited; //timeelapsed related float timeStart; float lastTime; UINT64 tickspsec; }TimeAndFPS; //Matrices struct Matrices { D3DXMATRIX matWorld; D3DXMATRIX matView; D3DXMATRIX matProj; }Matrices; //Misc struct Misc { //application RenderTechApplication EnApp; //capabilities HWCaps dcaps; //zbuffer struct ZModes zd; DWORD ClearColor; RECT winRect; bool worldcull; bool ShowErrors; char* errstr; }Misc; struct Objects { //Text related goes here vector<FontMan> Fonts; UINT fontnum; RECT textRect; }Objects; //window structure struct WindowStruct { HWND hWnd; HINSTANCE hInst; int iWidth; int iHeight; char* clsName; }WindowStruct; struct Input { //keyboard LPDIRECTINPUT8 input8; LPDIRECTINPUTDEVICE8 inpdev8; char KeyBuf[256]; //mouse LPDIRECTINPUTDEVICE8 mousedev8; //mouse state DIMOUSESTATE2 MState; DIDEVICEOBJECTDATA data; //used to check if devices are acquired. bool kaq; bool maq; }Input; };
My question now is, how much overhead there is? Could it be better to use global variables instead of this huge class, which will grow twice as that in the future?



LinkBack URL
About LinkBacks


