<?xml version="1.0" encoding="UTF-8" ?><rdf:RDF 
  xmlns="http://purl.org/rss/1.0/"
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xml:lang="ja">
  <channel rdf:about="http://www7.atwiki.jp/bleutruth/">
    <title>BleuTruthWiki</title>
    <link>http://www7.atwiki.jp/bleutruth/</link>
    <description>BleuTruthWiki</description>

    <dc:language>ja</dc:language>
    <dc:date>2012-01-15T05:30:17+09:00</dc:date>

    <items>
      <rdf:Seq>
                <rdf:li rdf:resource="http://www7.atwiki.jp/bleutruth/pages/84.html" />
                <rdf:li rdf:resource="http://www7.atwiki.jp/bleutruth/pages/76.html" />
                <rdf:li rdf:resource="http://www7.atwiki.jp/bleutruth/pages/90.html" />
                <rdf:li rdf:resource="http://www7.atwiki.jp/bleutruth/pages/80.html" />
                <rdf:li rdf:resource="http://www7.atwiki.jp/bleutruth/pages/89.html" />
                <rdf:li rdf:resource="http://www7.atwiki.jp/bleutruth/pages/88.html" />
                <rdf:li rdf:resource="http://www7.atwiki.jp/bleutruth/pages/61.html" />
                <rdf:li rdf:resource="http://www7.atwiki.jp/bleutruth/pages/87.html" />
                <rdf:li rdf:resource="http://www7.atwiki.jp/bleutruth/pages/78.html" />
                <rdf:li rdf:resource="http://www7.atwiki.jp/bleutruth/pages/86.html" />
              </rdf:Seq>
    </items>
	
		
    
  </channel>
    <item rdf:about="http://www7.atwiki.jp/bleutruth/pages/84.html">
    <title>言語/Squirrel/リファレンス</title>
    <link>http://www7.atwiki.jp/bleutruth/pages/84.html</link>
    <description>
      #contents
----
*Virtual Machine
**sq_close
 void sq_close(HSQUIRRELVM v);
 VMとすべてのfriendVMを解放します。

**sq_getforeignptr
 SQUserPointer sq_getforeignptr(HSQUIRRELVM v);
 VMの外部ポインタを返します。

**sq_getprintfunc
 SQPRINTFUNCTION sq_getprintfunc(HSQUIRRELVM v);
 VMに設定されたprint関数を返します。

**sq_getvmstate
 SQInteger sq_getvmstate(HSQUIRRELVM v);
 VMの実行状態を返します。
 SQ_VMSTATE_IDLE, SQ_VMSTATE_RUNNING, SQ_VMSTATE_SUSPENDEDのいずれかの値を返します。

**sq_move
 void sq_move(HSQUIRRELVM dest, HSQUIRRELVM src, SQInteger idx);
 srcVMのidxの位置にあるオブジェクトを、destVMにPushします。
 srcVMからはオブジェクトはなくなりません。

**sq_newthread
 HSQUIRRELVM sq_newthread(HSQUIRRELVM friendvm, SQInteger initialstacksize);
 第1引数で与えられたVMのfriendとしてVMを新たに生成して返します。
 またthreadオブジェクトを(引数で与えられたVMへ)Pushします。

**sq_open
 HSQUIRRELVM sq_open(SQInteger initialstacksize);
 新しい実行スタックを持ったSquirrelVMの新しいインスタンスを生成します。

**sq_pushconsttable
 SQRESULT sq_pushconsttable(HSQUIRRELVM v);

**sq_pushregistrytable
 SQRESULT sq_pushregistrytable(HSQUIRRELVM v);

**sq_pushroottable
 SQRESULT sq_pushroottable(HSQUIRRELVM v);
 スタックにルートテーブルをPushします。

**sq_setconsttable
 void sq_setconsttable(HSQUIRRELVM v);

**sq_seterrorhandler
 void sq_seterrorhandler(HSQUIRRELVM v);

**sq_setforeignptr
 void sq_setforeignptr(HSQUIRRELVM v, SQUserPointer p);

**sq_setprintfunc
 void sq_setprintfunc(HSQUIRRELVM v, SQPRINTFUNCTION printfunc);

**sq_setroottable
 void sq_setroottable(HSQUIRRELVM v);

**sq_suspendvm
 HRESULT sq_suspendvm(HSQUIRRELVM v);
 指定したVMの実行状態をサスペンドします。

**sq_wakeupvm
 HRESULT sq_wakeupvm(HSQUIRRELVM v, SQBool resumedret, SQBool retval, SQBool raiseerror);
 サスペンドされていたVMを起動します。

*Compiler
**sq_compile
 SQRESULT sq_compile(HSQUIRRELVM v, HSQLEXREADFUNC read, SQUserPointer p, const SQChar * sourcename, SQBool raiseerror);
 Squirrelのプログラムをコンパイルします。
 コンパイルに成功すれば、関数としてスタックにプッシュします。

**sq_compilebuffer
 SQRESULT sq_compilebuffer(HSQUIRRELVM v, const SQChar* s, SQInteger size, const SQChar * sourcename, SQBool raiseerror);
 メモリ上のバッファに置かれたSquirrelプログラムをコンパイルします。
 コンパイルに成功すれば、関数としてスタックにプッシュします。

**sq_enabledebuginfo
 void sq_enabledebuginfo(HSQUIRRELVM v, SQBool enable);

**sq_notifyallexceptions
 void sq_notifyallexceptions(HSQUIRRELVM v, SQBool enable);

**sq_setcompilererrorhandler
 void sq_setcompilererrorhandler(HSQUIRRELVM v, SQCOMPILERERROR f);

*Stack Operations
**sq_cmp
 SQInteger sq_cmp(HSQUIRRELVM v);

**sq_gettop
 SQInteger sq_gettop(HSQUIRRELVM v);
 スタックトップのインデックス(スタックに要素がいくつ積まれているか)を返します。

**sq_pop
 void sq_pop(HSQUIRRELVM v, SQInteger nelementstopop);
 スタックからn個の要素をPopします。

**sq_poptop
 void sq_poptop(HSQUIRRELVM v);

**sq_push
 void sq_push(HSQUIRRELVM v, SQInteger idx);

**sq_remove
 void sq_remove(HSQUIRRELVM v, SQInteger idx);

**sq_reservestack
 void sq_reservestack(HSQUIRRELVM v, SQInteger nsize);

**sq_settop
 void sq_settop(HSQUIRRELVM v, SQInteger v);
 スタックをリサイズし、リサイズ後のサイズが現在の大きさよりも大きければnullで埋めます。

*Object creation and handling
**sq_bindenv
 SQRESULT sq_bindenv(HSQUIRRELVM v, SQInteger idx);

**sq_createinstance
 SQRESULT sq_createinstance(HSQUIRRELVM v, SQInteger idx);

**sq_getbool
 SQRESULT sq_getbool(HSQUIRRELVM v, SQInteger idx, SQBool * b);

**sq_getclosureinfo
 SQRESULT sq_getclosureinfo(HSQUIRRELVM v, SQInteger idx, SQUnsignedInteger * nparams, SQUnsignedInteger * nfreevars);

**sq_getfloat
 SQRESULT sq_getfloat(HSQUIRRELVM v, SQInteger idx, SQFloat * f);

**sq_getinstanceup
 SQRESULT sq_getinstanceup(HSQUIRRELVM v, SQInteger idx, SQUserPointer * up, SQUSerPointer typetag);

**sq_getinteger
 SQRESULT sq_getinteger(HSQUIRRELVM v, SQInteger idx, SQInteger * i);

**sq_getscratchpad
 SQChar * sq_getscratchpad(HSQUIRRELVM v, SQInteger minsize);

**sq_getsize
 SQObjectType sq_getsize(HSQUIRRELVM v, SQInteger idx);

**sq_getstring
 SQRESULT sq_getstring(HSQUIRRELVM v, SQInteger idx, const SQChar ** c);

**sq_getthread
 SQRESULT sq_getthread(HSQUIRRELVM v, SQInteger idx, HSQUIRRELVM* v);

