OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2009, Google Inc. | 2 * Copyright 2009, Google Inc. |
3 * All rights reserved. | 3 * All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 18 matching lines...) Expand all Loading... |
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
30 */ | 30 */ |
31 | 31 |
32 | 32 |
33 // This file contains the implementation of the GAPID3D9 class. | 33 // This file contains the implementation of the GAPID3D9 class. |
34 | 34 |
35 #include "command_buffer/service/win/d3d9/gapi_d3d9.h" | 35 #include "command_buffer/service/win/d3d9/gapi_d3d9.h" |
36 | 36 |
37 namespace o3d { | 37 namespace o3d { |
38 namespace command_buffer { | 38 namespace command_buffer { |
| 39 namespace o3d { |
39 | 40 |
40 GAPID3D9::GAPID3D9() | 41 GAPID3D9::GAPID3D9() |
41 : d3d_module_(NULL), | 42 : d3d_module_(NULL), |
42 d3dx_module_(NULL), | 43 d3dx_module_(NULL), |
43 d3d_(NULL), | 44 d3d_(NULL), |
44 d3d_device_(NULL), | 45 d3d_device_(NULL), |
45 hwnd_(NULL), | 46 hwnd_(NULL), |
46 current_vertex_struct_(0), | 47 current_vertex_struct_(0), |
47 validate_streams_(true), | 48 validate_streams_(true), |
48 max_vertices_(0), | 49 max_vertices_(0), |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 LOG(ERROR) << "Drawing with invalid streams."; | 303 LOG(ERROR) << "Drawing with invalid streams."; |
303 return false; | 304 return false; |
304 } | 305 } |
305 max_vertices_ = vertex_struct->SetStreams(this); | 306 max_vertices_ = vertex_struct->SetStreams(this); |
306 validate_streams_ = false; | 307 validate_streams_ = false; |
307 return max_vertices_ > 0; | 308 return max_vertices_ > 0; |
308 } | 309 } |
309 | 310 |
310 // Converts a GAPID3D9::PrimitiveType to a D3DPRIMITIVETYPE. | 311 // Converts a GAPID3D9::PrimitiveType to a D3DPRIMITIVETYPE. |
311 static D3DPRIMITIVETYPE D3DPrimitive( | 312 static D3DPRIMITIVETYPE D3DPrimitive( |
312 command_buffer::PrimitiveType primitive_type) { | 313 PrimitiveType primitive_type) { |
313 switch (primitive_type) { | 314 switch (primitive_type) { |
314 case command_buffer::kPoints: | 315 case kPoints: |
315 return D3DPT_POINTLIST; | 316 return D3DPT_POINTLIST; |
316 case command_buffer::kLines: | 317 case kLines: |
317 return D3DPT_LINELIST; | 318 return D3DPT_LINELIST; |
318 case command_buffer::kLineStrips: | 319 case kLineStrips: |
319 return D3DPT_LINESTRIP; | 320 return D3DPT_LINESTRIP; |
320 case command_buffer::kTriangles: | 321 case kTriangles: |
321 return D3DPT_TRIANGLELIST; | 322 return D3DPT_TRIANGLELIST; |
322 case command_buffer::kTriangleStrips: | 323 case kTriangleStrips: |
323 return D3DPT_TRIANGLESTRIP; | 324 return D3DPT_TRIANGLESTRIP; |
324 case command_buffer::kTriangleFans: | 325 case kTriangleFans: |
325 return D3DPT_TRIANGLEFAN; | 326 return D3DPT_TRIANGLEFAN; |
326 default: | 327 default: |
327 LOG(FATAL) << "Invalid primitive type"; | 328 LOG(FATAL) << "Invalid primitive type"; |
328 return D3DPT_POINTLIST; | 329 return D3DPT_POINTLIST; |
329 } | 330 } |
330 } | 331 } |
331 | 332 |
332 // Draws with the current vertex struct. | 333 // Draws with the current vertex struct. |
333 parse_error::ParseError GAPID3D9::Draw( | 334 parse_error::ParseError GAPID3D9::Draw( |
334 PrimitiveType primitive_type, | 335 PrimitiveType primitive_type, |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 return parse_error::kParseInvalidArguments; | 382 return parse_error::kParseInvalidArguments; |
382 } | 383 } |
383 | 384 |
384 HR(d3d_device_->SetIndices(index_buffer->d3d_index_buffer())); | 385 HR(d3d_device_->SetIndices(index_buffer->d3d_index_buffer())); |
385 HR(d3d_device_->DrawIndexedPrimitive(D3DPrimitive(primitive_type), 0, | 386 HR(d3d_device_->DrawIndexedPrimitive(D3DPrimitive(primitive_type), 0, |
386 min_index, max_index - min_index + 1, | 387 min_index, max_index - min_index + 1, |
387 first, count)); | 388 first, count)); |
388 return parse_error::kParseNoError; | 389 return parse_error::kParseNoError; |
389 } | 390 } |
390 | 391 |
| 392 } // namespace o3d |
391 } // namespace command_buffer | 393 } // namespace command_buffer |
392 } // namespace o3d | 394 } // namespace o3d |
OLD | NEW |