| 687 | } |
| 688 | |
| 689 | void EnableVertexDeclaration(HContext _context, HVertexDeclaration vertex_declaration, uint32_t binding_index) |
| 690 | { |
| 691 | assert(_context); |
| 692 | assert(vertex_declaration); |
| 693 | |
| 694 | NullContext* context = (NullContext*) _context; |
| 695 | |
| 696 | VertexBuffer* vb = (VertexBuffer*) context->m_VertexBuffers[binding_index]; |
| 697 | assert(vb); |
| 698 | |
| 699 | uint16_t stride = 0; |
| 700 | |
| 701 | for (uint32_t i = 0; i < vertex_declaration->m_StreamCount; ++i) |
| 702 | { |
| 703 | stride += vertex_declaration->m_Streams[i].m_Size * TYPE_SIZE[vertex_declaration->m_Streams[i].m_Type - dmGraphics::TYPE_BYTE]; |
| 704 | } |
| 705 | |
| 706 | uint32_t offset = 0; |
| 707 | for (uint16_t i = 0; i < vertex_declaration->m_StreamCount; ++i) |
| 708 | { |
| 709 | VertexDeclaration::Stream& stream = vertex_declaration->m_Streams[i]; |
| 710 | if (stream.m_Size > 0) |
| 711 | { |
| 712 | stream.m_Location = i; |
| 713 | EnableVertexStream(_context, binding_index, i, stream.m_Size, stream.m_Type, stride, &vb->m_Buffer[offset]); |
| 714 | offset += stream.m_Size * TYPE_SIZE[stream.m_Type - dmGraphics::TYPE_BYTE]; |
| 715 | } |
| 716 | } |
| 717 | |
| 718 | context->m_VertexDeclarations[binding_index] = vertex_declaration; |
| 719 | } |
| 720 | |
| 721 | static void NullEnableVertexDeclaration(HContext context, HVertexDeclaration vertex_declaration, uint32_t binding_index, uint32_t base_offset, HProgram program) |
| 722 | { |