   Need some direction
  I am building a "game Engine". Well, you could say that I am atempting to improve upon a game Engine. I use Jim Adams Game Core Engine to find some direction as how to build my own engine, but I have come up against a wall: That engine Sucks (well, in my opinion it does). I need some direction as to what a graphics Engine needs. I can build the other steps by myself later, or ask for help, but right now, I just want to focus on the graphics. Could someone tell me some classes that I would need for one... For example, a Camera class what does X and has Y. Right now I have a vertex buffer class, a texture class, a camera class, and a controller class. Here is the Graphics engine source:(Please be aware that this is COMPLETELY full of Errors, and much (probably about 80% of this is going to be deleted... this is why I need help...)#include "stdafx.h"#include <windows.h>#include <d3d9.h>#include <d3dx9.h>#include "Errors.h"#include <stdio.h>#include <string.h>#include <vector>#ifndef _GRAPHICS_ENGINE_H_#define _GRAPHICS_ENGINE_H_class eGraphics{protected:ID3DXSprite *Sprite;IDirect3D9 *iD3D; // Main interface to 3dIDirect3DDevice9 *iD3DDev; // Interface to 3d deviceHWND hwnd;public:eGraphics();~eGraphics();int height;int width;char BPP;D3DPRESENT_PARAMETERS Present;D3DDISPLAYMODE Display;D3DFORMAT PFormat;D3DFORMAT SFormat;bool zbuf;bool Start();bool Stop();IDirect3D9 *GetiD3D();IDirect3DDevice9 *GetDev();ID3DXSprite *GetSpri();bool Clear();bool ScreenClear();bool CheckDisplayMode();void Init(HWND hWnd);void Shutdown();bool TestFormat(D3DFORMAT Format, bool HAL);bool Frame();};class Texture{protected:eGraphics *GEngine;IDirect3DTexture9 tex;unsigned long width, height;public:Texture();~Texture();IDirect3DTexture9 *Get();bool Load(eGraphics *pGEngine, char *Filename, DWORD trans=0, D3DFORMAT Format = D3DFMT_UNKNOWN);bool Create(eGraphics *pGEngine, DWORD width, DWORD height, D3DFORMAT Format);bool Create(eGraphics *pGEngine, IDirect3DTexture9 source);bool Free();bool IsLoaded();bool GetDimentions(long *h, long *w);bool Blit(long DX, long DY, long SX = 0, long SY = 0, long Width = 0, long Height = 0, float XScale = 1.0f, float YScale = 1.0f, D3DCOLOR Color = 0xFFFFFFFF);bool GetFMT(D3DFORMAT *Fmt);};class VertexBuffer{protected:eGraphics *pGEngine;IDirect3DVertexBuffer9 *VertBuf;DWORD VertNum;DWORD VertSize;DWORD FVF;bool Locked;char *ptr;public:VertexBuffer();~VertexBuffer();bool Create(eGraphics *GEngine, unsigned long NumVerts, DWORD fvf, unsigned long SizeVerts);bool SetCamera(Camera sCamera);bool Close();bool IsReady();// Copy a serices of vertices into bufferbool Set(unsigned long firstvert, unsigned long Numvert, void *Vertlist);// Render vertex bufferbool Render(unsigned long firstvert, unsigned long Numprim, DWORD type);//lock or unlockbool Lock(unsigned long firstvert = 0, unsigned long NumVerts = 0);bool Unlock();void *GetPtr();IDirect3DVertexBuffer9 *GetBuffer();unsigned long GetVertNum();unsigned long GetVertSize();unsigned long GetFVF();};class World{protected:bool Billboard;float Xpos, Ypos, Zpos;float Xrot, Yrot, Zrot;float Xsca, Ysca, Zsca;D3DXMATRIX worldmatrix;D3DXMATRIX scalematrix;D3DXMATRIX rotatematrix;D3DXMATRIX transmatrix;D3DXMATRIX *Comb1;D3DXMATRIX *Comb2;public:World();D3DXMATRIX *GetMatrix(eGraphics *GEngine = NULL);bool SetComb1(D3DXMATRIX *Matrix = NULL);bool SetComb2(D3DXMATRIX *Matrix = NULL);bool Copy(World *Target);bool Shift(float x, float y, float z);bool SetPos(float xpos, float ypos, float zpos);bool Rotate(float xdist, float ydist, float zdist);bool SetRot(float x, float y, float z);bool Scale(float xadd, float yadd, float zadd);bool SetScale(float x, float y, float z);bool Update(eGraphics *GEngine = NULL);bool GetRot(float *x, float *y, float *z);bool GetPos(float *x, float *y, float *z);bool GetScale(float *x, float *y, float *z);bool BillboardOn(bool Yes = true);};class Camera{private:D3DXMATRIX Cam;D3DXMATRIX World;D3DXMATRIX Trans;D3DXMATRIX Rot;float Xpos, Ypos, Zpos;float Xrot, Yrot, Zrot;float startXpos, startYpos, startZpos;float startXrot, startYrot, startZrot;float endX, endY, endZ;float endXrot, endYrot, endZrot;public:Camera();D3DXMATRIX *GetCam();bool Update();bool Shift( float xdist, float ydist, float zdist);bool SetPos( float xpos, float ypos, float zpos);bool Rotate( float xdist, float ydist, float zdist);bool SetRot(float x, float y, float z);bool Point(float Xeye, float Yeye, float Zeye, float Xat, float Yat, float Zat);bool SetTrackStart();bool SetTrackEnd();bool Track(float time, float length);bool GetPos(float *x, float *y, float *z);bool GetRotation(float *x, float *y, float *z);};class Material{protected:D3DMATERIAL9 mater;public:Material();D3DMATERIAL9 *Get();bool SetDiffuse(char red, char green, char blue);bool GetDiffuse(char *red, char *green, char *blue);bool SetAmbient(char red, char green, char blue);bool GetAmbient(char *red, char *green, char *blue);bool SetSpecular(char red, char green, char blue);bool GetSpecular(char *red, char *green, char *blue);bool SetEmissive(char red, char green, char blue);bool GetEmissive(char *red, char *green, char *blue);bool SetPower(float power)lfloat GetPower();};class Light{protected:D3DLIGHT9 Lit;public:Light();bool SetType(D3DLIGHTTYPE type);bool SetPos(float x, float y, float z);bool Move(float x, float y, float z);bool GetPos(float *x, float *y, float *z);bool Point(float xfrom, float yfrom, float zfrom, float xat, float yat, float zat);bool GetDirection(float *xdir, float *ydir, float *zdir);bool SetDif(char red, char green, char blue);bool GetDir(char *red, char *green, char *blue);bool SetAmb(char red, char green, char blue);bool GetAmb(char *red, char *green, char *blue);bool SetSpec(char red, char green, char blue);bool GetSpec(char *red, char *green, char blue);bool SetRange(float range);float GetRange();bool SetFalloff(float falloff);float GetFalloff();bool SetAttenuation0(float atten);bool SetAttenuation1(float atten);bool SetAttenuation2(float atten);float GetAttenuation0();float GetAttenuation1();float GetAttenuation2();bool SetTheta(float theta);float GetTheta();bool SetPhi(float Phi);float GetPhi();};#endifand the .cpp#include "stdafx.h"#include <windows.h>#include <d3d9.h>#include <d3dx9.h>#include "Errors.h"#include <stdio.h>#include "Graphics Engine.h"eGraphics::eGraphics(){iD3D=NULL;iD3DDev=NULL;}eGraphics::~eGraphics(){iD3D=NULL;iD3DDev=NULL;}void eGraphics::Init(HWND hWnd){eGraphics::hwnd = hWnd;//Initilize DirectX formats and suchPFormat = D3DFMT_A8R8G8B8;SFormat = D3DFMT_X8R8G8B8;if((iD3D = Direct3DCreate9(D3D_SDK_VERSION))==NULL){Error(2);}Display.Width = width;Display.Height = height;Display.RefreshRate =0;if(TestFormat(PFormat, true)==true){Display.Format = PFormat;}else{if(TestFormat(SFormat, true) == true){Display.Format = SFormat;}else{if(TestFormat(PFormat, false) == true){Display.Format = PFormat;}else{if(TestFormat(SFormat, false) == true){Display.Format = SFormat;}else{Error(3);}}}}ZeroMemory(&Present, sizeof(D3DPRESENT_PARAMETERS));Present.Windowed = false;Present.SwapEffect = D3DSWAPEFFECT_FLIP;Present.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;Present.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT;Present.BackBufferFormat = Display.Format;Present.BackBufferWidth = Display.Width;Present.BackBufferHeight = Display.Height;Present.EnableAutoDepthStencil = TRUE;Present.AutoDepthStencilFormat = D3DFMT_D16;if(FAILED(iD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hwnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &Present, &iD3DDev))){Present.EnableAutoDepthStencil = false;zbuf = false;if(FAILED(iD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hwnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &Present, &iD3DDev)))Error(4);}else{zbuf = true;}bool eGraphics::TestFormat(D3DFORMAT Format, bool HAL){if(FAILED(iD3D->CheckDeviceType(D3DADAPTER_DEFAULT, (HAL == TRUE) ? D3DDEVTYPE_HAL : D3DDEVTYPE_REF,    Format, Format, true)))  return false;return true;}void eGraphics::Shutdown(){iD3D->Release();iD3DDev->Release();//Iterate through children and close them}bool eGraphics::Start(){iD3DDev->BeginScene();}bool eGraphics::Stop(){iD3DDev->EndScene();}bool eGraphics::Frame(){Clear();iD3DDev->Present(NULL, NULL, hwnd, NULL);}bool eGraphics::SetCamera(Camera sCamera){iD3DDev->SetTransform( D3DTS_VIEW, sCamera->GetCam() );}Texture::Texture(){GEngine = NULL;tex = NULL;width = height = 0;}Texture::~Texture(){Free();}bool Texture::Load(eGraphics *pGEngine, char *Filename, DWORD trans, D3DFORMAT Format){Free();if((GEngine = pGEngine) == NULL)return false;if(GEngine->GetDev() == NULL)return false;if(Filename = NULL)return false;if(FAILED(D3DXCreateTextureFromFileEx(GEngine->GetDev(),    Filename, D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT,    0, Format, D3DPOOL_MANAGED,D3DX_FILTER_TRIANGLE, D3DX_FILTER_TRIANGLE,    trans, NULL, NULL, &tex))) return false;GetDimentions(&height, &width);return true;}bool Texture::Create(eGraphics *pGEngine, DWORD width, DWORD height, D3DFORMAT Format){Free();if((GEngine = pGEngine) == NULL)return false;if(FAILED(GEngine->GetDev()->CreateTexture(width, height, 0, 0, Format, D3DPOOL_MANAGED, &tex, NULL)))return false;return true;}bool Texture::Create(eGraphics *pGEngine, IDirect3DTexture9 source){D3DLOCKED_RECT SrcRect, DestRect;  D3DSURFACE_DESC Desc;  Free();  if((GEngine = pGEngine) == NULL)    return FALSE;  if(source == NULL)    return TRUE; // Copy texture over  source->GetLevelDesc(0, &Desc);  width  = Desc.Width;  height = Desc.Height;  GEngine->GetDev()->CreateTexture(width, height, 0, 0, Desc.Format, D3DPOOL_MANAGED, &tex, NULL);  source->LockRect(0, &SrcRect, NULL, D3DLOCK_READONLY);  tex->LockRect(0, &DestRect, NULL, 0);  memcpy(DestRect.pBits, SrcRect.pBits, SrcRect.Pitch * height);  tex->UnlockRect(0);  source->UnlockRect(0);  return true;}bool Texture::Free(){tex->Release();GEngine = NULL;width = height = 0;}bool Texture::IsLoaded(){if(tex = NULL)return false;return true;}IDirect3DTexture9 *Texture::Get(){return tex;}bool Texture::GetDimentions(long *h, long *w){D3DSURFACE_DESC d3dsd;  if(tex == NULL)    return false;  if(FAILED(tex->GetLevelDesc(0, &d3dsd)))    return false;  *h = d3dsd.Height;  *w = d3dsd.Width;  return true;}bool Texture::GetFMT(D3DFORMAT *Fmt){D3DSURFACE_DESC d3dsd;  if(tex == NULL)    return false;  if(FAILED(tex->GetLevelDesc(0, &d3dsd)))    return false;  *Fmt = d3dsd.Format;  return true;}bool Texture::Blit(long DX, long DY, long SX, long SY, long Width, long Height, float XScale, float YScale, D3DCOLOR Color){RECT rec;ID3DXSprite *pSprite;if(tex == NULL)return false;if(GEngine == NULL)return false;if((pSprite = GEngine->GetSpri())== NULL)return false;if(!Width)Width = width;if(!Height)Height = height;rec.left = SX;  rec.top  = SY;  rec.right = rec.left + Width;  rec.bottom = rec.top + Height;   if(FAILED(pSprite->Draw(tex, &rec, &D3DXVECTOR2(XScale, YScale), NULL, 0.0f, &D3DXVECTOR2((float)DX, (float)DY), Color)))    return FALSE;  return TRUE;}VertexBuffer::VertexBuffer(){VertBuf=NULL;VertNum=0;VertSize=0;FVF=NULL;Locked=false;Pointer=NULL;}VertexBuffer::~VertexBuffer(){Close();}bool VertexBuffer::Create(eGraphics *GEngine, unsigned long NumVerts, DWORD fvf, unsigned long SizeVerts){Close();if(!(pGEngine = GEngine)return false;if(!(VertNum = NumVerts) || !(FVF = fvf) || !(VertSize = SizeVerts))return false;if(pGEngine->GetDev() == NULL)return false;if(FAILED(GEngine->GetDev()->CreateVertexBuffer(NumVerts * SizeVerts, 0, fvf, D3DPOOL_DEFAULT, &VertBuf)))return false;return true;}bool VertexBuffer::Close(){Unlock();VertBuf->Release();VertNum=0;VertSize=0;FVF=NULL;Locked = false;ptr = NULL;}bool VertexBuffer::IsReady(){return(VertBuf == NULL) ? false : true;}bool VertexBuffer::Set(unsigned long firstvert, unsigned long Numvert, void *Vertlist){//Test for other errorsif(Lock(firstvert, Numvert) == false)return false;memcpy(ptr, Vertlist, Numvert * VertSize);if(Unlock() == false)return false;return true;}bool VertexBuffer::Render(unsigned long firstvert, unsigned long Numprim, DWORD type){pGEngine->GetDev()->SetStreamSource(0, VertBuf, 0, VertSize);pGEngine->GetDev()->SetFVF(FVF);pGEngine->GetDev()->DrawPrimitive((D3DPRIMITIVETYPE)Type, firstvert, Numprim);return true;}bool VertexBuffer::Lock(unsigned long firstvert = 0, unsigned long NumVerts = 0){//check for errors hereif(FAILED(VertBuf->Lock(firstvert * VertSize, NumVerts * VertSize, (void**)&ptr,0)))return false;Locked = true;return true;}bool VertexBuffer::Unlock(){//check errorsif(FAILED(VertBuf->Unlock()))return false;Locked = false;return true;}void *VertexBuffer::GetPtr(){return (void*) ptr;}IDirect3DVertexBuffer9 *VertexBuffer::GetBuffer(){return VertBuf;}unsigned long VertexBuffer::GetVertNum();{return VertNum;}unsigned long VertexBuffer::GetVertSize();{return D3DXGetFVFVertexSize(FVF);}unsigned long VertexBuffer::GetFVF();{return FVF;}World::World(){Billboard = false;Comb1 = Comb2 = NULL;SetPos(0.0f, 0.0f, 0.0f);SetRot(0.0f, 0.0f, 0.0f);SetScale(1.0f, 1.0f, 1.0f);Update();}bool World::Copy(World *Target){Target->BillboardOn(Billboard);Target->SetRot(Xrot, Yrot, Zrot);Target->SetPos(Xpos, Ypos, Zpos);Target->SetScale(Xsca, Ysca, Zsca);return true;}bool World::SetPos(float xpos, float ypos, float zpos){Xpos = xpos;Ypos = ypos;Zpos = zpos;D3DXMatrixTranslation( &transmatrix, Xpos, Ypos, Zpos);return true;}bool World::Shift(float x, float y, float z){return SetPos(float Xpos + x, Ypos + y, Zpos + z);}bool World::SetRot(float x, float y, float z){Xrot = x;Yrot = y;Zrot = z;D3DXMatrixRotationYawPitchRoll(&rotatematrix, Yrot, Xrot, Zrot);return true;}bool World::Rotate(float xdist, float ydist, float zdist){return SetRot(Xrot + xdist, Yrot + ydist, Zrot + zdist);}bool World::SetScale(float x, float y, float z){Xsca = x;Ysca = y;Zsca = z;D3DXMatrixScaling(&scalematrix, Xsca, Ysca, Zsca);return true;}bool World::Scale(float xadd, float yadd, float zadd){return SetScale(Xsca + xadd, Ysca + yadd, Zsca + zadd);}bool World::Update(eGraphics *GEngine){D3DXMATRIX ViewMat, TransposeMat;//Setup billboarding....if(Billboard == true) {if(GEngine != NULL && GEngine->GetDev() != NULL) {GEngine->GetDev()->GetTransform(D3DTS_VIEW, &ViewMat);D3DXMatrixTranspose(&TransposeMat, &ViewMat);TransposeMat._41 = TransposeMat._42 = TransposeMat._43 = TransposeMat._14 = TransposeMat._24 = TransposeMat._34 = 0.0f;} else {D3DXMatrixIdentity(&TransposeMat);}}//Combine MatricesD3DXMatrixMultiply(&worldmatrix, &scalematrix, &rotatematrix);// Apply billboard matrix  if(Billboard == TRUE)    D3DXMatrixMultiply(&worldmatrix, &worldmatrix, &TransposeMat);  // Combine with translation matrix  D3DXMatrixMultiply(&worldmatrix, &worldmatrix, &transmatrix);  // Combine with combined matrices (if any)  if(Comb1 != NULL)D3DXMatrixMultiply(&worldmatrix, &worldmatrix, Comb1);  if(Comb2 != NULL)D3DXMatrixMultiply(&worldmatrix, &worldmatrix, Comb2);  return true;}bool World::BillboardOn(bool Yes){Billboard = Yes;return true;}D3DXMATRIX *World::GetMatrix(eGraphics GEngine){Update(GEngine);return &worldmatrix;}bool World::SetComb1(D3DXMATRIX *Matrix){Comb1 = Matrix;return true;}bool World::SetComb2(D3DXMATRIX *Matrix ){Comb2 = Matrix;return true;}bool World::GetPos(float *x, float *y, float *z){*x = Xpos;*y = Ypos;*z = Zpos;return true;}bool World::GetRot(float *x, float *y, float *z){*x = Xrot;*y = Yrot;*z = Zrot;return true;}bool World::GetScale(float *x, float *y, float *z){*x = Xsca;*y = Ysca;*z = Zsca;return true;}Camera::Camera(){SetPos(0.0f, 0.0f, 0.0f);Rotate(0.0f, 0.0f, 0.0f);Update();}bool Camera::SetPos(float xpos, float ypos, float zpos){Xpos = xpos;Ypos = ypos;Zpos = zpos;D3DXMatrixTranslation(&Trans, -XPos, -YPos, -ZPos);return true;}bool Camera::Shift(float xdist, float ydist, float zdist){SetPos(Xpos + xdist, Ypos + ydist, Zpos + zdist);}bool Camera::SetRot(float x, float y, float z){D3DXMatrix Xrotate, Yrotate, Zrotate;Xrot = x;Yrot = y;Zrot = z;  D3DXMatrixRotationX(&XRotate, -XRot);  D3DXMatrixRotationY(&YRotate, -YRot);  D3DXMatrixRotationZ(&ZRotate, -ZRot);  Rot = ZRotate;  D3DXMatrixMultiply(&Rot, &Rot, &YRotate);  D3DXMatrixMultiply(&Rot, &Rot, &XRotate);  return true;}bool Camera::Rotate(float xdist, float ydist, float zdist){return SetRot(Xrot + xdist, Yrot + ydist, Zrot + zdist);}bool Camera::Point(float Xeye, float Yeye, float Zeye, float Xat, float Yat, float Zat){float XRotate, YRotate, Xdif, Ydif, Zdif;//Diference angles detween pointsXdif = Xat - Xeye;Ydif = Yat - Yeye;Zdif = Zat - Zeye;XRotate = (float)atan2(-Ydif, sqrt(Xdif*Xdif+Zdif*Zdif));YRotate = (float)atan2(Xdif, Zdif);SetPos(Xeye, Yeye, Zeye);SetRot(XRotate, YRotate, 0.0f);return true;}bool Camera::SetTrackStart(){startXpos=Xpos;startYpos=Ypos;startZpos=Zpos;startXrot=Xrot;startYrot=Yrot;startZrot=Zrot;return true;}bool Camera::SetTrackEnd(){endX = Xpos;endY = Ypos;endZ = Zpos;endXrot = Xrot;endYrot = Yrot;endZrot = Zrot;return true;}bool Camera::Track(float time, float length){float cx, cy, cz;float offset;offset = length * time;cx = (endX - startXpos) / length * offset;cy = (endY - startYpos) / length * offset;cz = (endZ - startZpos) / length * offset;SetPos( cx, cy, cz);cx = (endXrot - startXrot) / length * offset;cy = (endYrot - startYrot) / length * offset;cz = (endZrot - startZrot) / length * offset;SetRot(cx, cy, cz);return true;}bool Camera::Update(){D3DMatrixMultiply(&World, &Trans, &Rot);return true;}D3DMATRIX *Camera::GetCam(){Update();return &World;}bool Camera::GetPos(float *x, float *y, float *z){*x = Xpos;*y = Ypos;*z = Zpos;return true;}bool Camera::GetRotation(float *x, float *y, float *z){*x = Xrot;*y = Yrot;*z = Zrot;return true;}Alright, so, what does a good graphics engine have? I am looking for a list of classes, and things that those classes to, in relation to directX functions/objects...   