**sq_gettype
 SQObjectType sq_gettype(HSQUIRRELVM v, SQInteger idx);

**sq_gettypetag
 SQRESULT sq_gettypetag(HSQUIRRELVM v, SQInteger idx, SQUserPointer * typetag);

**sq_getuserdata
 SQRESULT sq_getuserdata(HSQUIRRELVM v, SQInteger idx, SQUserPointer * p, SQUserPointer * typetag);

**sq_getuserpointer
 SQRESULT sq_getuserpointer(HSQUIRRELVM v, SQInteger idx, SQUserPointer * p);

**sq_newarray
 void sq_newarray(HSQUIRRELVM v, SQInteger size);
 配列を生成し、スタックにPushします。

**sq_newclass
 SQRESULT sq_newclass(HSQUIRRELVM v, SQBool hasbase);
 クラスオブジェクトを生成し、スタックにPushします。

**sq_newclosure
 void sq_newclosure(HSQUIRRELVM v, HSQFUNCTION func, SQInteger nfreevars);
 ネイティブクロージャを生成し、スタックにPushします。

**sq_newtable
 void sq_newtable(HSQUIRRELVM v);
 テーブルを生成し、スタックにPushします。

**sq_newuserdata
 SQUserPointer sq_newuserdata(HSQUIRRELVM v, SQUnsignedInteger size);
 ユーザーデータを生成し、スタックにPushします。

**sq_pushbool
 void sq_pushbool(HSQUIRRELVM v, SQBool b);

**sq_pushfloat
 void sq_pushfloat(HSQUIRRELVM v, SQFloat f);

**sq_pushinteger
 void sq_pushinteger(HSQUIRRELVM v, SQInteger n);

**sq_pushnull
 void sq_pushnull(HSQUIRRELVM v);

**sq_pushstring
 void sq_pushstring(HSQUIRRELVM v, const SQChar * s, SQInteger len);
 文字列をスタックにPushします。
 lenの値が負の時は、strlen関数によって文字列の長さを計算します。

**sq_pushuserpointer
 void sq_pushuserpointer(HSQUIRRELVM v, SQUserPointer p);

**sq_setclassudsize
 SQRESULT sq_setclassudsize(HSQUIRRELVM v, SQInteger idx, SQInteger udsize);

**sq_setinstanceup
 SQRESULT sq_setinstanceup(HSQUIRRELVM v, SQInteger idx, SQUserPointer up);

**sq_setnativeclosurename
 SQRESULT sq_setnativeclosurename(HSQUIRRELVM v, SQInteger idx, const SQChar * name);
 スタックのidxの位置に、ネイティブクロージャの名前をセットします。
 ネイティブクロージャの名前は純粋にデバッグ目的です。

**sq_setparamscheck
 SQRESULT sq_setparamscheck(HSQUIRRELVM v, SQInteger nparamscheck, const SQChar * typemask);
 スタックトップにあるネイティブクロージャのためのパラメータ確認スキームをセットします。

**sq_setreleasehook
 void sq_setreleasehook(HSQUIRRELVM v, SQInteger idx, SQRELEASEHOOK hook);

**sq_settypetag
 SQRESULT sq_settypetag(HSQUIRRELVM v, SQInteger idx, SQUserPointer typetag);
 idxの位置にある(ユーザーデータorクラス)オブジェクトにタイプタグをセットします。

**sq_tobool
 void sq_tobool(HSQUIRRELVM v, SQInteger idx, SQBool * b);

**sq_tostring
 void sq_tostring(HSQUIRRELVM v, SQInteger idx);

*Calls
**sq_call
 SQRESULT sq_call(HSQUIRRELVM v, SQInteger params, SQBool retval, SQBool raiseerror);

**sq_getlasterror
 SQRESULT sq_getlasterror(HSQUIRRELVM v);

**sq_getlocal
 const SQChar * sq_getlocal(HSQUIRRELVM v, SQUnsignedInteger level, SQUnsignedInteger nseq);

**sq_reseterror
 void sq_reseterror(HSQUIRRELVM v);

**sq_resume
 SQRESULT sq_resume(HSQUIRRELVM v, SQBool retval, SQBool raiseerror);

**sq_throwerror
 SQRESULT sq_throwerror(HSQUIRRELVM v, const SQChar * err);

*Objects manipulation
**sq_arrayappend
 SQRESULT sq_arrayappend(HSQUIRRELVM v, SQInteger idx);
 スタックから値をPopし、指定されたインデックスにある配列の最後にPushします。

**sq_arrayinsert
 SQRESULT sq_arrayappend(HSQUIRRELVM v, SQInteger idx);

**sq_arraypop
 SQRESULT sq_arraypop(HSQUIRRELVM v, SQInteger idx);

**sq_arrayremove
 SQRESULT sq_arrayremove(HSQUIRRELVM v, SQInteger idx, SQInteger itemidx);

**sq_arrayresize
 SQRESULT sq_arrayresize(HSQUIRRELVM v, SQInteger idx, SQInteger newsize);

**sq_arrayreverse
 SQRESULT sq_arrayreverse(HSQUIRRELVM v, SQInteger idx);

**sq_clear
 SQRESULT sq_clear(HSQUIRRELVM v, SQInteger idx);

**sq_clone
 SQRESULT sq_clone(HSQUIRRELVM v, SQInteger idx);

**sq_createslot
 SQRESULT sq_createslot(HSQUIRRELVM v, SQInteger idx);
 スタックからキーと値をPopし、idxの位置にあるテーブルorクラスへセットします。
 スロットが存在しなければ作成します。既に存在している場合は、値を書き換えます。

**sq_deleteslot
 SQRESULT sq_deleteslot(HSQUIRRELVM v, SQInteger idx, SQBool pushval);

**sq_get
 SQRESULT sq_get(HSQUIRRELVM v, SQInteger idx);
 スタックからキーをPopし、idxの位置にあるオブジェクトに対してGet操作を行ないます。
 取得されたものはスタックへPushされます。
 この呼び出しは、テーブル、配列、ユーザーデータに対して働きます。
 取得できなかった時は、スタックには何もPushされません。

**sq_getattributes
 SQRESULT sq_getattributes(HSQUIRRELVM v, SQInteger idx);

**sq_getclass
 SQRESULT sq_getclass(HSQUIRRELVM v, SQInteger idx);

**sq_getdelegate
 SQRESULT sq_getdelegate(HSQUIRRELVM v, SQInteger idx);

**sq_getfreevariable
 const SQChar * sq_getfreevariable(HSQUIRRELVM v, SQInteger idx, SQInteger nval);

**sq_getweakrefval
 SQRESULT sq_getweakrefval(HSQUIRRELVM v, SQInteger idx);

**sq_instanceof
 SQBool sq_instanceof(HSQUIRRELVM v);

**sq_newslot
 SQRESULT sq_newslot(HSQUIRRELVM v, SQInteger idx, SQBool bstatic);

**sq_next
 SQRESULT sq_next(HSQUIRRELVM v, SQInteger idx);

**sq_rawdeleteslot
 SQRESULT sq_rawdeleteslot(HSQUIRRELVM v, SQInteger idx, SQBool pushval);

**sq_rawget
 SQRESULT sq_rawget(HSQUIRRELVM v, SQInteger idx);

**sq_rawset
 SQRESULT sq_rawset(HSQUIRRELVM v, SQInteger idx);

**sq_set
 SQRESULT sq_set(HSQUIRRELVM v, SQInteger idx);

**sq_setattributes
 SQRESULT sq_setattributes(HSQUIRRELVM v, SQInteger idx);

**sq_setdelegate
 SQRESULT sq_setdelegate(HSQUIRRELVM v, SQInteger idx);

**sq_setfreevariable
 SQRESULT sq_setfreevariable(HSQUIRRELVM v, SQInteger idx, SQInteger nval);

**sq_weakref
 void sq_weakref(HSQUIRRELVM v, SQInteger idx);

*Bytecode serialization
**sq_readclosure
 SQRESULT sq_readclosure(HSQUIRRELVM v, SQREADFUNC readf, SQUserPointer up);

