#include <windows.h> using namespace System; using namespace System::Windows::Forms; using namespace System::Drawing; using namespace SlimDX; using namespace SlimDX::Direct3D9; public ref class WndForm : public Form { Direct3D^ direct3D; Device^ device; PresentParameters^ presentParams; public: WndForm() { this->ClientSize = System::Drawing::Size(400, 300); this->StartPosition = FormStartPosition::CenterScreen; this->Text = "D3D Tutorial 2"; } ~WndForm() { this->!WndForm(); } !WndForm() { if (direct3D) delete direct3D; if (device) delete device; } bool InitD3D() { try { direct3D = gcnew Direct3D(); presentParams = gcnew PresentParameters(); presentParams->Windowed = true; presentParams->DeviceWindowHandle = this->Handle; presentParams->SwapEffect = SwapEffect::Discard; presentParams->BackBufferFormat = Format::X8R8G8B8; device = gcnew Device(direct3D, 0, DeviceType::Hardware, this->Handle, CreateFlags::SoftwareVertexProcessing | CreateFlags::Multithreaded, presentParams); return true; } catch (Direct3D9Exception^) { return false; } } void Render() { if (!device) return; device->Clear(ClearFlags::Target, Color::DarkGray, 1.0f, 0); device->BeginScene(); device->EndScene(); device->Present(); } }; INT WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, INT) { WndForm^ frm = gcnew WndForm(); if (!frm->InitD3D()) { MessageBox::Show("Initializing D3D Device Failed"); return 0; } frm->Show(); while (frm->Created) { frm->Render(); Application::DoEvents(); } delete frm; return 0; }
SlimDX Tutorial 2 - 디바이스 생성
여기서부터는 실제로 SlimDX를 사용하여 디바이스를 생성하므로 SlimDX 세팅법 글을 참조하여 프로젝트에 SlimDX를 포함시켜야합니다.
0 개의 댓글:
댓글 쓰기