MrSqweaky

Members
  • Content count

    6
  • Joined

  • Last visited

Community Reputation

100 Neutral

About MrSqweaky

  • Rank
    Newbie
  1. C++ D3D9 window

    The program stopped here in main.cpp g_App.GetDevice()->CreateVertexBuffer(sizeof(aTriangle),D3DUSAGE_WRITEONLY,D3DFVF_CUSTOMVERTEX,D3DPOOL_MANAGED,&pTriangleVB,NULL); g_App.GetDevice()->CreateVertexBuffer(sizeof(aQuad),D3DUSAGE_WRITEONLY,D3DFVF_CUSTOMVERTEX,D3DPOOL_MANAGED,&pQuadVB,NULL); Can u try compile the code, my compiler having serious issues when it comes down to debugging(crashes)
  2. C++ D3D9 window

    Hello Steve, I have been busy with some pragma messages this is final result: 1>------ Rebuild All started: Project: twoking, Configuration: Debug Win32 ------ 1>Deleting intermediate and output files for project 'twoking', configuration 'Debug|Win32' 1>Compiling... 1>capplication.cpp [b]1>-Public CApplication prototypes - CApp.h[/b] [b]1>-Public inline functions - CApp.h[/b] [b]1>-Declarations -CApp.h[/b] [b]1>-D3DVERTEX Structure[/b] [b]1>Loading Main.h[/b] [b]1>Loading CApplication::CApplication[/b] [b]1>Loading CApplication::~CApplication[/b] [b]1>Loading InitWindow()[/b] [b]1>Loading InitD3D()[/b] [b]1>Loading InitScene[/b] [b]1>Loading KillD3D[/b] [b]1>Loading LoadSettings[/b] [b]1>Loading SaveSettinfs[/b] [b]1>Loadin KillWindow()[/b] 1>main.cpp 1>-Public CApplication prototypes 1>-Public inline functions 1>-Declarations 1>-D3DVERTEX Structure 1>Loading Main.h 1>winproc.cpp 1>-[b]Public CApplication prototypes[/b] [b]1>-Public inline functions[/b] [b]1>-Declarations[/b] [b]1>-D3DVERTEX Structure[/b] [b]1>Loading Main.h[/b] [b]1>Loading WinProc[/b] [b]1>Case ID_Start[/b] [b]1>Case ID_CANCEL[/b] [b]1>Case Escapekey[/b] [b]1>Case WM_DESTROY[/b] 1>Generating Code... 1>Linking... 1>LINK : C:\Users\Alx\Documents\Visual Studio 2008\Projects\twoking\Debug\twoking.exe not found or not built by the last incremental link; performing full link 1>Embedding manifest... 1>Build log was saved at "file://c:\Users\Alx\Documents\Visual Studio 2008\Projects\twoking\twoking\Debug\BuildLog.htm" 1>twoking - 0 error(s), 0 warning(s) ========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
  3. C++ D3D9 window

    Can u please move it to Technical side -> DirectX and XNA, just realized that i posted in wrong section.
  4. C++ D3D9 window

    Hey GameDev'ers Yet another question for u guys. I have compiled my code succesfully. BUT there is a flaw/bug the code that makes the window pop up and disappear again, in matter of 0,2 seconds. My debug out put said this on exiting: [code]The program '[5044] twoking.exe: Native' has exited with code 1 (0x1).[/code] I assume that 0x1 it is correctly closed, i cant seem to find any code that would terminate the window. Disable a few snippets and keeps happening. And a thing i found out is that its is probably the D3D code, when in only used the WIN32 code in worked fine. Here is my code: [b]CApplication.h[/b] [code]#ifndef capplication_h #define capplication_h #include"main.h" class CApplication { public: CApplication(void); ~CApplication(void); //win32 stuff void InitWindow(void); void SaveSettings(void); void LoadSettings(void); void KillWindow(void); //d3d stuff void InitD3D(void); void InitScene(void); void CheckDeviceCaps(void); bool CheckDevice(void); void KillD3D(void); //win32 prototypes inline bool GetWindowStatus(void) { return m_bRunningWindow; } inline HWND GetWindowHandle(void) { return m_hWindow; } inline void SetWindowStatus(bool bRunningWindow) { m_bRunningWindow = bRunningWindow; } //d3d inline bool GetD3DStatus(void) { return m_bRunningD3D; } inline LPDIRECT3DDEVICE9 GetDevice(void) { return m_pDirect3DDevice; } inline void SetD3DStatus(bool bRunningD3D) { m_bRunningD3D = bRunningD3D; } //win32 private: bool m_bRunningWindow, m_bRunningD3D; HWND m_hWindow, m_hBtnStart, m_hBtnCancel, m_hLblResolution, m_hCbResolution, m_hLblBackBuffer, m_hCbBackBuffer, m_hLblDepthStencil, m_hCbDepthStencil, m_hLblVertexProcessing, m_hCbVertexProcessing, m_hLblMultiSampling, m_hCbMultiSampling, m_hLblAnisotropy, m_hCbAnisotropy; LPDIRECT3D9 m_pDirect3DObject; LPDIRECT3DDEVICE9 m_pDirect3DDevice; D3DPRESENT_PARAMETERS m_PresentParameters; D3DCAPS9 m_DeviceCaps; DWORD m_dwWidth, m_dwHeight, m_dwVertexProcessing, m_dwAnisotropy; D3DFORMAT m_ColorFormat, m_DepthStencilFormat; D3DMULTISAMPLE_TYPE m_MultiSampling; D3DXMATRIX m_matProjection; float m_fAspectRatio, m_fFieldOfView, m_fNearPlane, m_fFarPlane; }; #endif[/code] [b]d3ddefs.h[/b] [code]#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ | D3DFVF_DIFFUSE) struct D3DVERTEX { float fX, fY,fZ; DWORD dwColor; };[/code][b]M[/b] [b]Main.[/b]h [code]#ifndef main_cpp #define main_cpp //Includes #include<windows.h> #include<commctrl.h> #include<d3d9.h> #include<d3dx9.h> #include<fstream> #include "capplication.h" #include "d3ddefs.h" //pragma #pragma comment(lib,"d3d9.lib") #pragma comment(lib,"d3dx9.lib") #pragma comment(lib, "comctl32.lib") //Constants #define TITLE "My First app" #define WINDOW_X 800 #define WINDOW_Y 600 //ids #define ID_START 1 #define ID_CANCEL 2 //globals extern CApplication g_App; //prototypes LRESULT CALLBACK WindowProcedure(HWND,UINT,WPARAM,LPARAM); #endif[/code] [b]CApplication.cpp[/b] [code]#include "main.h" CApplication::CApplication(void) { m_pDirect3DObject = NULL; m_pDirect3DDevice = NULL; m_dwWidth = 800; m_dwHeight = 600; m_ColorFormat = D3DFMT_R5G6B5; m_DepthStencilFormat = D3DFMT_D16; m_dwVertexProcessing = D3DCREATE_SOFTWARE_VERTEXPROCESSING; m_MultiSampling = D3DMULTISAMPLE_NONE; m_dwAnisotropy = 0; m_fFieldOfView = D3DX_PI / 4.0f; m_fNearPlane = 1.0f; m_fFarPlane = 1000.0f; m_fAspectRatio = (float)m_dwWidth / (float)m_dwHeight; m_bRunningWindow = true; m_bRunningD3D = false; InitWindow(); } CApplication::~CApplication(void) { KillD3D(); KillWindow(); } void CApplication::InitWindow(void) { WNDCLASSEX screen; RECT size; InitCommonControls(); GetClientRect(GetDesktopWindow(), &size); screen.cbSize = sizeof(WNDCLASSEX); screen.style = CS_HREDRAW | CS_VREDRAW; screen.lpfnWndProc = WindowProcedure; screen.cbClsExtra = 0; screen.cbWndExtra = 0; screen.hInstance = GetModuleHandle(NULL); screen.hIcon = NULL; screen.hCursor = NULL; screen.hbrBackground = GetSysColorBrush(COLOR_BTNFACE); screen.lpszMenuName = NULL; screen.lpszClassName = "Classname"; screen.hIconSm = LoadIcon(NULL, IDI_APPLICATION); RegisterClassEx(&screen); m_hWindow = CreateWindowEx(WS_EX_CONTROLPARENT, "Classname", TITLE, WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_VISIBLE, ((1650 / 2) - WINDOW_X) + (WINDOW_X / 100 * 55) , ((1050 / 2) - WINDOW_Y) + (WINDOW_Y / 100 * 45) , WINDOW_X, WINDOW_Y, NULL, NULL, GetModuleHandle(NULL), NULL); m_hLblResolution = CreateWindow("static", "Hai:3", WS_CHILD | WS_VISIBLE | SS_LEFT, 20, 20, 200, 18, m_hWindow, NULL, (HINSTANCE)GetWindowLong(m_hWindow, GWL_HINSTANCE), NULL); SendMessage(m_hCbResolution,CB_ADDSTRING,0,(long)"640 x 480"); SendMessage(m_hCbResolution,CB_ADDSTRING,0,(long)"800 x 600"); LoadSettings(); } void CApplication::InitD3D(void) { if((m_pDirect3DObject = Direct3DCreate9(D3D_SDK_VERSION)) == NULL) { MessageBox(m_hWindow, "[0x0]Failed to create Direct3D Object", "Init D3D", MB_OK); m_bRunningD3D = false; } ZeroMemory(&m_PresentParameters, sizeof(m_PresentParameters)); m_PresentParameters.Windowed = false; m_PresentParameters.SwapEffect = D3DSWAPEFFECT_DISCARD; m_PresentParameters.EnableAutoDepthStencil = true; m_PresentParameters.AutoDepthStencilFormat = m_DepthStencilFormat; m_PresentParameters.hDeviceWindow = m_hWindow; m_PresentParameters.BackBufferWidth = m_dwWidth; m_PresentParameters.BackBufferHeight = m_dwHeight; m_PresentParameters.BackBufferFormat = m_ColorFormat; m_PresentParameters.MultiSampleType = m_MultiSampling; if(FAILED(m_pDirect3DObject->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,m_hWindow,m_dwVertexProcessing,&m_PresentParameters,&m_pDirect3DDevice))) { MessageBox(m_hWindow, "[0x1]Failed to create Direct3D Device", "Init D3D", MB_OK); m_bRunningD3D = false; } ShowCursor(false); InitScene(); CheckDeviceCaps(); } void CApplication::InitScene(void) { D3DXMatrixPerspectiveFovLH(&m_matProjection, m_fFieldOfView,m_fAspectRatio,m_fNearPlane,m_fFarPlane); m_pDirect3DDevice->SetTransform(D3DTS_PROJECTION,&m_matProjection); m_pDirect3DDevice->SetRenderState(D3DRS_AMBIENT, RGB(255,255,255)); m_pDirect3DDevice->SetRenderState(D3DRS_LIGHTING, false); m_pDirect3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE); m_pDirect3DDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE); m_pDirect3DDevice->SetFVF(D3DFVF_CUSTOMVERTEX); for(unsigned i = 0;i < 8;++i) { m_pDirect3DDevice->SetSamplerState(i,D3DSAMP_MINFILTER,D3DTEXF_LINEAR); m_pDirect3DDevice->SetSamplerState(i,D3DSAMP_MAGFILTER,D3DTEXF_LINEAR); m_pDirect3DDevice->SetSamplerState(i,D3DSAMP_MIPFILTER,D3DTEXF_ANISOTROPIC); m_pDirect3DDevice->SetSamplerState(i,D3DSAMP_MAXANISOTROPY,m_dwAnisotropy); } } bool CApplication::CheckDevice(void) { switch(m_pDirect3DDevice->TestCooperativeLevel()) { case D3DERR_DEVICELOST: { MessageBox(m_hWindow,"[0x2]Device has been lost","CheckDevice()",MB_OK); return false; } case D3DERR_DEVICENOTRESET: { if(FAILED(m_pDirect3DDevice->Reset(&m_PresentParameters))) { MessageBox(m_hWindow,"[0x3]Device failed to reset","CheckDevice()",MB_OK); return false; } return true; } default: return true; } } void CApplication::CheckDeviceCaps(void) { //Do Nothing. } void CApplication::KillD3D(void) { if(m_pDirect3DDevice != NULL) { m_pDirect3DDevice->Release(); m_pDirect3DDevice = NULL; } if(m_pDirect3DObject != NULL) { m_pDirect3DObject->Release(); m_pDirect3DObject = NULL; } } void CApplication::LoadSettings(void) { } void CApplication::SaveSettings(void) { } void CApplication::KillWindow(void) { UnregisterClass("ClassName",GetModuleHandle(NULL)); } [/code] [b]Main.cpp[/b] [code]#include "main.h" //obj CApplication g_App; int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPreviousInstance,LPSTR lpcmdline,int nCmdShow) { MSG Message; LPDIRECT3DVERTEXBUFFER9 pTriangleVB = NULL; LPDIRECT3DVERTEXBUFFER9 pQuadVB = NULL; VOID* pData; D3DVERTEX aTriangle[] = {{-2.0f, 1.0f,10.0f,0xffff0000},{-3.0f,-1.0f,10.0f,0xff00ff00},{-1.0f,-1.0f,10.0f,0xff0000ff}}; D3DVERTEX aQuad[] = {{1.0f,-1.0f,10.0f,0xffffff00}, {3.0f,-1.0f,10.0f,0xffffff00}, {1.0f, 1.0f,10.0f,0xffffff00},{3.0f, 1.0f,10.0f,0xffffff00}}; g_App.GetDevice()->CreateVertexBuffer(sizeof(aTriangle),D3DUSAGE_WRITEONLY,D3DFVF_CUSTOMVERTEX,D3DPOOL_MANAGED,&pTriangleVB,NULL); g_App.GetDevice()->CreateVertexBuffer(sizeof(aQuad),D3DUSAGE_WRITEONLY,D3DFVF_CUSTOMVERTEX,D3DPOOL_MANAGED,&pQuadVB,NULL); pTriangleVB->Lock(0,sizeof(pData),(void**)&pData,0); memcpy(pData, aTriangle, sizeof(aTriangle)); pTriangleVB->Unlock(); pQuadVB->Lock(0, sizeof(pData),(void**)&pData, 0); memcpy(pData, aQuad, sizeof(aQuad)); pQuadVB->Unlock(); while(g_App.GetD3DStatus()) { if(PeekMessage(&Message, NULL, 0,0 , PM_REMOVE)) { TranslateMessage(&Message); DispatchMessage(&Message); } if(g_App.CheckDevice()) { g_App.GetDevice()->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,0,0), 1.0f, 0); g_App.GetDevice()->BeginScene(); driehoek g_App.GetDevice()->SetStreamSource(0,pTriangleVB,0,sizeof(D3DVERTEX)); g_App.GetDevice()->DrawPrimitive(D3DPT_TRIANGLELIST,0,1); Quad g_App.GetDevice()->SetStreamSource(0,pQuadVB,0,sizeof(D3DVERTEX)); g_App.GetDevice()->DrawPrimitive(D3DPT_TRIANGLESTRIP,0,2); */ g_App.GetDevice()->EndScene(); g_App.GetDevice()->Present(NULL,NULL,NULL,NULL); } } return 1; }//Winmain [/code] [b]Winproc.cpp[/b] [code]#include "main.h" LRESULT CALLBACK WindowProcedure(HWND hWindow,UINT uMessage,WPARAM wparam, LPARAM lparam) { switch(uMessage) { case WM_COMMAND: { switch(LOWORD(wparam)) { case ID_START: { g_App.SaveSettings(); g_App.SetWindowStatus(false); g_App.SetD3DStatus(true); SetFocus(hWindow); g_App.InitD3D(); break; } case ID_CANCEL: { DestroyWindow(hWindow); break; } } return 0; } case WM_KEYDOWN: { switch(wparam) { case VK_ESCAPE: { DestroyWindow(hWindow); break; } } return 0; } case WM_DESTROY: { g_App.SetWindowStatus(false); g_App.SetD3DStatus(false); break; } } return DefWindowProc(hWindow,uMessage,wparam,lparam); } //WindowProcedure[/code]
  5. C++ Linker error?

    [quote name='SiCrane' timestamp='1328481129' post='4909950'] You don't seem to have a function definition for your CheckDeviceCaps() function. [/quote] The tutorial said we will be covering that on a later stage of our programming course. What u saying is just add the function definition [code]CApplication::CheckDeviceCaps(void) { //Do Nothing. }[/code] [b]Edit: Worked fine, tutorial actually didnt say u need to define that:)[/b]
  6. [sub][i]Hello![/i][/sub] [size=5][sub][i]I have a question for u guys, i have tried to compile my code for the two-kings.de tutorial, everthing worked fine until the second lesson. I see to have a strange linker error. tried to look up wich lib was causing this error, no succes so far. So i think u guys can help me out with this error, it bougles my mind :l[/i][/sub] [sub][i]The error i get is this:[/i][/sub][/size] [sub][i][code]1>capplication.obj : error LNK2019: unresolved external symbol "public: void __thiscall CApplication::CheckDeviceCaps(void)" (?CheckDeviceCaps@CApplication@@QAEXXZ) referenced in function "public: void __thiscall CApplication::InitD3D(void)" (?InitD3D@CApplication@@QAEXXZ) 1>C:\Users\Alx\Documents\Visual Studio 2008\Projects\twoking\Debug\twoking.exe : fatal error LNK1120: 1 unresolved externals[/code][/i][/sub] [b]Here is my CApplication header[/b] [code][size=2]]#ifndef capplication_h #define capplication_h[/size] [size=2]#include"main.h"[/size] [size=2]class CApplication { public: CApplication(void); ~CApplication(void);[/size] [size=2]//win32 stuff void InitWindow(void); void SaveSettings(void); void LoadSettings(void); void KillWindow(void);[/size] [size=2]//d3d stuff void InitD3D(void); void InitScene(void); void CheckDeviceCaps(void); bool CheckDevice(void); void KillD3D(void);[/size] [size=2]//win32 prototypes inline bool GetWindowStatus(void) { return m_bRunningWindow; } inline HWND GetWindowHandle(void) { return m_hWindow; } inline void SetWindowStatus(bool bRunningWindow) { m_bRunningWindow = bRunningWindow; }[/size] [size=2]//d3d inline bool GetD3DStatus(void) { return m_bRunningD3D; } inline LPDIRECT3DDEVICE9 GetDevice(void) { return m_pDirect3DDevice; } inline void SetD3DStatus(bool bRunningD3D) { m_bRunningD3D = bRunningD3D; }[/size] [size=2]//win32 private: bool m_bRunningWindow, m_bRunningD3D; [/size] [size=2] HWND m_hWindow, m_hBtnStart, m_hBtnCancel, m_hLblResolution, m_hCbResolution, m_hLblBackBuffer, m_hCbBackBuffer, m_hLblDepthStencil, m_hCbDepthStencil, m_hLblVertexProcessing, m_hCbVertexProcessing, m_hLblMultiSampling, m_hCbMultiSampling, m_hLblAnisotropy, m_hCbAnisotropy;[/size] [size=2] LPDIRECT3D9 m_pDirect3DObject; LPDIRECT3DDEVICE9 m_pDirect3DDevice; D3DPRESENT_PARAMETERS m_PresentParameters; D3DCAPS9 m_DeviceCaps; [/size] [size=2] DWORD m_dwWidth, m_dwHeight, m_dwVertexProcessing, m_dwAnisotropy; D3DFORMAT m_ColorFormat, m_DepthStencilFormat; D3DMULTISAMPLE_TYPE m_MultiSampling;[/size] [size=2] D3DXMATRIX m_matProjection; float m_fAspectRatio, m_fFieldOfView, m_fNearPlane, m_fFarPlane; };[/size] [size=2]#endif[/size][/code] [b]And here my CApplication cpp file[/b] [size=2][code]#include "main.h"[/size] [size=2]CApplication::CApplication(void) { m_pDirect3DObject = NULL; m_pDirect3DDevice = NULL;[/size] [size=2] m_dwWidth = 800; m_dwHeight = 600;[/size] [size=2] m_ColorFormat = D3DFMT_R5G6B5; m_DepthStencilFormat = D3DFMT_D16; m_dwVertexProcessing = D3DCREATE_SOFTWARE_VERTEXPROCESSING; m_MultiSampling = D3DMULTISAMPLE_NONE; m_dwAnisotropy = 0;[/size] [size=2] m_fFieldOfView = D3DX_PI / 4.0f; m_fNearPlane = 1.0f; m_fFarPlane = 1000.0f; m_fAspectRatio = (float)m_dwWidth / (float)m_dwHeight;[/size] [size=2] m_bRunningWindow = true; m_bRunningD3D = false;[/size] [size=2] InitWindow(); }[/size] [size=2]CApplication::~CApplication(void) { KillD3D(); KillWindow(); }[/size] [size=2]void CApplication::InitWindow(void) { WNDCLASSEX screen; RECT size;[/size] [size=2]InitCommonControls(); GetClientRect(GetDesktopWindow(), &size);[/size] [size=2]screen.cbSize = sizeof(WNDCLASSEX); screen.style = CS_HREDRAW | CS_VREDRAW; screen.lpfnWndProc = WindowProcedure; screen.cbClsExtra = 0; screen.cbWndExtra = 0; screen.hInstance = GetModuleHandle(NULL); screen.hIcon = NULL; screen.hCursor = NULL; screen.hbrBackground = GetSysColorBrush(COLOR_BTNFACE); screen.lpszMenuName = NULL; screen.lpszClassName = "Classname"; screen.hIconSm = LoadIcon(NULL, IDI_APPLICATION);[/size] [size=2]RegisterClassEx(&screen);[/size] [size=2]m_hWindow = CreateWindowEx(WS_EX_CONTROLPARENT, "Classname", TITLE, WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_VISIBLE, ((1650 / 2) - WINDOW_X) + (WINDOW_X / 100 * 55) , ((1050 / 2) - WINDOW_Y) + (WINDOW_Y / 100 * 45) , WINDOW_X, WINDOW_Y, NULL, NULL, GetModuleHandle(NULL), NULL);[/size] [size=2]m_hLblResolution = CreateWindow("static", "Hai:3", WS_CHILD | WS_VISIBLE | SS_LEFT, 20, 20, 200, 18, m_hWindow, NULL, (HINSTANCE)GetWindowLong(m_hWindow, GWL_HINSTANCE), NULL); SendMessage(m_hCbResolution,CB_ADDSTRING,0,(long)"640 x 480"); SendMessage(m_hCbResolution,CB_ADDSTRING,0,(long)"800 x 600");[/size] [size=2]LoadSettings(); }[/size] [size=2]void CApplication::InitD3D(void) { if((m_pDirect3DObject = Direct3DCreate9(D3D_SDK_VERSION)) == NULL) { MessageBox(m_hWindow, "[0x0]Failed to create Direct3D Object", "Init D3D", MB_OK); m_bRunningD3D = false; } ZeroMemory(&m_PresentParameters, sizeof(m_PresentParameters)); m_PresentParameters.Windowed = false; m_PresentParameters.SwapEffect = D3DSWAPEFFECT_DISCARD; m_PresentParameters.EnableAutoDepthStencil = true; m_PresentParameters.AutoDepthStencilFormat = m_DepthStencilFormat; m_PresentParameters.hDeviceWindow = m_hWindow; m_PresentParameters.BackBufferWidth = m_dwWidth; m_PresentParameters.BackBufferHeight = m_dwHeight; m_PresentParameters.BackBufferFormat = m_ColorFormat; m_PresentParameters.MultiSampleType = m_MultiSampling; [/size] [size=2]if(FAILED(m_pDirect3DObject->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,m_hWindow,m_dwVertexProcessing,&m_PresentParameters,&m_pDirect3DDevice))) { MessageBox(m_hWindow, "[0x1]Failed to create Direct3D Device", "Init D3D", MB_OK); m_bRunningD3D = false; } ShowCursor(false);[/size] [size=2]InitScene(); CheckDeviceCaps(); } void CApplication::InitScene(void) { D3DXMatrixPerspectiveFovLH(&m_matProjection, m_fFieldOfView,m_fAspectRatio,m_fNearPlane,m_fFarPlane); m_pDirect3DDevice->SetTransform(D3DTS_PROJECTION,&m_matProjection);[/size] [size=2]for(unsigned i = 0;i < 8;++i) { m_pDirect3DDevice->SetSamplerState(i,D3DSAMP_MINFILTER,D3DTEXF_LINEAR); m_pDirect3DDevice->SetSamplerState(i,D3DSAMP_MAGFILTER,D3DTEXF_LINEAR); m_pDirect3DDevice->SetSamplerState(i,D3DSAMP_MIPFILTER,D3DTEXF_ANISOTROPIC); m_pDirect3DDevice->SetSamplerState(i,D3DSAMP_MAXANISOTROPY,m_dwAnisotropy); } }[/size] [size=2]bool CApplication::CheckDevice(void) { switch(m_pDirect3DDevice->TestCooperativeLevel()) { case D3DERR_DEVICELOST: { MessageBox(m_hWindow,"[0x2]Device has been lost","CheckDevice()",MB_OK); return false; } case D3DERR_DEVICENOTRESET: { if(FAILED(m_pDirect3DDevice->Reset(&m_PresentParameters))) { MessageBox(m_hWindow,"[0x3]Device failed to reset","CheckDevice()",MB_OK); return false; } return true; } default: return true; } }[/size] [size=2]void CApplication::KillD3D(void) { if(m_pDirect3DDevice != NULL) { m_pDirect3DDevice->Release(); m_pDirect3DDevice = NULL; } if(m_pDirect3DObject != NULL) { m_pDirect3DObject->Release(); m_pDirect3DObject = NULL; }[/size] [size=2]}[/size] [size=2]void CApplication::LoadSettings(void) { } [/size] [size=2]void CApplication::SaveSettings(void) { } [/size] [size=2]void CApplication::KillWindow(void) { UnregisterClass("ClassName",GetModuleHandle(NULL)); } [/code][/size]