**sq_writeclosure
 SQRESULT sq_writeclosure(HSQUIRRELVM v, SQWRITEFUNC writef, SQUserPointer up);

*Raw object handling
**sq_addref
 void sq_addref(HSQUIRRELVM v, HSQOBJECT * po);
 オブジェクトハンドラの参照カウンタを1つ加算します。

**sq_getobjtypetag
 SQRESULT sq_getobjtypetag(HSQOBJECT * o, SQUserPointer * typetag);

**sq_getstackobj
 SQRESULT sq_getstackobj(HSQUIRRELVM v, SQInteger idx, HSQOBJECT * po);
 スタックからオブジェクトを取得し、オブジェクトハンドラに入れます。
 取得したオブジェクトは、スタックから取り除かれません。

**sq_objtobool
 SQBool sq_objtobool(HSQOBJECT * po);

**sq_objtofloat
 SQFloat sq_objtofloat(HSQOBJECT * po);

**sq_objtointeger
 SQInteger sq_objtointeger(HSQOBJECT * po);

**sq_objtostring
 const SQChar * sq_objtostring(HSQOBJECT * po);

**sq_pushobject
 void sq_pushobject(HSQUIRRELVM v, HSQOBJECT obj);
 スタックにオブジェクトをPushします。

**sq_release
 SQBool sq_release(HSQUIRRELVM v, HSQOBJECT * po);
 オブジェクトハンドラの参照カウンタを1つ減算します。

**sq_resetobject
 void sq_resetobject(HSQUIRRELVM v, HSQOBJECT * po);
 オブジェクトハンドラをリセット(初期化)します。

*Debug interface
**sq_getfunctioninfo
 SQRESULT sq_getfunctioninfo(HSQUIRRELVM v, SQInteger level, SQStackInfos * si);

**sq_setdebughook
 void sq_setdebughook(HSQUIRRELVM v);

**sq_stackinfos
 SQRESULT sq_stackinfos(HSQUIRRELVM v, SQInteger level, SQStackInfos * si);

#amazon2()    </description>
    <dc:date>2012-01-15T05:30:17+09:00</dc:date>
  </item>
    <item rdf:about="http://www7.atwiki.jp/bleutruth/pages/76.html">
    <title>言語/C++/ライブラリ/STL/for_each</title>
    <link>http://www7.atwiki.jp/bleutruth/pages/76.html</link>
    <description>
      *サンプル1
**ソース
#highlight(linenumber,cpp){{
#include &lt;list&gt;
#include &lt;algorithm&gt;

void Print(int n)
{
  printf(&quot;%d\n&quot;, n);
}

int main()
{
  std::list&lt;int&gt; lst;

  lst.push_back(1);
  lst.push_back(2);
  lst.push_back(3);
  lst.push_back(4);
  lst.push_back(5);

  std::for_each(lst.begin(), lst.end(), Print);

  return 0;
}
}}

**実行結果
 1
 2
 3
 4
 5

*サンプル2
**ソース
#highlight(linenumber,cpp){{
#include &lt;list&gt;
#include &lt;algorithm&gt;

class Functor{

public:
  void operator()(int n)
  {
    printf(&quot;%d\n&quot;, n);
  }

};

int main()
{
  std::list&lt;int&gt; lst;

  lst.push_back(1);
  lst.push_back(2);
  lst.push_back(3);
  lst.push_back(4);
  lst.push_back(5);

  Functor functor;
  std::for_each(lst.begin(), lst.end(), functor);

  return 0;
}
}}

**実行結果
 1
 2
 3
 4
 5

*サンプル3
**ソース
#highlight(linenumber,cpp){{
#include &lt;list&gt;
#include &lt;algorithm&gt;

class Sum{

public:

  Sum() : sum(0){}

  void print()
  {
    printf(&quot;sum -&gt; %d\n&quot;, sum);
  }

  void operator()(int n)
  {
    sum += n;
  }

private:

  int sum;

};

int main()
{
  std::list&lt;int&gt; lst;

  lst.push_back(1);
  lst.push_back(2);
  lst.push_back(3);
  lst.push_back(4);
  lst.push_back(5);

  Sum sum;
  sum = std::for_each(lst.begin(), lst.end(), sum);

  sum.print();

  return 0;
}
}}

**実行結果
 sum -&gt; 15

#amazon2()    </description>
    <dc:date>2011-11-06T05:30:14+09:00</dc:date>
  </item>
    <item rdf:about="http://www7.atwiki.jp/bleutruth/pages/90.html">
    <title>ゲーム/DX11/背景のクリア</title>
    <link>http://www7.atwiki.jp/bleutruth/pages/90.html</link>
    <description>
      #highlight(cpp){{
//  WinMain.cpp

#include &lt;windows.h&gt;

#include &quot;MyApp.h&quot;

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
  // Enable run-time memory check for debug builds.
  _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );

  std::auto_ptr&lt;MyApp&gt; p(new MyApp(hInstance, hPrevInstance, lpCmdLine, nCmdShow));
  p-&gt;Run();
  return 0;
}

/*_________EOF_______________________________________________________________*/
}}

#highlight(cpp){{
// MyApp.h

#ifndef MYAPP_H_20110221
#define MYAPP_H_20110221

#include &lt;windows.h&gt;

class MyApp{

public:

  MyApp(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow);

  virtual ~MyApp();

  void Run();

private:

  bool Init();
  void Terminate();

  void MainLoop();
  void RunOneFrame();

  HINSTANCE hInstance, hPrevInstance;
  LPSTR lpCmdLine;
  int nCmdShow;

};

#endif  //  MYAPP_H_20110221
/*__________EOF______________________________________________________________*/
}}

#highlight(cpp){{
// MyApp.cpp

#include &quot;MyApp.h&quot;

#include &quot;Window.h&quot;
#include &quot;Renderer.h&quot;

MyApp::MyApp(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
 :  hInstance(hInstance), hPrevInstance(hPrevInstance), lpCmdLine(lpCmdLine), nCmdShow(nCmdShow)
{
}

MyApp::~MyApp()
{
}

void MyApp::Run()
{
  if(!Init()){
    Terminate();
    return;
  }

  MainLoop();
  Terminate();
}

bool MyApp::Init()
{
  Window* window = Window::Create(hInstance, hPrevInstance, lpCmdLine, nCmdShow, 1280, 720);
  if(!window){
    return false;
  }

  if(!Renderer::Create(window-&gt;WindowHandle(), window-&gt;WindowWidth(), window-&gt;WindowHeight())){
    return false;
  }

  window-&gt;UpdateWindow();
  return true;
}

void MyApp::Terminate()
{
  Renderer::Delete();
  Window::Delete();
}

void MyApp::MainLoop()
{
  HWND hWnd = Window::Get()-&gt;WindowHandle();

  bool bGotMsg;
  MSG msg;
  msg.message = WM_NULL;
  PeekMessage( &amp;msg, NULL, 0U, 0U, PM_NOREMOVE );

  while( WM_QUIT != msg.message )
  {
    // Use PeekMessage() so we can use idle time to render the scene. 
    bGotMsg = ( PeekMessage( &amp;msg, NULL, 0U, 0U, PM_REMOVE ) != 0 );

    if( bGotMsg )
    {
      // Translate and dispatch the message
      if( hWnd == NULL ||
        0 == TranslateAccelerator( hWnd, 0, &amp;msg ) )
      {
        TranslateMessage( &amp;msg );
        DispatchMessage( &amp;msg );
      }
    }
    else
    {
      // Render a frame during idle time (no messages are waiting)
      RunOneFrame();
    }
    Sleep(1);
  }
}

void MyApp::RunOneFrame()
{
  Renderer* renderer = Renderer::Get();
  renderer-&gt;Clear();
  renderer-&gt;Swap();
}

/*_________EOF_______________________________________________________________*/
}}

#highlight(cpp){{
// Window.h

#ifndef SYSTEM_KERNEL_H_20101123
#define SYSTEM_KERNEL_H_20101123

#include &lt;windows.h&gt;

class Window{

public:

