RocketRenderingInterface::RocketRenderingInterface() { renderOffset.x = 0.0f; renderOffset.y = 0.0f; vertex_stream_buffer = gr_create_buffer(BufferType::Vertex, BufferUsageHint::Streaming); index_stream_buffer = gr_create_buffer(BufferType::Index, BufferUsageHint::Streaming); layout.add_vertex_component(vertex_format_data::POSITION2, sizeof(Vertex), offsetof(Vertex, position)); layout.add_vertex_component(vertex_format_data::COLOR4, sizeof(Vertex), offsetof(Vertex, colour)); layout.add_vertex_component(vertex_format_data::TEX_COORD2, sizeof(Vertex), offsetof(Vertex, tex_coord)); }
CompiledGeometryHandle RocketRenderingInterface::CompileGeometry(Vertex* vertices, int num_vertices, int* indices, int num_indices, TextureHandle texture) { GR_DEBUG_SCOPE("libRocket::CompileGeometry"); auto* geom = new CompiledGeometry(); geom->vertex_buffer = gr_create_buffer(BufferType::Vertex, BufferUsageHint::Static); gr_update_buffer_data(geom->vertex_buffer, num_vertices * sizeof(Vertex), reinterpret_cast<void*>(vertices)); geom->index_buffer = gr_create_buffer(BufferType::Index, BufferUsageHint::Static); gr_update_buffer_data(geom->index_buffer, num_indices * sizeof(int), reinterpret_cast<void*>(indices)); geom->num_elements = num_indices; geom->texture = get_texture(texture); return reinterpret_cast<CompiledGeometryHandle>(geom); }
void batching_init_buffer(primitive_batch_buffer *buffer, primitive_type prim_type, uint vertex_mask) { batching_setup_vertex_layout(&buffer->layout, vertex_mask); buffer->buffer_num = gr_create_buffer(BufferType::Vertex, BufferUsageHint::Streaming); buffer->buffer_ptr = NULL; buffer->buffer_size = 0; buffer->desired_buffer_size = 0; buffer->prim_type = prim_type; }
UniformBuffer::UniformBuffer(size_t element_size, size_t header_size) : _aligner(element_size, header_size) { int offsetAlignment; bool success = gr_get_property(gr_property::UNIFORM_BUFFER_OFFSET_ALIGNMENT, &offsetAlignment); Assertion(success, "Uniform buffer usage requires a backend which allows to query the offset alignment!"); _aligner.setAlignment(static_cast<size_t>(offsetAlignment)); // This uses Dynamic since that matches our usage pattern the closest (update once and then use multiple times) _buffer_obj = gr_create_buffer(BufferType::Uniform, BufferUsageHint::Dynamic); Assertion(_buffer_obj >= 0, "Creation of buffer object failed!"); }