//==================Includes======================//#include "main.h"//================================================//LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM); //Wnd Proc declaratiovoid InitScene();void Render();CGOApp cApp; //The application instancetypedef struct myvert //A temporary structure for the vertices{ float x,y,z; float nx,ny,nz; D3DCOLOR color; float tu,tv;};#define D3DFVF_CUSTOM D3DFVF_XYZ|D3DFVF_TEX1|D3DFVF_NORMAL|D3DFVF_DIFFUSE //The custom FVFmyvert gverts[]={ {-1.0f,-1.0f,-1.0f, 0.0f, 0.0f,-1.0f, 0xFFFFFFFF, 0.0f, 1.0f }, //Front face {-1.0f, 1.0f,-1.0f, 0.0f, 0.0f,-1.0f, 0xFFFFFFFF, 0.0f, 0.0f }, { 1.0f, 1.0f,-1.0f, 0.0f, 0.0f,-1.0f, 0xFFFFFFFF, 1.0f, 0.0f }, { 1.0f, 1.0f,-1.0f, 0.0f, 0.0f,-1.0f, 0xFFFFFFFF, 1.0f, 0.0f }, { 1.0f,-1.0f,-1.0f, 0.0f, 0.0f,-1.0f, 0xFFFFFFFF, 1.0f, 1.0f }, {-1.0f,-1.0f,-1.0f, 0.0f, 0.0f,-1.0f, 0xFFFFFFFF, 0.0f, 1.0f }, { 1.0f,-1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0xFFFFFFFF, 0.0f, 1.0f }, //Back face { 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0xFFFFFFFF, 0.0f, 0.0f }, {-1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0xFFFFFFFF, 1.0f, 0.0f }, {-1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0xFFFFFFFF, 1.0f, 0.0f }, {-1.0f,-1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0xFFFFFFFF, 1.0f, 1.0f }, { 1.0f,-1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0xFFFFFFFF, 0.0f, 1.0f }, {-1.0f, 1.0f,-1.0f, 0.0f, 1.0f, 0.0f, 0xFFFFFFFF, 0.0f, 1.0f }, //Top face {-1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0xFFFFFFFF, 0.0f, 0.0f }, { 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0xFFFFFFFF, 1.0f, 0.0f }, { 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0xFFFFFFFF, 1.0f, 0.0f }, { 1.0f, 1.0f,-1.0f, 0.0f, 1.0f, 0.0f, 0xFFFFFFFF, 1.0f, 1.0f }, {-1.0f, 1.0f,-1.0f, 0.0f, 1.0f, 0.0f, 0xFFFFFFFF, 0.0f, 1.0f }, { 1.0f,-1.0f,-1.0f, 0.0f,-1.0f, 0.0f, 0xFFFFFFFF, 0.0f, 1.0f }, //Bottom face { 1.0f,-1.0f, 1.0f, 0.0f,-1.0f, 0.0f, 0xFFFFFFFF, 0.0f, 0.0f }, {-1.0f,-1.0f, 1.0f, 0.0f,-1.0f, 0.0f, 0xFFFFFFFF, 1.0f, 0.0f }, {-1.0f,-1.0f, 1.0f, 0.0f,-1.0f, 0.0f, 0xFFFFFFFF, 1.0f, 0.0f }, {-1.0f,-1.0f,-1.0f, 0.0f,-1.0f, 0.0f, 0xFFFFFFFF, 1.0f, 1.0f }, { 1.0f,-1.0f,-1.0f, 0.0f,-1.0f, 0.0f, 0xFFFFFFFF, 0.0f, 1.0f }, {-1.0f,-1.0f, 1.0f, -1.0f, 0.0f, 0.0f, 0xFFFFFFFF, 0.0f, 1.0f }, //Left face {-1.0f, 1.0f, 1.0f, -1.0f, 0.0f, 0.0f, 0xFFFFFFFF, 0.0f, 0.0f }, {-1.0f, 1.0f,-1.0f, -1.0f, 0.0f, 0.0f, 0xFFFFFFFF, 1.0f, 0.0f }, {-1.0f, 1.0f,-1.0f, -1.0f, 0.0f, 0.0f, 0xFFFFFFFF, 1.0f, 0.0f }, {-1.0f,-1.0f,-1.0f, -1.0f, 0.0f, 0.0f, 0xFFFFFFFF, 1.0f, 1.0f }, {-1.0f,-1.0f, 1.0f, -1.0f, 0.0f, 0.0f, 0xFFFFFFFF, 0.0f, 1.0f }, { 1.0f,-1.0f,-1.0f, 1.0f, 0.0f, 0.0f, 0xFFFFFFFF, 0.0f, 1.0f }, //Right face { 1.0f, 1.0f,-1.0f, 1.0f, 0.0f, 0.0f, 0xFFFFFFFF, 0.0f, 0.0f }, { 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0xFFFFFFFF, 1.0f, 0.0f }, { 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0xFFFFFFFF, 1.0f, 0.0f }, { 1.0f,-1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0xFFFFFFFF, 1.0f, 1.0f }, { 1.0f,-1.0f,-1.0f, 1.0f, 0.0f, 0.0f, 0xFFFFFFFF, 0.0f, 1.0f },};IDirect3DDevice8 *mydev = cApp.goGetDevice();CGOPRIMITIVE mymesh(36,D3DFVF_CUSTOM,D3DPT_TRIANGLELIST,12);int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmd, int nShow) //The WinMain function{cApp.goInitWindow("BlueFireStudios Windows Wrapper",800,600,hInstance,CGO_FULLSCREEN); //Initiate the windowInitScene();while (!cApp.KeyDown(DIK_ESCAPE)) //While the window is alive{cApp.goMessageLoop(); //Deal with messagesRender();}}LRESULT CALLBACK WndProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam) //The Window procedure{ switch (message) //Look at the messsages { case WM_CLOSE: //If the window is closed case WM_QUIT: //If someone quit the window case WM_DESTROY: //If someone destroys the window (Alt+F4) PostQuitMessage(0); //Post a message saying we're quitting cApp.goWindowKill(); //Kill the window break; default: return DefWindowProc(hWnd,message,wParam,lParam); //Return default actions to messages } return 0;}void InitScene(){mymesh.CreateVertexBuffer(mydev);mymesh.Fill(gverts);mymesh.TextureMesh("tex.bmp");mymesh.MoveMesh(0,0,1);cApp.PointCamera(&D3DXVECTOR3(0,0,-8),&D3DXVECTOR3(0,0,0),&D3DXVECTOR3(0,1,0));cApp.CameraRange(1.0f,100.0f);}void Render() //Render D3D{ cApp.Cls(50,50,140); mymesh.Draw(); cApp.Text(0,0,0xFFFFFFFF,"Matthew Whitworth"); cApp.Text(0,32,"Bluefirestudios.com"); cApp.Flip();} Main.h #ifndef INC_FILES#define INC_FILES#define WIN32_LEAN_AND_MEAN#include <windows.h> //The windows header file#define INITGUID#include <d3dx8.h> //The DirectX 8 header file#include <string.h> //String header file#include <stdio.h> //Header for dealing with files#include <stdarg.h> //Variable arguments header file#include <dinput.h> //The DirectInput header file#include "CApplication.h" //Include our CDirectApplication class#include "System.h" //Include the System functions#include "CPrimitives.h" //Include the Primitives class#endif CApplication.h // --------- CApplication.h ----------------//#ifndef CAPPLICATION_H#define CAPPLICATION_H//Fullscreen / Windowed definesenum WINDOWTYPE{ CGO_WINDOWED; CGO_FULLSCREEN;}; //Typedefstypedef unsigned char GOBYTE;//----- CGFont class ------//class CGOFont{ public: CGOFont(); void KillFont(); void CreateFont(IDirect3DDevice8*); void Text(int,int,char*); void Text(int,int,DWORD,char*); private: ID3DXFont *font; HRESULT hR; IDirect3DDevice8 *fdev;};//------ CGOApp class -----//class CGOApp{public: //Public function members //Win32 / DirectX CGOApp(); //Default constructor ~CGOApp(); //Default destructor //Win32 only HWND goGetWindowHandle() { return hWnd; } //Returns the window handle, since hWnd is private HINSTANCE goGetInstance() { return hInstance;} //Returns the window instance bool goWindowAlive() {return windowalive; } //Returns whether the window is alive or not void goWindowKill(); //Kill the window bool goInitWindow(char[32],int,int,HINSTANCE,bool); //Initiate the window void goMessageLoop(); //DirectX only D3DFORMAT FindBitMode(); void Cls(); void Cls(GOBYTE,GOBYTE,GOBYTE); void Flip(); IDirect3DDevice8 *goGetDevice() {return gD3Ddevice;} void SetDevice(IDirect3DDevice8 *pdev) {gD3Ddevice=pdev;} void PointCamera(D3DXVECTOR3*,D3DXVECTOR3*,D3DXVECTOR3*); void CameraRange(float,float); void RenderState(D3DRENDERSTATETYPE,DWORD); void DebugLog(char*,...); bool KeyDown(GOBYTE); bool MouseDown(GOBYTE); void Text(int x,int y,char *text) {myfont.Text(x,y,text);} void Text(int x,int y,DWORD color,char *text) {myfont.Text(x,y,color,text);} CGOFont myfont;private: //Win32 private class members HWND hWnd; //Handle to the window HINSTANCE hInstance; //Handle to the window instance WNDCLASSEX wc; //The window class MSG messages; bool windowalive; //The status of the window char title[32]; //The title of the window int width,height; //The width and height of the window //DirectX private class members LPDIRECT3D8 gD3D; //Main Direct3D interface IDirect3DDevice8 *gD3Ddevice; //Direct3D Device HRESULT hR; //Handle to a result D3DPRESENT_PARAMETERS d3dpp; //Parameters for creating the display mode D3DDISPLAYMODE displaymode; //Display mode bool fullscreen; //Fullscreen/windowed boolean value D3DXMATRIX viewmatrix; //The view matrix D3DXMATRIX matProj; //The projection matrix LPDIRECTINPUT8 directi; LPDIRECTINPUTDEVICE8 devkeyboard; GOBYTE keystate[256]; LPDIRECTINPUTDEVICE8 devmouse; DIMOUSESTATE statemouse; bool goInitD3D(); //Initiate D3D void goKillD3D(); //Kill D3D bool InitDirectInput(); void KillDirectInput(); //File FILE *log; bool Open(); bool Close();};#endif CApplication.cpp //=======================================================================////======================== CApplication.cpp =============================////== Version number: V0.05//== Main coder - CloudNine#include "CApplication.h"//=======================================================================////======================== CGOFont Class ================================////=======================================================================//CGOFont::CGOFont(){font=NULL;}void CGOFont::KillFont(){ if (font) { font->Release(); font=NULL; }}void CGOFont::CreateFont(IDirect3DDevice8 *gD3Ddevice){ fdev=gD3Ddevice; LOGFONT logfont={ 32, //height 0, //width (use default) 0,0, //Escapement and orentation FW_BOLD, //The weight of the font FALSE, //Italic FALSE, //Underline FALSE, //Strikeout DEFAULT_CHARSET, //The character set OUT_DEFAULT_PRECIS, //Out precision CLIP_DEFAULT_PRECIS, //Clipping precision ANTIALIASED_QUALITY, //The quality of the font DEFAULT_PITCH, //The pitch "Comic Sans MS" //The name of the font }; hR=D3DXCreateFontIndirect(fdev,&logfont,&font); if (FAILED(hR)) { goRunTimeError("Font could not be created"); }}void CGOFont::Text(int x,int y,char *text){RECT fontrect={x,y,800,600};font->Begin();font->DrawText(text,-1,&fontrect,DT_LEFT,0xFFFFFFFF);font->End();}void CGOFont::Text(int x,int y,DWORD color,char *text){RECT fontrect={x,y,800,600};font->Begin();font->DrawText(text,-1,&fontrect,DT_LEFT,color);font->End();}//=======================================================================////====================== CGOApplication Class ===========================////=======================================================================//CGOApp::CGOApp(){ windowalive=true; //Make the window alive //Make sure we don't have pointer trouble gD3D=NULL; gD3Ddevice=NULL; log=NULL; directi=NULL; devkeyboard=NULL; //Creates the log file, and closes it, just to be safe log=fopen("debuglog.txt","w"); Close();}CGOApp::~CGOApp() //The destructor{Close(); //Close the file, just in case it was left open//Kill the interfaces in reverse ordermyfont.KillFont();KillDirectInput();goKillD3D();}bool CGOApp::goInitWindow(char wtitle[32],int wwidth,int wheight,HINSTANCE winstance,bool wfullscreen) //Initiates the window{//Copy the parameters to class member variablesstrcpy(title,wtitle);width=wwidth;height=wheight;fullscreen=wfullscreen;hInstance=winstance;DWORD dwStyle; //Style for the window, depending on fullscreen/windowedif (fullscreen) //If it's fullscreen{ dwStyle=WS_POPUP; //Make it a popup style (no borders) }else{ dwStyle=WS_OVERLAPPEDWINDOW; //Make it a normal window}//Set up the window classwc.cbSize=sizeof(WNDCLASSEX);wc.style=CS_OWNDC;wc.lpfnWndProc=WndProc;wc.cbClsExtra=0;wc.cbWndExtra=0;wc.hInstance=hInstance;wc.hIcon=LoadIcon(NULL,IDI_APPLICATION);wc.hCursor=LoadCursor(NULL,IDC_ARROW);wc.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);wc.lpszMenuName=NULL;wc.lpszClassName=title;wc.hIconSm=LoadIcon(NULL,IDI_APPLICATION);//Register the classif (!RegisterClassEx(&wc)){goRunTimeError("Failure registering class");return false;}//Create the window, and check if it's createdhWnd=CreateWindowEx(0,title,title,dwStyle, 0,0,width,height,NULL,NULL, hInstance,NULL);if (hWnd==NULL){goRunTimeError("Failure creating window");return false;}if (fullscreen){ ShowWindow(hWnd,SW_SHOW); //Show it normally }else{ShowWindow(hWnd,SW_MAXIMIZE); //Show the window maximized}UpdateWindow(hWnd); //Update the window//Initiate the interfacesgoInitD3D();InitDirectInput();myfont.CreateFont(gD3Ddevice);return true;}void CGOApp::goWindowKill(){ windowalive=false;}//DirectXbool CGOApp::goInitD3D(){ gD3D=Direct3DCreate8(D3D_SDK_VERSION); if (!gD3D) { goRunTimeError("Error getting DirectX 8"); return false; } hR=gD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT,&displaymode); if (FAILED(hR)) { goRunTimeError("Error getting adapter display mode"); return false; } ZeroMemory(&d3dpp,sizeof(d3dpp)); d3dpp.SwapEffect=D3DSWAPEFFECT_DISCARD; d3dpp.hDeviceWindow=hWnd; d3dpp.BackBufferCount=1; //Z buffer stuff d3dpp.EnableAutoDepthStencil=true; d3dpp.AutoDepthStencilFormat=D3DFMT_D16; if (fullscreen) { d3dpp.Windowed=false; d3dpp.BackBufferWidth=width; d3dpp.BackBufferHeight=height; d3dpp.BackBufferFormat=FindBitMode(); }else{ d3dpp.Windowed=true; d3dpp.BackBufferFormat=displaymode.Format; } hR=gD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &gD3Ddevice); if (FAILED(hR)) { goRunTimeError("Error creating D3D device"); return false; } RenderState(D3DRS_ZENABLE,TRUE);}bool CGOApp::InitDirectInput(){DirectInput8Create(hInstance,DIRECTINPUT_VERSION,IID_IDirectInput8,(void**)&directi,NULL);directi->CreateDevice(GUID_SysKeyboard,&devkeyboard,NULL);devkeyboard->SetDataFormat(&c_dfDIKeyboard);devkeyboard->SetCooperativeLevel(hWnd,DISCL_BACKGROUND | DISCL_NONEXCLUSIVE);devkeyboard->Acquire();directi->CreateDevice(GUID_SysMouse,&devmouse,NULL);devmouse->SetCooperativeLevel(hWnd,DISCL_BACKGROUND | DISCL_NONEXCLUSIVE);devmouse->SetDataFormat(&c_dfDIMouse);devmouse->Acquire();}void CGOApp::KillDirectInput(){if (devmouse){ devmouse->Unacquire(); devmouse->Release(); devmouse=NULL;}if (devkeyboard){ devkeyboard->Unacquire(); devkeyboard->Release(); devkeyboard=NULL;}if (directi){ directi->Release(); directi=NULL;}}bool CGOApp::KeyDown(GOBYTE keynum){if (keystate[keynum] & 0x80){ return true; }else{ return false;}}bool CGOApp::MouseDown(GOBYTE mousenum){ if (statemouse.rgbButtons[mousenum] & 0x80) { return true; }else{ return false; }}void CGOApp::goMessageLoop(){ if(PeekMessage(&messages,hWnd,0,0,PM_REMOVE)!=WM_QUIT) { TranslateMessage(&messages); DispatchMessage(&messages); } devkeyboard->GetDeviceState(sizeof(GOBYTE[256]),(LPVOID)keystate); devmouse->GetDeviceState(sizeof(DIMOUSESTATE),(LPVOID)&statemouse);}D3DFORMAT CGOApp::FindBitMode(){ hR=gD3D->CheckDeviceType(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_R5G6B5, D3DFMT_R5G6B5, FALSE); if (SUCCEEDED(hR)) return D3DFMT_R5G6B5; hR=gD3D->CheckDeviceType(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_X1R5G5B5, D3DFMT_X1R5G5B5, FALSE); if (SUCCEEDED(hR)) return D3DFMT_X1R5G5B5; goRunTimeError("Couldn't find a 16bit color format");}void CGOApp::goKillD3D(){ if (gD3Ddevice) { gD3Ddevice->Release(); gD3Ddevice=NULL; } if (gD3D) { gD3D->Release(); gD3D=NULL; }}void CGOApp::Cls(){ gD3Ddevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,0,0), 1.0f, 0);gD3Ddevice->BeginScene();}void CGOApp::Cls(GOBYTE r,GOBYTE g,GOBYTE b){ gD3Ddevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(r,g,b), 1.0f, 0);gD3Ddevice->BeginScene();}void CGOApp::Flip(){ gD3Ddevice->EndScene(); gD3Ddevice->Present(NULL, NULL, NULL, NULL);}void CGOApp::PointCamera(D3DXVECTOR3 *eye,D3DXVECTOR3 *at,D3DXVECTOR3 *up){ D3DXMatrixLookAtLH(&viewmatrix,eye,at,up); gD3Ddevice->SetTransform(D3DTS_VIEW,&viewmatrix);}void CGOApp::CameraRange(float pnear,float pfar){ D3DXMatrixPerspectiveFovLH(&matProj,D3DX_PI/4,((float)width/(float)height),pnear,pfar); gD3Ddevice->SetTransform(D3DTS_PROJECTION,&matProj);}void CGOApp::RenderState(D3DRENDERSTATETYPE pd3drender,DWORD pvalue){ gD3Ddevice->SetRenderState(pd3drender,pvalue);}//=======================================================================////========================= File Stuff ==================================////=======================================================================//bool CGOApp::Open(){ if (!log) log=fopen("debuglog.txt","a");}bool CGOApp::Close(){ if (log!=NULL) { fclose(log); log=NULL; }}void CGOApp::DebugLog(char *text,...){ Open(); va_list arglist; char buff[1024]; memset(buff,0,sizeof(buff)); va_start(arglist,text); vsprintf(buff,text,arglist); va_end(arglist); fprintf(log,buff); Close();} CPrimitives.h #ifndef CPRIMITIVES_H#define CPRIMITIVES_Htypedef unsigned char GOBYTE;class CGOPRIMITIVE{public: CGOPRIMITIVE(); CGOPRIMITIVE(DWORD,DWORD,D3DPRIMITIVETYPE,DWORD); ~CGOPRIMITIVE(); LPDIRECT3DTEXTURE8 GetTexture(); void TextureMesh(char *fname); bool Draw(); void Fill(void*); void Fill(void*,DWORD); IDirect3DDevice8* GetDevice() {return device;} void CreateVertexBuffer(IDirect3DDevice8*); void SetMatrix(D3DXMATRIX*); void MoveMesh(float,float,float); void RotateMesh(float,float,float);private:IDirect3DDevice8 *device; //A pointer to the deviceIDirect3DVertexBuffer8 *vb; //The vertex buffer pointerDWORD vertexspec; //The type of vertex (FVFs and that)DWORD vertexsize; //The size of the vertexDWORD vertexnum; //The number of verticesDWORD polycount; //The number of polysD3DPRIMITIVETYPE primtype; //The primitive type (Triangle list)LPDIRECT3DTEXTURE8 texture; //The texture handleD3DXMATRIX worldmatrix; //The world matrixD3DXMATRIX rotmatrix; //The rotation matrixD3DXMATRIX rotx; //The X rotation matrixD3DXMATRIX roty; //The Y rotation matrixD3DXMATRIX rotz; //The Z rotation matrixD3DXMATRIX transmatrix; //The translation matrixvoid Init();void Free();};#endif CPrimitives.cpp #include "CPrimitives.h" //Include the header filevoid CGOPRIMITIVE::Init(){ device=NULL; vb=NULL; vertexspec=0; vertexsize=0; vertexnum=0; polycount=0; texture=NULL; primtype=D3DPT_TRIANGLELIST; D3DXMatrixIdentity(&worldmatrix); D3DXMatrixIdentity(&rotmatrix); D3DXMatrixIdentity(&transmatrix); D3DXMatrixIdentity(&rotx); D3DXMatrixIdentity(&roty); D3DXMatrixIdentity(&rotz);}CGOPRIMITIVE::CGOPRIMITIVE(){ Init();}CGOPRIMITIVE::CGOPRIMITIVE(DWORD pvertcount,DWORD pvertspec,D3DPRIMITIVETYPE pprimtype,DWORD ppolycount){ Init(); vertexnum=pvertcount; vertexspec=pvertspec; vertexsize=D3DXGetFVFVertexSize(vertexspec); primtype=pprimtype; polycount=ppolycount;}CGOPRIMITIVE::~CGOPRIMITIVE(){ Free();}void CGOPRIMITIVE::Free(){ if (vb!=NULL) { vb->Release(); vb=NULL; } if (texture!=NULL) { texture->Release(); texture=NULL; }}void CGOPRIMITIVE::TextureMesh(char *fname){ D3DXCreateTextureFromFile(device,fname,&texture); device->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_SELECTARG1); device->SetTextureStageState(0,D3DTSS_COLORARG1,D3DTA_TEXTURE); device->SetTextureStageState(0,D3DTSS_ALPHAOP,D3DTOP_DISABLE); device->SetTextureStageState(0,D3DTSS_MAGFILTER,D3DTEXF_LINEAR); device->SetTextureStageState(0,D3DTSS_MINFILTER,D3DTEXF_LINEAR);}void CGOPRIMITIVE::CreateVertexBuffer(IDirect3DDevice8 *pdevice){ device=pdevice; device->CreateVertexBuffer(vertexnum*vertexsize, D3DUSAGE_WRITEONLY, vertexspec, D3DPOOL_MANAGED, &vb);}void CGOPRIMITIVE::Fill(void *pdata){ GOBYTE *vb_verts; vb->Lock(0, 0, &vb_verts, 0); memcpy(vb_verts,pdata,(vertexnum*vertexsize)); vb->Unlock();}void CGOPRIMITIVE::Fill(void *pdata,DWORD pcount){GOBYTE *vb_vertices; vb->Lock(0, 0, &vb_vertices, 0); memcpy(vb_vertices,pdata,(pcount*vertexsize)); vb->Unlock();}void CGOPRIMITIVE::SetMatrix(D3DXMATRIX* pmat){ worldmatrix=(*pmat);}bool CGOPRIMITIVE::Draw(){device->SetStreamSource(0,vb,vertexsize);device->SetVertexShader(vertexspec);device->SetTexture(0,texture);D3DXMatrixMultiply(&worldmatrix,&rotmatrix,&transmatrix);device->SetTransform(D3DTS_WORLD,&worldmatrix);device->DrawPrimitive(primtype,0,polycount);device->SetTexture(0,NULL);}void CGOPRIMITIVE::MoveMesh(float x,float y,float z){ D3DXMatrixTranslation(&transmatrix,x,y,z);}void CGOPRIMITIVE::RotateMesh(float xdir,float ydir,float zdir){ D3DXMatrixRotationX(&rotx,xdir); D3DXMatrixRotationY(&roty,ydir); D3DXMatrixRotationZ(&rotz,zdir); D3DXMatrixMultiply(&rotmatrix,&rotmatrix,&rotx); D3DXMatrixMultiply(&rotmatrix,&rotmatrix,&roty); D3DXMatrixMultiply(&rotmatrix,&rotmatrix,&rotz);} System.h #ifndef SYSTEM_H#define SYSTEM_HDWORD goGetMillisecs();void goRunTimeError(char*);#endif System.cpp #include "System.h"DWORD goGetMillisecs(){return GetTickCount();}void goRunTimeError(char* msg){ MessageBox(NULL,msg,"RunTimeError",MB_OK | MB_ICONEXCLAMATION | MB_TOPMOST);}
I'm getting loads of multiple definition errors, all prefixed with GUID_ and IID_. My source is getting so messed up