0001: // ---------------------------------------------------------------------------
0002: // File: tpotCGL.h
0003: //
0004: // OpenGLのラッパークラス
0005: //
0006: // Copyright (c) 2005 IMAGIRE Takashi. All rights reserved.
0007: // ---------------------------------------------------------------------------
0008: #pragma once
0009: 
0010: namespace tpot
0011: {
0012:     class CGl
0013:     {
0014:     private:
0015:         HWND   _hWnd;
0016:         HDC    _hDC;
0017:         HGLRC  _hglrc;
0018: 
0019:         int SetupPixelFormat( HDC hdc );// ピクセルフォーマットを設定する
0020:     public:
0021:         // コンストラクタ/デストラクタ
0022:         CGl( HWND hWnd );
0023:         ~CGl();
0024: 
0025:         void BeginRender();  // 描画開始時に呼ぶ
0026:         void EndRender();    // 描画終了時に呼ぶ
0027: 
0028:         void SetCurrent();   // レンダリング コンテキストをカレントにする
0029:     };
0030: 
0031:     // -----------------------------------------------------------------------
0032:     inline void CGl::SetCurrent()
0033:     {
0034:         wglMakeCurrent( _hDC, _hglrc );
0035:     }
0036:     // -----------------------------------------------------------------------
0037:     inline void CGl::BeginRender()
0038:     {
0039:         wglMakeCurrent( _hDC, _hglrc );
0040:     }
0041:     // -----------------------------------------------------------------------
0042:     inline void CGl::EndRender()
0043:     {
0044:         SwapBuffers( _hDC );
0045:         wglMakeCurrent( _hDC, 0);
0046:     }
0047: }// tpot
0048: