+++ /dev/null
-#include "stdafx.h"\r
-/*\r
-* Copyright (c) 2007-2010 SlimDX Group\r
-* \r
-* Permission is hereby granted, free of charge, to any person obtaining a copy\r
-* of this software and associated documentation files (the "Software"), to deal\r
-* in the Software without restriction, including without limitation the rights\r
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r
-* copies of the Software, and to permit persons to whom the Software is\r
-* furnished to do so, subject to the following conditions:\r
-* \r
-* The above copyright notice and this permission notice shall be included in\r
-* all copies or substantial portions of the Software.\r
-* \r
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
-* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
-* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
-* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
-* THE SOFTWARE.\r
-*/\r
-#include <windows.h>\r
-#include <d3d9.h>\r
-#include <d3dx9.h>\r
-\r
-#include "../ComObject.h"\r
-\r
-#include "../math/Color4.h"\r
-#include "../math/Vector3.h"\r
-\r
-#include "Device.h"\r
-#include "Sprite9.h"\r
-#include "Texture.h"\r
-\r
-#include "Direct3D9Exception.h"\r
-\r
-using namespace System;\r
-using namespace System::Drawing;\r
-\r
-namespace SlimDX\r
-{\r
-namespace Direct3D9\r
-{\r
- Sprite::Sprite( SlimDX::Direct3D9::Device^ device )\r
- {\r
- ID3DXSprite* sprite;\r
- \r
- HRESULT hr = D3DXCreateSprite( device->InternalPointer, &sprite );\r
- \r
- if( RECORD_D3D9( hr ).IsFailure )\r
- throw gcnew Direct3D9Exception( Result::Last );\r
-\r
- Construct(sprite);\r
- }\r
-\r
- Result Sprite::Begin( SpriteFlags flags )\r
- {\r
- HRESULT hr = InternalPointer->Begin( static_cast<DWORD>( flags ) );\r
- return RECORD_D3D9( hr );\r
- }\r
-\r
- Result Sprite::End()\r
- {\r
- HRESULT hr = InternalPointer->End();\r
- return RECORD_D3D9( hr );\r
- }\r
-\r
- Result Sprite::Flush()\r
- {\r
- HRESULT hr = InternalPointer->Flush();\r
- return RECORD_D3D9( hr );\r
- }\r
-\r
- Result Sprite::OnLostDevice()\r
- {\r
- HRESULT hr = InternalPointer->OnLostDevice();\r
- return RECORD_D3D9( hr );\r
- }\r
-\r
- Result Sprite::OnResetDevice()\r
- {\r
- HRESULT hr = InternalPointer->OnResetDevice();\r
- return RECORD_D3D9( hr );\r
- }\r
-\r
- SlimDX::Direct3D9::Device^ Sprite::Device::get()\r
- {\r
- IDirect3DDevice9* device;\r
-\r
- HRESULT hr = InternalPointer->GetDevice( &device );\r
- \r
- if( RECORD_D3D9( hr ).IsFailure )\r
- return nullptr;\r
-\r
- return SlimDX::Direct3D9::Device::FromPointer( device );\r
- }\r
-\r
- Matrix Sprite::Transform::get()\r
- {\r
- Matrix result;\r
-\r
- HRESULT hr = InternalPointer->GetTransform( reinterpret_cast<D3DXMATRIX*>( &result ) );\r
- RECORD_D3D9( hr );\r
-\r
- return result;\r
- }\r
-\r
- void Sprite::Transform::set( Matrix value )\r
- {\r
- HRESULT hr = InternalPointer->SetTransform( reinterpret_cast<const D3DXMATRIX*>( &value ) );\r
- RECORD_D3D9( hr );\r
- }\r
-\r
- Result Sprite::SetWorldViewLH( Matrix world, Matrix view )\r
- {\r
- HRESULT hr = InternalPointer->SetWorldViewLH( reinterpret_cast<const D3DXMATRIX*>( &world ), reinterpret_cast<const D3DXMATRIX*>( &view ) );\r
- return RECORD_D3D9( hr );\r
- }\r
-\r
- Result Sprite::SetWorldViewRH( Matrix world, Matrix view )\r
- {\r
- HRESULT hr = InternalPointer->SetWorldViewRH( reinterpret_cast<const D3DXMATRIX*>( &world ), reinterpret_cast<const D3DXMATRIX*>( &view ) );\r
- return RECORD_D3D9( hr );\r
- }\r
-\r
- Result Sprite::Draw( Texture^ texture, Nullable<System::Drawing::Rectangle> sourceRect, Nullable<Vector3> center, Nullable<Vector3> position, Color4 color )\r
- {\r
- RECT rect = {0};\r
- RECT* rectPtr = 0;\r
- if(sourceRect.HasValue)\r
- {\r
- System::Drawing::Rectangle rectValue = sourceRect.Value;\r
- Utilities::ConvertRect(rectValue, rect);\r
- rectPtr = ▭\r
- }\r
-\r
- const D3DXVECTOR3* centerPtr = 0;\r
- Vector3 centerValue;\r
- if( center.HasValue ) \r
- {\r
- centerValue = center.Value;\r
- centerPtr = reinterpret_cast<const D3DXVECTOR3*>( ¢erValue );\r
- }\r
- \r
- const D3DXVECTOR3* positionPtr = 0;\r
- Vector3 positionValue;\r
- if( position.HasValue ) \r
- {\r
- positionValue = position.Value;\r
- positionPtr = reinterpret_cast<const D3DXVECTOR3*>( &positionValue );\r
- }\r
- \r
- HRESULT hr = InternalPointer->Draw( texture->InternalPointer, rectPtr, centerPtr, positionPtr, color.ToArgb() );\r
- return RECORD_D3D9( hr );\r
- }\r
-\r
- Result Sprite::Draw( Texture^ texture, Nullable<System::Drawing::Rectangle> sourceRect, Color4 color )\r
- {\r
- RECT rect = {0};\r
- RECT* rectPtr = 0;\r
- if(sourceRect.HasValue)\r
- {\r
- System::Drawing::Rectangle rectValue = sourceRect.Value;\r
- Utilities::ConvertRect(rectValue, rect);\r
- rectPtr = ▭\r
- }\r
-\r
- HRESULT hr = InternalPointer->Draw( texture->InternalPointer, rectPtr, NULL, NULL, color.ToArgb() );\r
- return RECORD_D3D9( hr );\r
- }\r
-\r
- Result Sprite::Draw( Texture^ texture, Nullable<Vector3> center, Nullable<Vector3> position, Color4 color )\r
- {\r
- const D3DXVECTOR3* centerPtr = 0;\r
- Vector3 centerValue;\r
- if( center.HasValue ) \r
- {\r
- centerValue = center.Value;\r
- centerPtr = reinterpret_cast<const D3DXVECTOR3*>( ¢erValue );\r
- }\r
- \r
- const D3DXVECTOR3* positionPtr = 0;\r
- Vector3 positionValue;\r
- if( position.HasValue ) \r
- {\r
- positionValue = position.Value;\r
- positionPtr = reinterpret_cast<const D3DXVECTOR3*>( &positionValue );\r
- }\r
-\r
- HRESULT hr = InternalPointer->Draw( texture->InternalPointer, NULL, centerPtr, positionPtr, color.ToArgb() );\r
- return RECORD_D3D9( hr );\r
- }\r
-\r
- Result Sprite::Draw( Texture^ texture, Color4 color )\r
- {\r
- HRESULT hr = InternalPointer->Draw( texture->InternalPointer, NULL, NULL, NULL, color.ToArgb() );\r
- return RECORD_D3D9( hr );\r
- }\r
-}\r
-}\r