  virtual ~Window();

  void UpdateWindow();

  HWND WindowHandle() const{ return hWnd; }
  int WindowWidth() const{ return mWidth; }
  int WindowHeight() const{ return mHeight; }

  static Window* Create(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow, int w, int h);
  static void Delete();
  static Window* Get();

private:

  Window(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow, int w, int h);

  bool Init();

  static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);

  static char const* const sWindowName;

  HINSTANCE hInstance, hPrevInstance;
  LPSTR lpCmdLine;
  int nCmdShow;

  HWND hWnd;
  int const mWidth, mHeight;

};

#endif  //  SYSTEM_KERNEL_H_20101123
/*__________EOF______________________________________________________________*/
}}

#highlight(cpp){{
// Window.cpp

#include &quot;Window.h&quot;

namespace{
std::auto_ptr&lt;Window&gt; sInstance;
}  //  namespace

char const* const Window::sWindowName = &quot;MyDX11&quot;;

/*___________________________________________________________________________*/

Window::Window(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow, int w, int h)
 :  hInstance(hInstance), hPrevInstance(hPrevInstance), lpCmdLine(lpCmdLine), nCmdShow(nCmdShow),
    hWnd(0), mWidth(w), mHeight(h)
{
}

Window::~Window()
{
}

bool Window::Init()
{
  WNDCLASS wndClass;
  memset(&amp;wndClass, 0, sizeof(wndClass));

  wndClass.style = CS_DBLCLKS;
  wndClass.lpfnWndProc = WndProc;
  wndClass.hInstance = hInstance;
  wndClass.hIcon = 0;
  wndClass.hCursor = LoadCursor(0, IDC_ARROW);
  wndClass.hbrBackground = static_cast&lt;HBRUSH&gt;(GetStockObject(BLACK_BRUSH));
  wndClass.lpszMenuName = 0;
  wndClass.lpszClassName = sWindowName;

  if(!RegisterClass(&amp;wndClass)){
    return false;
  }

  RECT rc;
  SetRect(&amp;rc, 0, 0, mWidth, mHeight);
  AdjustWindowRect(&amp;rc, WS_OVERLAPPEDWINDOW, FALSE);

  hWnd = CreateWindow(sWindowName, sWindowName, WS_OVERLAPPEDWINDOW,
        CW_USEDEFAULT, CW_USEDEFAULT,
        rc.right - rc.left, rc.bottom - rc.top,
        0, 0, hInstance, 0);
  return true;
}

void Window::UpdateWindow()
{
  ShowWindow(hWnd, nCmdShow);
  ::UpdateWindow(hWnd);
}

LRESULT CALLBACK Window::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
  switch(uMsg){

  case WM_KEYDOWN:
    switch(wParam){
    case VK_ESCAPE:
      SendMessage(hWnd, WM_CLOSE, 0, 0);
      break;
    }
    break;

  case WM_CLOSE:
    DestroyWindow(hWnd);
    UnregisterClass(sWindowName, 0);
    return 0;

  case WM_DESTROY:
    PostQuitMessage(0);
    break;
  }
  return DefWindowProc(hWnd, uMsg, wParam, lParam);
}

Window* Window::Create(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow, int w, int h)
{
  sInstance.reset(new Window(hInstance, hPrevInstance, lpCmdLine, nCmdShow, w, h));
  if(!sInstance-&gt;Init()){
    sInstance.reset();
    return 0;
  }
  return sInstance.get();
}

void Window::Delete()
{
  sInstance.reset();
}

Window* Window::Get()
{
  return sInstance.get();
}

/*_________EOF_______________________________________________________________*/
}}

#highlight(cpp){{
// Renderer.h

#ifndef SYSTEM_RENDER_RENDERER_20101123
#define SYSTEM_RENDER_RENDERER_20101123

#include &lt;windows.h&gt;
#include &lt;D3D11.h&gt;

class Renderer{

public:

  virtual ~Renderer();

  void Clear();
  void Swap();

  int ScreenWidth() const{ return mWidth; }
  int ScreenHeight() const{ return mHeight; }

  static Renderer* Create(HWND, int, int);
  static void Delete();
  static Renderer* Get();

private:

  Renderer(HWND, int, int);

  bool Init();
  HRESULT CreateDeviceAndSwapChain();
  HRESULT CreateRenderTargetView();
  void SetViewport();

  HWND const hWnd;
  int const mWidth, mHeight;

  ID3D11Device* mDevice;
  ID3D11DeviceContext* mDeviceContext;
  IDXGISwapChain* mSwapChain;
  ID3D11RenderTargetView* mRenderTargetView;

};

#endif  //  SYSTEM_RENDER_RENDERER_20101123
/*__________EOF______________________________________________________________*/
}}

#highlight(cpp){{
// Renderer.cpp

#include &quot;Renderer.h&quot;  //  Renderer

namespace{
std::auto_ptr&lt;Renderer&gt; sInstance;
}  //  namespace

/*___________________________________________________________________________*/

Renderer::Renderer(HWND hWnd, int w, int h)
 :  hWnd(hWnd), mWidth(w), mHeight(h),
  mDevice(0), mDeviceContext(0), mSwapChain(0), mRenderTargetView(0)
{
}

Renderer::~Renderer()
{
  SafeRelease(mRenderTargetView);
  SafeRelease(mSwapChain);
  SafeRelease(mDeviceContext);
  SafeRelease(mDevice);
}

void Renderer::Clear()
{
  static FLOAT const sColor[4] = {0.2f, 0.2f, 0.2f, 1.0f};
  mDeviceContext-&gt;ClearRenderTargetView(mRenderTargetView, sColor);
}

void Renderer::Swap()
{
  mSwapChain-&gt;Present(1, 0);
}

bool Renderer::Init()
{
  if(FAILED(CreateDeviceAndSwapChain())){
    return false;
  }
  if(FAILED(CreateRenderTargetView())){
    return false;
  }
  SetViewport();
  return true;
}

HRESULT Renderer::CreateDeviceAndSwapChain()
{
  DXGI_SWAP_CHAIN_DESC desc;
  ZeroMemory(&amp;desc, sizeof(desc));

  desc.BufferDesc.Width = mWidth;
  desc.BufferDesc.Height = mHeight;
  desc.BufferDesc.RefreshRate.Numerator = 60;
  desc.BufferDesc.RefreshRate.Denominator = 1;
  desc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM_SRGB;
  desc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
  desc.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
  desc.SampleDesc.Count = 1;
  desc.SampleDesc.Quality = 0;
  desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
  desc.BufferCount = 2;
  desc.OutputWindow = hWnd;
  desc.Windowed = TRUE;
  desc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
  desc.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;

  D3D_FEATURE_LEVEL const LevelIn = D3D_FEATURE_LEVEL_11_0;
  D3D_FEATURE_LEVEL LevelOut;

  HRESULT hr = D3D11CreateDeviceAndSwapChain(
    0, D3D_DRIVER_TYPE_HARDWARE, 0, D3D11_CREATE_DEVICE_DEBUG,
    &amp;LevelIn, 1, D3D11_SDK_VERSION, &amp;desc,
    &amp;mSwapChain, &amp;mDevice, &amp;LevelOut, &amp;mDeviceContext);
  return hr;
}

HRESULT Renderer::CreateRenderTargetView()
{
  ID3D11Texture2D* back;
  HRESULT hr = mSwapChain-&gt;GetBuffer(0, __uuidof(ID3D11Texture2D), reinterpret_cast&lt;void**&gt;(&amp;back));
  if(FAILED(hr)){
    return hr;
  }

  hr = mDevice-&gt;CreateRenderTargetView(back, 0, &amp;mRenderTargetView);
  SafeRelease(back);
  return hr;
}

void Renderer::SetViewport()
{
  D3D11_VIEWPORT vp;

  vp.TopLeftX = 0.0f;
  vp.TopLeftY = 0.0f;
  vp.Width = static_cast&lt;FLOAT&gt;(mWidth);
  vp.Height = static_cast&lt;FLOAT&gt;(mHeight);
  vp.MinDepth = 0.0f;
  vp.MaxDepth = 1.0f;

  mDeviceContext-&gt;RSSetViewports(1, &amp;vp);
}

