25 #define RELEASE(x) if (x) { x->Release(); x=NULL; }
35 : video(dx9), vertex_buffer(0),
36 num_verts(nverts), num_locked(0), vert_size(vsize), next_vert(0),
39 UINT len = num_verts * vert_size;
42 is_dynamic = (usage & D3DUSAGE_DYNAMIC) ?
true :
false;
43 D3DPOOL pool = is_dynamic ? D3DPOOL_DEFAULT : D3DPOOL_MANAGED;
45 HRESULT hr = video->
D3DDevice()->CreateVertexBuffer(len,
53 static int report = 10;
76 if (vertex_buffer && count <= num_verts) {
83 flags = D3DLOCK_NOOVERWRITE;
85 if (next_vert + count > num_verts) {
87 flags = D3DLOCK_DISCARD;
94 hr = vertex_buffer->Lock(next_vert * vert_size,
101 return (BYTE*) result;
111 if (vertex_buffer && num_locked > 0) {
112 vertex_buffer->Unlock();
114 next_vert += num_locked;
122 if (video && vertex_buffer) {
128 hr = video->
D3DDevice()->SetStreamSource(stream,
169 : video(dx9), index_buffer(0),
170 num_indices(nind), num_locked(0), next_index(0),
173 UINT len = num_indices *
sizeof(WORD);
176 is_dynamic = (usage & D3DUSAGE_DYNAMIC) ?
true :
false;
177 D3DPOOL pool = is_dynamic ? D3DPOOL_DEFAULT : D3DPOOL_MANAGED;
179 HRESULT hr = video->
D3DDevice()->CreateIndexBuffer(len,
187 static int report = 10;
209 if (index_buffer && count <= num_indices) {
216 flags = D3DLOCK_NOOVERWRITE;
218 if (next_index + count > num_indices) {
220 flags = D3DLOCK_DISCARD;
227 hr = index_buffer->Lock(next_index * 2,
234 return (WORD*) result;
244 if (index_buffer && num_locked > 0) {
245 index_buffer->Unlock();
247 next_index += num_locked;
255 if (video && index_buffer) {
259 HRESULT hr = video->
D3DDevice()->SetIndices(index_buffer);