void D3DGraphicContextProvider::set_primitives_array(const PrimitivesArray &primitives_array) { reset_primitives_array(); current_prim_array_provider = static_cast<D3DPrimitivesArrayProvider *>(primitives_array.get_provider()); std::vector<ID3D11Buffer*> buffers; std::vector<UINT> strides, offsets; current_prim_array_provider->get_vertex_buffers(buffers, strides, offsets); if (!buffers.empty()) window->get_device_context()->IASetVertexBuffers(0, buffers.size(), &buffers[0], &strides[0], &offsets[0]); }
void GL1GraphicContextProvider::set_primitives_array(const PrimitivesArray &primitives_array) { GL1PrimitivesArrayProvider * prim_array = static_cast<GL1PrimitivesArrayProvider *>(primitives_array.get_provider()); if (prim_arrays_set) reset_primitives_array(); set_active(); prim_arrays_set = true; num_set_tex_arrays = 0; for (size_t attribute_index = 0; attribute_index < prim_array->attributes.size(); attribute_index++) { if (!prim_array->attribute_set[attribute_index]) continue; const PrimitivesArrayProvider::VertexData &attribute = prim_array->attributes[attribute_index]; GL1VertexArrayBufferProvider *vertex_array_ptr = static_cast<GL1VertexArrayBufferProvider *>(attribute.array_provider); if (!vertex_array_ptr) throw Exception("Invalid BindBuffer Provider"); const char *data_ptr = ((const char *)vertex_array_ptr->get_data()) + attribute.offset; switch (attribute_index) { case 0: // POSITION glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(attribute.size, OpenGL::to_enum(attribute.type), attribute.stride, data_ptr); break; case 1: // COLOR glEnableClientState(GL_COLOR_ARRAY); glColorPointer(attribute.size, OpenGL::to_enum(attribute.type), attribute.stride, data_ptr); break; case 2: // TEXTURE primitives_array_texture = attribute; primitives_array_texture_set = true; break; case 3: // TEXINDEX primitives_array_texindex = attribute; primitives_array_texindex_set = true; break; case 4: // NORMAL glEnableClientState(GL_NORMAL_ARRAY); glNormalPointer(OpenGL::to_enum(attribute.type), attribute.stride, data_ptr); break; } } }
void D3DGraphicContextProvider::draw_primitives(PrimitivesType type, int num_vertices, const PrimitivesArray &primitives_array) { set_primitives_array(primitives_array); draw_primitives_array(type, 0, num_vertices); reset_primitives_array(); }