Renderer* Renderer::Create(HWND hWnd, int w, int h)
{
  sInstance.reset(new Renderer(hWnd, w, h));
  if(!sInstance-&gt;Init()){
    sInstance.reset();
    return 0;
  }
  return sInstance.get();
}

void Renderer::Delete()
{
  sInstance.reset();
}

Renderer* Renderer::Get()
{
  return sInstance.get();
}

/*_________EOF_______________________________________________________________*/
}}

#highlight(cpp){{
// PreCompile.h

#ifndef PRECOMPILE_H_20110222
#define PRECOMPILE_H_20110222

#include &lt;memory&gt;
#include &lt;string&gt;

#include &quot;typedef.h&quot;
#include &quot;Utility.h&quot;

#endif	//	PRECOMPILE_H_20110222
/*__________EOF______________________________________________________________*/
}}

#highlight(cpp){{
// PreCompile.cpp

#include &quot;PreCompile.h&quot;	//	PreCompile

/*_________EOF_______________________________________________________________*/
}}

#highlight(cpp){{
// typeder.h

#ifndef SYSTEM_TYPEDEF_H_20110221
#define SYSTEM_TYPEDEF_H_20110221

typedef char           s8;
typedef unsigned char  u8;
typedef short          s16;
typedef unsigned short u16;
typedef int            s32;
typedef unsigned int   u32;

typedef float          f32;
typedef double         f64;

#endif  // SYSTEM_TYPEDEF_H_20110221
/*__________EOF______________________________________________________________*/
}}

#highlight(cpp){{
// Utility.h

#ifndef SYSTEM_UTILITY_H_20101124
#define SYSTEM_UTILITY_H_20101124

#include &lt;DXGI.h&gt;

template&lt;typename T&gt; void SafeDelete(T*&amp; p){ delete p; p = 0; }
template&lt;typename T&gt; void SafeDeleteArray(T*&amp; p){ delete[] p; p = 0; }

template&lt;typename T&gt; void SafeRelease(T*&amp; p){ if(p){ p-&gt;Release(); p = 0; } }

#endif  // SYSTEM_UTILITY_H_20101124
/*__________EOF______________________________________________________________*/
}}
#amazon2()    </description>
    <dc:date>2011-02-27T20:46:58+09:00</dc:date>
  </item>
    <item rdf:about="http://www7.atwiki.jp/bleutruth/pages/80.html">
    <title>ゲーム/DX11</title>
    <link>http://www7.atwiki.jp/bleutruth/pages/80.html</link>
    <description>
      -[[ウィンドウの更新&gt;ゲーム/DX11/ウィンドウの更新]]
-[[背景のクリア&gt;ゲーム/DX11/背景のクリア]]
#amazon2()    </description>
    <dc:date>2011-02-27T20:46:44+09:00</dc:date>
  </item>
    <item rdf:about="http://www7.atwiki.jp/bleutruth/pages/89.html">
    <title>ゲーム/DX11/ウィンドウの更新</title>
    <link>http://www7.atwiki.jp/bleutruth/pages/89.html</link>
    <description>
      #highlight(cpp){{
//  WinMain.cpp

#include &lt;windows.h&gt;

#include &quot;MyApp.h&quot;

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
  // Enable run-time memory check for debug builds.
  _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );

  std::auto_ptr&lt;MyApp&gt; p(new MyApp(hInstance, hPrevInstance, lpCmdLine, nCmdShow));
  p-&gt;Run();
  return 0;
}

/*_________EOF_______________________________________________________________*/
}}

#highlight(cpp){{
// MyApp.h

#ifndef MYAPP_H_20110221
#define MYAPP_H_20110221

#include &lt;windows.h&gt;

class MyApp{

public:

  MyApp(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow);

  virtual ~MyApp();

  void Run();

private:

  bool Init();
  void Terminate();

  void MainLoop();
  void RunOneFrame();

  HINSTANCE hInstance, hPrevInstance;
  LPSTR lpCmdLine;
  int nCmdShow;

};

#endif  //  MYAPP_H_20110221
/*__________EOF______________________________________________________________*/
}}

#highlight(cpp){{
// MyApp.cpp

#include &quot;MyApp.h&quot;

#include &quot;Window.h&quot;
#include &quot;Renderer.h&quot;

MyApp::MyApp(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
 :  hInstance(hInstance), hPrevInstance(hPrevInstance), lpCmdLine(lpCmdLine), nCmdShow(nCmdShow)
{
}

MyApp::~MyApp()
{
}

void MyApp::Run()
{
  if(!Init()){
    Terminate();
    return;
  }

  MainLoop();
  Terminate();
}

bool MyApp::Init()
{
  Window* window = Window::Create(hInstance, hPrevInstance, lpCmdLine, nCmdShow, 1280, 720);
  if(!window){
    return false;
  }

  if(!Renderer::Create(window-&gt;WindowHandle(), window-&gt;WindowWidth(), window-&gt;WindowHeight())){
    return false;
  }

  window-&gt;UpdateWindow();
  return true;
}

void MyApp::Terminate()
{
  Renderer::Delete();
  Window::Delete();
}

void MyApp::MainLoop()
{
  HWND hWnd = Window::Get()-&gt;WindowHandle();

  bool bGotMsg;
  MSG msg;
  msg.message = WM_NULL;
  PeekMessage( &amp;msg, NULL, 0U, 0U, PM_NOREMOVE );

  while( WM_QUIT != msg.message )
  {
    // Use PeekMessage() so we can use idle time to render the scene. 
    bGotMsg = ( PeekMessage( &amp;msg, NULL, 0U, 0U, PM_REMOVE ) != 0 );

    if( bGotMsg )
    {
      // Translate and dispatch the message
      if( hWnd == NULL ||
        0 == TranslateAccelerator( hWnd, 0, &amp;msg ) )
      {
        TranslateMessage( &amp;msg );
        DispatchMessage( &amp;msg );
      }
    }
    else
    {
      // Render a frame during idle time (no messages are waiting)
      RunOneFrame();
    }
    Sleep(1);
  }
}

void MyApp::RunOneFrame()
{
  Renderer::Get()-&gt;Swap();
}

/*_________EOF_______________________________________________________________*/
}}

#highlight(cpp){{
// Window.h

#ifndef SYSTEM_KERNEL_H_20101123
#define SYSTEM_KERNEL_H_20101123

#include &lt;windows.h&gt;

class Window{

public:

  virtual ~Window();

  void UpdateWindow();

  HWND WindowHandle() const{ return hWnd; }
  int WindowWidth() const{ return mWidth; }
  int WindowHeight() const{ return mHeight; }

  static Window* Create(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow, int w, int h);
  static void Delete();
  static Window* Get();

private:

  Window(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow, int w, int h);

  bool Init();

  static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);

  static char const* const sWindowName;

  HINSTANCE hInstance, hPrevInstance;
  LPSTR lpCmdLine;
  int nCmdShow;

  HWND hWnd;
  int const mWidth, mHeight;

};

#endif  //  SYSTEM_KERNEL_H_20101123
/*__________EOF______________________________________________________________*/
}}

#highlight(cpp){{
// Window.cpp

#include &quot;Window.h&quot;

namespace{
std::auto_ptr&lt;Window&gt; sInstance;
}  //  namespace

char const* const Window::sWindowName = &quot;MyDX11&quot;;

/*___________________________________________________________________________*/

Window::Window(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow, int w, int h)
 :  hInstance(hInstance), hPrevInstance(hPrevInstance), lpCmdLine(lpCmdLine), nCmdShow(nCmdShow),
    hWnd(0), mWidth(w), mHeight(h)
{
}

Window::~Window()
{
}

