|
1 | 1 | #include "TRenderD3D/TD3DVertexPoolResource.h" |
2 | 2 | #include "TRenderD3D/TD3DVertexBlockResource.h" |
3 | 3 | #include "TRenderD3D/TD3DVertexFactoryResource.h" |
| 4 | +#include "TRenderD3D/TRenderD3DInterface.h" |
4 | 5 |
|
5 | 6 | //----------------------------------------------------------------------------- |
6 | 7 | // Enables memory debugging. |
@@ -62,18 +63,47 @@ TBOOL TVertexPoolResource::Validate() |
62 | 63 | // $TRenderD3DInterface: FUNCTION 10009c30 |
63 | 64 | void TVertexPoolResource::Invalidate() |
64 | 65 | { |
| 66 | + TIMPLEMENT(); |
65 | 67 | } |
66 | 68 |
|
67 | 69 | // $TRenderD3DInterface: FUNCTION 1000a500 |
68 | 70 | void TVertexPoolResource::OnDestroy() |
69 | 71 | { |
| 72 | + TIMPLEMENT(); |
70 | 73 | } |
71 | 74 |
|
72 | 75 | // $TRenderD3DInterface: FUNCTION 10009cd0 |
73 | 76 | TBOOL TVertexPoolResource::Lock(LockBuffer *a_pLockBuffer) |
74 | 77 | { |
75 | 78 | TVALIDADDRESS(a_pLockBuffer); |
76 | | - return TBOOL(); |
| 79 | + if ((m_uiLockCount++) == 0) { |
| 80 | + TUINT flags = GetFlags() & 7; |
| 81 | + if (flags == 1) { |
| 82 | + TASSERT(TFALSE==IsValid()); |
| 83 | + a_pLockBuffer->uiNumStreams = GetFactory()->GetVertexFormat()->GetNumStreams(); |
| 84 | + for (TUINT i = 0; i < a_pLockBuffer->uiNumStreams; i++) { |
| 85 | + a_pLockBuffer->apStreams[i] = m_apManagedStreams[i]; |
| 86 | + } |
| 87 | + return TTRUE; |
| 88 | + } |
| 89 | + else if (flags == 2) { |
| 90 | + TASSERT(TTRUE==GetRenderer()->IsInScene()); |
| 91 | + Validate(); |
| 92 | + if (GetVertexBlock()->Lock(a_pLockBuffer, 0)) { |
| 93 | + m_uiVertexOffset = a_pLockBuffer->uiOffset; |
| 94 | + return TTRUE; |
| 95 | + } |
| 96 | + } |
| 97 | + else if (flags == 4) { |
| 98 | + TASSERT(TTRUE == GetRenderer()->IsInScene()); |
| 99 | + Validate(); |
| 100 | + if (GetVertexBlock()->Lock(a_pLockBuffer, GetMaxVertices())) { |
| 101 | + m_uiVertexOffset = a_pLockBuffer->uiOffset; |
| 102 | + return TTRUE; |
| 103 | + } |
| 104 | + } |
| 105 | + } |
| 106 | + return TFALSE; |
77 | 107 | } |
78 | 108 |
|
79 | 109 | // $TRenderD3DInterface: FUNCTION 10009f60 |
@@ -105,5 +135,19 @@ void TVertexPoolResource::Unlock(TUSHORT a_uiNewNumVertices) |
105 | 135 | // $TRenderD3DInterface: FUNCTION 1000a3c0 |
106 | 136 | TBOOL TVertexPoolResource::Create(TVertexFactoryResourceInterface *a_pFactory, TUINT a_uiMaxVertices, TUINT a_uiFlags) |
107 | 137 | { |
108 | | - return TBOOL(); |
| 138 | + TASSERT(TFALSE==IsCreated()); |
| 139 | + if (a_uiFlags & 4) { |
| 140 | + a_uiFlags = a_uiFlags & ~4 | 2; |
| 141 | + } |
| 142 | + if (!TVertexPoolResourceInterface::Create(a_pFactory, a_uiMaxVertices, a_uiFlags)) { |
| 143 | + return TFALSE; |
| 144 | + } |
| 145 | + if (GetFlags() & 1) { |
| 146 | + TVertexFactoryFormat *vertexFormat = GetFactory()->GetVertexFormat(); |
| 147 | + for (TUINT i = 0; i < vertexFormat->m_uiNumStreams; i++) { |
| 148 | + m_apManagedStreams[i] = new TBYTE[a_uiMaxVertices * vertexFormat->m_aStreamFormats[i].m_uiVertexSize]; |
| 149 | + TVALIDADDRESS(m_apManagedStreams[i]); |
| 150 | + } |
| 151 | + } |
| 152 | + return TTRUE; |
109 | 153 | } |
0 commit comments