3 * Copyright (c) 2007-2010 SlimDX Group
\r
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
\r
6 * of this software and associated documentation files (the "Software"), to deal
\r
7 * in the Software without restriction, including without limitation the rights
\r
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
\r
9 * copies of the Software, and to permit persons to whom the Software is
\r
10 * furnished to do so, subject to the following conditions:
\r
12 * The above copyright notice and this permission notice shall be included in
\r
13 * all copies or substantial portions of the Software.
\r
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
\r
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
\r
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
\r
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
\r
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
\r
23 #include <windows.h>
\r
27 #include "../ComObject.h"
\r
29 #include "../math/Color4.h"
\r
30 #include "../math/Matrix.h"
\r
31 #include "../math/Vector2.h"
\r
32 #include "../math/Vector3.h"
\r
34 #include "Direct3D9Exception.h"
\r
39 using namespace System;
\r
40 using namespace System::Drawing;
\r
46 Line::Line( SlimDX::Direct3D9::Device^ device )
\r
50 HRESULT hr = D3DXCreateLine( device->InternalPointer, &line );
\r
51 if( RECORD_D3D9( hr ).IsFailure )
\r
52 throw gcnew Direct3D9Exception( Result::Last );
\r
57 Result Line::Begin()
\r
59 HRESULT hr = InternalPointer->Begin();
\r
60 return RECORD_D3D9( hr );
\r
65 HRESULT hr = InternalPointer->End();
\r
66 return RECORD_D3D9( hr );
\r
69 Result Line::Draw( array<Vector2>^ vertexList, Color4 color )
\r
71 pin_ptr<Vector2> pinnedVerts = &vertexList[0];
\r
73 HRESULT hr = InternalPointer->Draw( reinterpret_cast<D3DXVECTOR2*>( pinnedVerts ), vertexList->Length, color.ToArgb() );
\r
74 return RECORD_D3D9( hr );
\r
77 Result Line::DrawTransformed( array<Vector3>^ vertexList, Matrix transform, Color4 color )
\r
79 pin_ptr<Vector3> pinnedVerts = &vertexList[0];
\r
81 HRESULT hr = InternalPointer->DrawTransform( reinterpret_cast<D3DXVECTOR3*>( pinnedVerts ), vertexList->Length, reinterpret_cast<const D3DXMATRIX*>( &transform ), color.ToArgb() );
\r
82 return RECORD_D3D9( hr );
\r
85 Result Line::OnLostDevice()
\r
87 HRESULT hr = InternalPointer->OnLostDevice();
\r
88 return RECORD_D3D9( hr );
\r
91 Result Line::OnResetDevice()
\r
93 HRESULT hr = InternalPointer->OnResetDevice();
\r
94 return RECORD_D3D9( hr );
\r
97 SlimDX::Direct3D9::Device^ Line::Device::get()
\r
99 IDirect3DDevice9* device;
\r
100 HRESULT hr = InternalPointer->GetDevice( &device );
\r
101 if( RECORD_D3D9( hr ).IsFailure )
\r
104 return SlimDX::Direct3D9::Device::FromPointer( device );
\r
107 bool Line::Antialias::get()
\r
109 return InternalPointer->GetAntialias() > 0;
\r
112 void Line::Antialias::set( bool value )
\r
114 HRESULT hr = InternalPointer->SetAntialias( value );
\r
118 bool Line::GLLines::get()
\r
120 return InternalPointer->GetGLLines() > 0;
\r
123 void Line::GLLines::set( bool value )
\r
125 HRESULT hr = InternalPointer->SetGLLines( value );
\r
129 int Line::Pattern::get()
\r
131 return InternalPointer->GetPattern();
\r
134 void Line::Pattern::set( int value )
\r
136 HRESULT hr = InternalPointer->SetPattern( value );
\r
140 float Line::PatternScale::get()
\r
142 return InternalPointer->GetPatternScale();
\r
145 void Line::PatternScale::set( float value )
\r
147 HRESULT hr = InternalPointer->SetPatternScale( value );
\r
151 float Line::Width::get()
\r
153 return InternalPointer->GetWidth();
\r
156 void Line::Width::set( float value )
\r
158 HRESULT hr = InternalPointer->SetWidth( value );
\r