OSDN Git Service

dx9/idirect3d_device.hpp: begin_scene(), end_scene() Add. common.hpp: color_t
authorMyun2 <myun2@nwhite.info>
Sat, 16 Apr 2011 08:30:14 +0000 (17:30 +0900)
committerMyun2 <myun2@nwhite.info>
Sat, 16 Apr 2011 10:55:00 +0000 (19:55 +0900)
roast_ex/include/roast/graphics/directx/common.hpp
roast_ex/include/roast/graphics/directx/dx9/idirect3d_device.hpp

index 885624a..4f0700c 100644 (file)
@@ -69,7 +69,7 @@ namespace roast
                                throw api_exception(msg, api_ret);
                }
                
-               ///////////////////////////////////////////////////////////////////////////////
+               ///////////////////////////////////////////////////////////////////////////////////////
                
                template <typename T>
                class iunknown_
@@ -100,6 +100,20 @@ namespace roast
                        T* get_internal_if_ptr(){ return m_if; }
                        T* get_internal_ptr(){ return m_if; }
                };
+               
+               ///////////////////////////////////////////////////////////////////////////////////////
+
+               typedef ::D3DCOLOR color_t;
+               
+               namespace colordef
+               {
+                       enum
+                       {
+                               black = 0x00000000,
+                               blue = 0x000000ff,
+                               white = 0x00ffffff
+                       };
+               }
        }
 }
 
index ebdd876..f57bbcd 100644 (file)
@@ -32,7 +32,37 @@ namespace roast
                                                if ( hr != D3D_OK )
                                                        throw api_error("IDirect3D9::CreateDevice() Failed.", hr);
                                        }
+                                       
+                                       //////////////////////////////////////////////////////////////////////////////
+                                       
+                                       void begin_scene()
+                                       {
+                                               //if ( m_if == NULL )
+                                               //      throw exception("device::begin_scene()  not normally initialized.");
+
+                                               HRESULT hr = m_if->BeginScene();
+                                               if ( hr != D3D_OK )
+                                                       throw api_error("IDirect3DDevice9::BeginScene() Failed.", hr);
+                                       }
+                                       
+                                       void end_scene()
+                                       {
+                                               HRESULT hr = m_if->EndScene();
+                                               if ( hr != D3D_OK )
+                                                       throw api_error("IDirect3DDevice9::EndScene() Failed.", hr);
+                                       }
+                                       
+                                       void clear(const color_t& cl=colordef::black)
+                                       {
+                                               HRESULT hr = m_if->EndScene();
+                                               if ( hr != D3D_OK )
+                                                       throw api_error("IDirect3DDevice9::EndScene() Failed.", hr);
+                                       }
 
+                                       //Clear
+                                       
+                                       //////////////////////////////////////////////////////////////////////////////
+                                       
                                        idirect3d_device* get_idirect3d_device_ptr(){ return get_internal_ptr(); }
                                };