bool Window::Init()
{
  WNDCLASS wndClass;
  memset(&amp;wndClass, 0, sizeof(wndClass));

  wndClass.style = CS_DBLCLKS;
  wndClass.lpfnWndProc = WndProc;
  wndClass.hInstance = hInstance;
  wndClass.hIcon = 0;
  wndClass.hCursor = LoadCursor(0, IDC_ARROW);
  wndClass.hbrBackground = static_cast&lt;HBRUSH&gt;(GetStockObject(BLACK_BRUSH));
  wndClass.lpszMenuName = 0;
  wndClass.lpszClassName = sWindowName;

  if(!RegisterClass(&amp;wndClass)){
    return false;
  }

  RECT rc;
  SetRect(&amp;rc, 0, 0, mWidth, mHeight);
  AdjustWindowRect(&amp;rc, WS_OVERLAPPEDWINDOW, FALSE);

  hWnd = CreateWindow(sWindowName, sWindowName, WS_OVERLAPPEDWINDOW,
        CW_USEDEFAULT, CW_USEDEFAULT,
        rc.right - rc.left, rc.bottom - rc.top,
        0, 0, hInstance, 0);
  return true;
}

void Window::UpdateWindow()
{
  ShowWindow(hWnd, nCmdShow);
  ::UpdateWindow(hWnd);
}

LRESULT CALLBACK Window::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
  switch(uMsg){

  case WM_KEYDOWN:
    switch(wParam){
    case VK_ESCAPE:
      SendMessage(hWnd, WM_CLOSE, 0, 0);
      break;
    }
    break;

  case WM_CLOSE:
    DestroyWindow(hWnd);
    UnregisterClass(sWindowName, 0);
    return 0;

  case WM_DESTROY:
    PostQuitMessage(0);
    break;
  }
  return DefWindowProc(hWnd, uMsg, wParam, lParam);
}

Window* Window::Create(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow, int w, int h)
{
  sInstance.reset(new Window(hInstance, hPrevInstance, lpCmdLine, nCmdShow, w, h));
  if(!sInstance-&gt;Init()){
    sInstance.reset();
    return 0;
  }
  return sInstance.get();
}

void Window::Delete()
{
  sInstance.reset();
}

Window* Window::Get()
{
  return sInstance.get();
}

/*_________EOF_______________________________________________________________*/
}}

#highlight(cpp){{
// Renderer.h

#ifndef SYSTEM_RENDER_RENDERER_20101123
#define SYSTEM_RENDER_RENDERER_20101123

#include &lt;windows.h&gt;
#include &lt;D3D11.h&gt;

class Renderer{

public:

  virtual ~Renderer();

  void Swap();

  int ScreenWidth() const{ return mWidth; }
  int ScreenHeight() const{ return mHeight; }

  static Renderer* Create(HWND, int, int);
  static void Delete();
  static Renderer* Get();

private:

  Renderer(HWND, int, int);

  bool Init();
  HRESULT CreateDeviceAndSwapChain();
  void SetViewport();

  HWND const hWnd;
  int const mWidth, mHeight;

  ID3D11Device* mDevice;
  ID3D11DeviceContext* mDeviceContext;
  IDXGISwapChain* mSwapChain;

};

#endif  //  SYSTEM_RENDER_RENDERER_20101123
/*__________EOF______________________________________________________________*/
}}

#highlight(cpp){{
// Renderer.cpp

#include &quot;Renderer.h&quot;  //  Renderer

namespace{
std::auto_ptr&lt;Renderer&gt; sInstance;
}  //  namespace

/*___________________________________________________________________________*/

Renderer::Renderer(HWND hWnd, int w, int h)
 :  hWnd(hWnd), mWidth(w), mHeight(h),
  mDevice(0), mDeviceContext(0), mSwapChain(0)
{
}

Renderer::~Renderer()
{
  SafeRelease(mSwapChain);
  SafeRelease(mDeviceContext);
  SafeRelease(mDevice);
}

void Renderer::Swap()
{
  mSwapChain-&gt;Present(1, 0);
}

bool Renderer::Init()
{
  if(FAILED(CreateDeviceAndSwapChain())){
    return false;
  }
  SetViewport();
  return true;
}

HRESULT Renderer::CreateDeviceAndSwapChain()
{
  DXGI_SWAP_CHAIN_DESC desc;
  ZeroMemory(&amp;desc, sizeof(desc));

  desc.BufferDesc.Width = mWidth;
  desc.BufferDesc.Height = mHeight;
  desc.BufferDesc.RefreshRate.Numerator = 60;
  desc.BufferDesc.RefreshRate.Denominator = 1;
  desc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM_SRGB;
  desc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
  desc.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
  desc.SampleDesc.Count = 1;
  desc.SampleDesc.Quality = 0;
  desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
  desc.BufferCount = 2;
  desc.OutputWindow = hWnd;
  desc.Windowed = TRUE;
  desc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
  desc.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;

  D3D_FEATURE_LEVEL const LevelIn = D3D_FEATURE_LEVEL_11_0;
  D3D_FEATURE_LEVEL LevelOut;

  HRESULT hr = D3D11CreateDeviceAndSwapChain(
    0, D3D_DRIVER_TYPE_HARDWARE, 0, D3D11_CREATE_DEVICE_DEBUG,
    &amp;LevelIn, 1, D3D11_SDK_VERSION, &amp;desc,
    &amp;mSwapChain, &amp;mDevice, &amp;LevelOut, &amp;mDeviceContext);
  return hr;
}

void Renderer::SetViewport()
{
  D3D11_VIEWPORT vp;

  vp.TopLeftX = 0.0f;
  vp.TopLeftY = 0.0f;
  vp.Width = static_cast&lt;FLOAT&gt;(mWidth);
  vp.Height = static_cast&lt;FLOAT&gt;(mHeight);
  vp.MinDepth = 0.0f;
  vp.MaxDepth = 1.0f;

  mDeviceContext-&gt;RSSetViewports(1, &amp;vp);
}

Renderer* Renderer::Create(HWND hWnd, int w, int h)
{
  sInstance.reset(new Renderer(hWnd, w, h));
  if(!sInstance-&gt;Init()){
    sInstance.reset();
    return 0;
  }
  return sInstance.get();
}

void Renderer::Delete()
{
  sInstance.reset();
}

Renderer* Renderer::Get()
{
  return sInstance.get();
}

/*_________EOF_______________________________________________________________*/
}}

#highlight(cpp){{
// PreCompile.h

#ifndef PRECOMPILE_H_20110222
#define PRECOMPILE_H_20110222

#include &lt;memory&gt;
#include &lt;string&gt;

#include &quot;typedef.h&quot;
#include &quot;Utility.h&quot;

#endif	//	PRECOMPILE_H_20110222
/*__________EOF______________________________________________________________*/
}}

#highlight(cpp){{
// PreCompile.cpp

#include &quot;PreCompile.h&quot;	//	PreCompile

/*_________EOF_______________________________________________________________*/
}}

#highlight(cpp){{
// typeder.h

#ifndef SYSTEM_TYPEDEF_H_20110221
#define SYSTEM_TYPEDEF_H_20110221

typedef char           s8;
typedef unsigned char  u8;
typedef short          s16;
typedef unsigned short u16;
typedef int            s32;
typedef unsigned int   u32;

typedef float          f32;
typedef double         f64;

#endif  // SYSTEM_TYPEDEF_H_20110221
/*__________EOF______________________________________________________________*/
}}

#highlight(cpp){{
// Utility.h

#ifndef SYSTEM_UTILITY_H_20101124
#define SYSTEM_UTILITY_H_20101124

#include &lt;DXGI.h&gt;

template&lt;typename T&gt; void SafeDelete(T*&amp; p){ delete p; p = 0; }
template&lt;typename T&gt; void SafeDeleteArray(T*&amp; p){ delete[] p; p = 0; }

template&lt;typename T&gt; void SafeRelease(T*&amp; p){ if(p){ p-&gt;Release(); p = 0; } }

#endif  // SYSTEM_UTILITY_H_20101124
/*__________EOF______________________________________________________________*/
}}
#amazon2()    </description>
    <dc:date>2011-02-23T00:26:41+09:00</dc:date>
  </item>
    <item rdf:about="http://www7.atwiki.jp/bleutruth/pages/88.html">
    <title>言語/Squirrel/VMの生成と破棄</title>
    <link>http://www7.atwiki.jp/bleutruth/pages/88.html</link>
    <description>
      #highlight(cpp){{
