「C++/CLI/MdxHello」の編集履歴(バックアップ)一覧はこちら
C++/CLI/MdxHello - (2012/09/18 (火) 12:58:10) の1つ前との変更点
追加された行は緑色になります。
削除された行は赤色になります。
|開発環境|Microsoft Visual C++ 2010 Express (SP1)|
|実行環境|Microsoft Windows XP Home Edition (SP3)|
|プロジェクトの種類|空の CLR プロジェクト|
|プロジェクト名|MdxHello|
MdxHello.cpp
#highlight(cpp){{
/*
プロジェクト参照の追加
C:\WINDOWS\Microsoft.NET\DirectX for Managed Code\1.0.2902.0
Microsoft.DirectX.dll
Microsoft.DirectX.Direct3D.dll
Microsoft.DirectX.Direct3DX.dll
*/
#using <System.dll>
#using <System.Drawing.dll>
#using <System.Windows.Forms.dll>
using namespace System;
using namespace System::Drawing;
using namespace System::Windows::Forms;
using namespace Microsoft::DirectX;
using namespace Microsoft::DirectX::Direct3D;
public ref class HelloForm : public Form
{
private:
Device^ device;
PresentParameters^ presentParam;
Direct3D::Font^ font; // Direct3DX参照
public:
HelloForm()
{
Size = Drawing::Size(640,480);
Text = "hello, world";
}
bool InitD3D()
{
presentParam = gcnew PresentParameters();
presentParam->Windowed = true;
presentParam->SwapEffect = SwapEffect::Discard;
device = gcnew Device(0, DeviceType::Hardware, this,
CreateFlags::HardwareVertexProcessing, presentParam);
InitFont();
return true;
}
void InitFont()
{
FontDescription fd;
fd.Height = 16;
fd.FaceName = "MS ゴシック";
font = gcnew Direct3D::Font(device, fd);
}
void Render()
{
if (device == nullptr) return;
device->Clear(ClearFlags::Target, Color::Blue, 1.0f, 0);
device->BeginScene();
font->DrawText(nullptr, "Hello, DirectX(C++/CLI) World!",
10, 10, Color::White);
device->EndScene();
device->Present();
}
};
int main(array<System::String ^> ^args)
{
HelloForm^ form = gcnew HelloForm();
form->InitD3D();
form->Show();
while (form->Created) {
form->Render();
Application::DoEvents();
}
return 0;
}
}}
|開発環境|Microsoft Visual C++ 2010 Express (SP1)|
|実行環境|Microsoft Windows XP Home Edition (SP3)|
|プロジェクトの種類|空の CLR プロジェクト|
|プロジェクト名|MdxHello|
参考
[[CX's Hello, World! » Hello, DirectX(C++/CLI) World!>http://cx20.main.jp/blog/hello/2012/07/30/hello-directx-cpp-cli-world/]]
MdxHello.cpp
#highlight(cpp){{
/*
プロジェクト参照の追加
C:\WINDOWS\Microsoft.NET\DirectX for Managed Code\1.0.2902.0
Microsoft.DirectX.dll
Microsoft.DirectX.Direct3D.dll
Microsoft.DirectX.Direct3DX.dll
*/
#using <System.dll>
#using <System.Drawing.dll>
#using <System.Windows.Forms.dll>
using namespace System;
using namespace System::Drawing;
using namespace System::Windows::Forms;
using namespace Microsoft::DirectX;
using namespace Microsoft::DirectX::Direct3D;
public ref class HelloForm : public Form
{
private:
Device^ device;
PresentParameters^ presentParam;
Direct3D::Font^ font; // Direct3DX参照
public:
HelloForm()
{
Size = Drawing::Size(640,480);
Text = "hello, world";
}
bool InitD3D()
{
presentParam = gcnew PresentParameters();
presentParam->Windowed = true;
presentParam->SwapEffect = SwapEffect::Discard;
device = gcnew Device(0, DeviceType::Hardware, this,
CreateFlags::HardwareVertexProcessing, presentParam);
InitFont();
return true;
}
void InitFont()
{
FontDescription fd;
fd.Height = 16;
fd.FaceName = "MS ゴシック";
font = gcnew Direct3D::Font(device, fd);
}
void Render()
{
if (device == nullptr) return;
device->Clear(ClearFlags::Target, Color::Blue, 1.0f, 0);
device->BeginScene();
font->DrawText(nullptr, "Hello, DirectX(C++/CLI) World!",
10, 10, Color::White);
device->EndScene();
device->Present();
}
};
int main(array<System::String ^> ^args)
{
HelloForm^ form = gcnew HelloForm();
form->InitD3D();
form->Show();
while (form->Created) {
form->Render();
Application::DoEvents();
}
return 0;
}
}}