// main.cpp

#include &lt;crtdbg.h&gt;
#include &lt;squirrel.h&gt;

int main()
{
  // Enable run-time memory check for debug builds.
  _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );

  SQInteger const STACK_SIZE = 1024;
  HSQUIRRELVM v = sq_open(STACK_SIZE);

  sq_close(v);
  return 0;
}
}}
#amazon2()    </description>
    <dc:date>2011-02-12T02:52:24+09:00</dc:date>
  </item>
    <item rdf:about="http://www7.atwiki.jp/bleutruth/pages/61.html">
    <title>言語/Squirrel</title>
    <link>http://www7.atwiki.jp/bleutruth/pages/61.html</link>
    <description>
      -[[VMの生成と破棄&gt;言語/Squirrel/VMの生成と破棄]]
-[[リファレンス&gt;言語/Squirrel/リファレンス]]
#amazon2()    </description>
    <dc:date>2011-02-12T02:48:44+09:00</dc:date>
  </item>
    <item rdf:about="http://www7.atwiki.jp/bleutruth/pages/87.html">
    <title>ゲーム/WinSDK/クライアント領域のサイズ</title>
    <link>http://www7.atwiki.jp/bleutruth/pages/87.html</link>
    <description>
      #highlight(cpp){{
// WinMain.cpp

#include &lt;windows.h&gt;
#include &lt;crtdbg.h&gt;

#include &quot;Window.h&quot;

namespace{

void MsgLoop(HWND);

} // namespace

/*___________________________________________________________________________*/

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
  // Enable run-time memory check for debug builds.
  _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );

  static int const WINDOW_W = 800;
  static int const WINDOW_H = 450;

  HWND hWnd = Window::Create(hInstance, WINDOW_W, WINDOW_H);
  if(!hWnd){
    return -1;
  }

  Window::Show(hWnd, nCmdShow);
  MsgLoop(hWnd);
  return 0;
}

/*___________________________________________________________________________*/

namespace{

void MsgLoop(HWND hWnd)
{
  MSG msg;
  msg.message = WM_NULL;

  PeekMessage(      // 着信した送信済みメッセージをディスパッチ（送出）し、
                    // スレッドのメッセージキューにポスト済みメッセージが存在するかどうかをチェックし、
                    // 存在する場合は、指定された構造体にそのメッセージを格納します。
    &amp;msg,           // メッセージ情報
    0,              // ウィンドウのハンドル
    0U,             // 最初のメッセージ
    0U,             // 最後のメッセージ
    PM_NOREMOVE);   // 削除オプション

  while(WM_QUIT != msg.message){

    if(PeekMessage(&amp;msg, 0, 0U, 0U, PM_REMOVE)){
      if(!hWnd || !TranslateAccelerator(    // メニューコマンドに対応するアクセラレータキー（ ショートカットキー）を処理します。
                      hWnd,                 // 目的のウィンドウのハンドル
                      0,                    // アクセラレータテーブルのハンドル
                      &amp;msg)){               // メッセージ情報

        TranslateMessage(   // 仮想キーメッセージを文字メッセージへ変換します。
          &amp;msg);            // メッセージ情報

        DispatchMessage(    // 1 つのウィンドウプロシージャへメッセージをディスパッチ（送出）します。
          &amp;msg);            // メッセージ情報
      }
    }
    Sleep(1);
  }
}

} // namespace
}}

#highlight(cpp){{
// Window.h
#ifndef WINDOW_H_20101122
#define WINDOW_H_20101122

#include &lt;windows.h&gt;

namespace Window{

HWND Create(HINSTANCE, int, int);
void Show(HWND, int);

} // namespace Window

#endif
}}

#highlight(cpp){{
// Window.cpp

#include &quot;Window.h&quot;

namespace{

char const * const sWindowName = &quot;Sample&quot;;

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

} // namespace

/*___________________________________________________________________________*/

namespace Window{

HWND Create(HINSTANCE hInstance, int w, int h)
{
  WNDCLASS wndClass;    // Contains the window class attributes that are registered by the RegisterClass function.
  memset(&amp;wndClass, 0, sizeof(wndClass));

  wndClass.style = CS_DBLCLKS;                          // The class style(s).
  wndClass.lpfnWndProc = WndProc;                       // A pointer to the window procedure.
  wndClass.hInstance = hInstance;                       // A handle to the instance that contains the window procedure for the class.
  wndClass.hIcon = 0;                                   // A handle to the class icon.
  wndClass.hCursor = LoadCursor(0, IDC_ARROW);          // A handle to the class cursor.
  wndClass.hbrBackground
    = static_cast&lt;HBRUSH&gt;(GetStockObject(BLACK_BRUSH)); // A handle to the class background brush.
  wndClass.lpszMenuName = 0;                            // The resource name of the class menu, as the name appears in the resource file.
  wndClass.lpszClassName = sWindowName;                 // A pointer to a null-terminated string or is an atom.

  if(!RegisterClass(&amp;wndClass)){    // ウィンドウクラスを登録します
    return 0;
  }

  // クライアント領域のサイズから、ウィンドウ全体のサイズを計算
  RECT rc;
  SetRect(&amp;rc, 0, 0, w, h);
  AdjustWindowRect(       // 指定されたクライアント領域を確保するために必要なウィンドウ座標を計算します。
    &amp;rc,                  // クライアント領域の座標が入った構造体へのポインタ
    WS_OVERLAPPEDWINDOW,  // ウィンドウスタイル
    FALSE);               // メニューを持つかどうかの指定

  HWND hWnd = CreateWindow(             // ウィンドウを作成します
                sWindowName,            // 登録されているクラス名
                sWindowName,            // ウィンドウ名
                WS_OVERLAPPEDWINDOW,    // ウィンドウスタイル
                CW_USEDEFAULT,          // ウィンドウの横方向の位置
                CW_USEDEFAULT,          // ウィンドウの縦方向の位置
                rc.right - rc.left,     // ウィンドウの幅
                rc.bottom - rc.top,     // ウィンドウの高さ
                0,                      // 親ウィンドウまたはオーナーウィンドウのハンドル
                0,                      // メニューハンドルまたは子ウィンドウ ID
                hInstance,              // アプリケーションインスタンスのハンドル
                0);                     // ウィンドウ作成データ
  return hWnd;
}

void Show(HWND hWnd, int nCmdShow)
{
  ShowWindow(   // 指定されたウィンドウの表示状態を設定します。
    hWnd,       // ウィンドウのハンドル
    nCmdShow);  // 表示状態

  UpdateWindow( // ウィンドウのクライアント領域を更新します
    hWnd);      // ウィンドウのハンドル
}

} // namespace Window

/*___________________________________________________________________________*/

namespace{

LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
  switch(uMsg){

  case WM_KEYDOWN:
    switch(wParam){
    case VK_ESCAPE:
      SendMessage(  // 1 つまたは複数のウィンドウへ、指定されたメッセージを送信します。
        hWnd,       // 送信先ウィンドウのハンドル
        WM_CLOSE,   // メッセージ
        0,          // メッセージの最初のパラメータ
        0);         // メッセージの 2 番目のパラメータ
      break;
    }
    break;

  case WM_CLOSE:
    DestroyWindow(    // ウィンドウを破棄します
      hWnd);          // 破棄するウィンドウのハンドル

    UnregisterClass(  // ウィンドウクラスを削除し、そのクラスのために使われていたメモリを解放します
      sWindowName,    // クラス名
      0);             // アプリケーションインスタンスのハンドル
    return 0;

  case WM_DESTROY:
    PostQuitMessage(  // 指定されたスレッドが自らの終了を要求したことをシステムに伝えます
      0);             // 終了コード
    break;
  }

  LRESULT result = DefWindowProc(   // 既定のウィンドウプロシージャを呼び出して、
                                    // アプリケーションが処理しないウィンドウメッセージに対して、既定の処理を提供します。
                      hWnd,         // ウィンドウのハンドル
                      uMsg,         // メッセージの識別子
                      wParam,       // メッセージの最初のパラメータ
                      lParam);      // メッセージの 2 番目のパラメータ
  return result;
}

} // namespace
}}
#amazon2()    </description>
    <dc:date>2010-11-23T01:40:42+09:00</dc:date>
  </item>
    <item rdf:about="http://www7.atwiki.jp/bleutruth/pages/78.html">
    <title>ゲーム/WinSDK</title>
    <link>http://www7.atwiki.jp/bleutruth/pages/78.html</link>
    <description>
      -[[WinMain&gt;ゲーム/WinSDK/WinMain]]
-[[ウィンドウ作成&gt;ゲーム/WinSDK/ウィンドウ作成]]
-[[メモリリークの検出&gt;ゲーム/WinSDK/メモリリーク検出]]
-[[Escキーでウィンドウを破棄出来るようにする&gt;ゲーム/WinSDK/Escキーウィンドウ破棄]]
-[[クライアント領域が指定したサイズになるようにする&gt;ゲーム/WinSDK/クライアント領域のサイズ]]
#amazon2()    </description>
    <dc:date>2010-11-23T01:08:04+09:00</dc:date>
  </item>
    <item rdf:about="http://www7.atwiki.jp/bleutruth/pages/86.html">
    <title>ゲーム/WinSDK/Escキーウィンドウ破棄</title>
    <link>http://www7.atwiki.jp/bleutruth/pages/86.html</link>
    <description>
      #highlight(cpp){{
// WinMain.cpp

#include &lt;windows.h&gt;
#include &lt;crtdbg.h&gt;

#include &quot;Window.h&quot;

namespace{

void MsgLoop(HWND);

} // namespace

/*___________________________________________________________________________*/

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
  // Enable run-time memory check for debug builds.
  _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );

  static int const WINDOW_W = 800;
  static int const WINDOW_H = 450;

  HWND hWnd = Window::Create(hInstance, WINDOW_W, WINDOW_H);
  if(!hWnd){
    return -1;
  }

  Window::Show(hWnd, nCmdShow);
  MsgLoop(hWnd);
  return 0;
}

/*___________________________________________________________________________*/

namespace{

void MsgLoop(HWND hWnd)
{
  MSG msg;
  msg.message = WM_NULL;

  PeekMessage(      // 着信した送信済みメッセージをディスパッチ（送出）し、
                    // スレッドのメッセージキューにポスト済みメッセージが存在するかどうかをチェックし、
                    // 存在する場合は、指定された構造体にそのメッセージを格納します。
    &amp;msg,           // メッセージ情報
    0,              // ウィンドウのハンドル
    0U,             // 最初のメッセージ
    0U,             // 最後のメッセージ
    PM_NOREMOVE);   // 削除オプション

  while(WM_QUIT != msg.message){

    if(PeekMessage(&amp;msg, 0, 0U, 0U, PM_REMOVE)){
      if(!hWnd || !TranslateAccelerator(    // メニューコマンドに対応するアクセラレータキー（ ショートカットキー）を処理します。
                      hWnd,                 // 目的のウィンドウのハンドル
                      0,                    // アクセラレータテーブルのハンドル
                      &amp;msg)){               // メッセージ情報

        TranslateMessage(   // 仮想キーメッセージを文字メッセージへ変換します。
          &amp;msg);            // メッセージ情報

        DispatchMessage(    // 1 つのウィンドウプロシージャへメッセージをディスパッチ（送出）します。
          &amp;msg);            // メッセージ情報
      }
    }
    Sleep(1);
  }
}

} // namespace
}}

#highlight(cpp){{
// Window.h
#ifndef WINDOW_H_20101122
#define WINDOW_H_20101122

#include &lt;windows.h&gt;

namespace Window{

HWND Create(HINSTANCE, int, int);
void Show(HWND, int);

} // namespace Window

#endif
}}

#highlight(cpp){{
// Window.cpp

#include &quot;Window.h&quot;

namespace{

char const * const sWindowName = &quot;Sample&quot;;

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

} // namespace

/*___________________________________________________________________________*/

namespace Window{

HWND Create(HINSTANCE hInstance, int w, int h)
{
  WNDCLASS wndClass;    // Contains the window class attributes that are registered by the RegisterClass function.
  memset(&amp;wndClass, 0, sizeof(wndClass));

  wndClass.style = CS_DBLCLKS;                          // The class style(s).
  wndClass.lpfnWndProc = WndProc;                       // A pointer to the window procedure.
  wndClass.hInstance = hInstance;                       // A handle to the instance that contains the window procedure for the class.
  wndClass.hIcon = 0;                                   // A handle to the class icon.
  wndClass.hCursor = LoadCursor(0, IDC_ARROW);          // A handle to the class cursor.
  wndClass.hbrBackground
    = static_cast&lt;HBRUSH&gt;(GetStockObject(BLACK_BRUSH)); // A handle to the class background brush.
  wndClass.lpszMenuName = 0;                            // The resource name of the class menu, as the name appears in the resource file.
  wndClass.lpszClassName = sWindowName;                 // A pointer to a null-terminated string or is an atom.

  if(!RegisterClass(&amp;wndClass)){    // ウィンドウクラスを登録します
    return 0;
  }

  HWND hWnd = CreateWindow(             // ウィンドウを作成します
                sWindowName,            // 登録されているクラス名
                sWindowName,            // ウィンドウ名
                WS_OVERLAPPEDWINDOW,    // ウィンドウスタイル
                CW_USEDEFAULT,          // ウィンドウの横方向の位置
                CW_USEDEFAULT,          // ウィンドウの縦方向の位置
                w,                      // ウィンドウの幅
                h,                      // ウィンドウの高さ
                0,                      // 親ウィンドウまたはオーナーウィンドウのハンドル
                0,                      // メニューハンドルまたは子ウィンドウ ID
                hInstance,              // アプリケーションインスタンスのハンドル
                0);                     // ウィンドウ作成データ
  return hWnd;
}

void Show(HWND hWnd, int nCmdShow)
{
  ShowWindow(   // 指定されたウィンドウの表示状態を設定します。
    hWnd,       // ウィンドウのハンドル
    nCmdShow);  // 表示状態

  UpdateWindow( // ウィンドウのクライアント領域を更新します
    hWnd);      // ウィンドウのハンドル
}

} // namespace Window

/*___________________________________________________________________________*/

namespace{

LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
  switch(uMsg){

  case WM_KEYDOWN:
    switch(wParam){

    // Escキーを受け取る
    case VK_ESCAPE:
      SendMessage(  // 1 つまたは複数のウィンドウへ、指定されたメッセージを送信します。
        hWnd,       // 送信先ウィンドウのハンドル
        WM_CLOSE,   // メッセージ
        0,          // メッセージの最初のパラメータ
        0);         // メッセージの 2 番目のパラメータ
      break;
    }
    break;

  case WM_CLOSE:
    DestroyWindow(    // ウィンドウを破棄します
      hWnd);          // 破棄するウィンドウのハンドル

    UnregisterClass(  // ウィンドウクラスを削除し、そのクラスのために使われていたメモリを解放します
      sWindowName,    // クラス名
      0);             // アプリケーションインスタンスのハンドル
    return 0;

  case WM_DESTROY:
    PostQuitMessage(  // 指定されたスレッドが自らの終了を要求したことをシステムに伝えます
      0);             // 終了コード
    break;
  }

  LRESULT result = DefWindowProc(   // 既定のウィンドウプロシージャを呼び出して、
                                    // アプリケーションが処理しないウィンドウメッセージに対して、既定の処理を提供します。
                      hWnd,         // ウィンドウのハンドル
                      uMsg,         // メッセージの識別子
                      wParam,       // メッセージの最初のパラメータ
                      lParam);      // メッセージの 2 番目のパラメータ
  return result;
}

} // namespace
}}
#amazon2()    </description>
    <dc:date>2010-11-23T00:22:35+09:00</dc:date>
  </item>
  </rdf:RDF>

