/** * \brief Inserts in this state the content of another compatible state. * \param state The other state. */ void bear::visual::gl_state::merge( const gl_state& state ) { CLAW_PRECOND( is_compatible_with( state ) ); const std::size_t index( get_vertex_count() ); for ( element_range_list::const_iterator it( state.m_elements.begin() ); it != state.m_elements.end(); ++it ) { element_range& back( m_elements.back() ); if ( it->texture_id == back.texture_id ) back.count += it->count; else m_elements.push_back ( element_range ( it->texture_id, it->vertex_index + index, it->count ) ); } m_vertices.insert ( m_vertices.end(), state.m_vertices.begin(), state.m_vertices.end() ); m_colors.insert ( m_colors.end(), state.m_colors.begin(), state.m_colors.end() ); m_texture_coordinates.insert ( m_texture_coordinates.end(), state.m_texture_coordinates.begin(), state.m_texture_coordinates.end() ); } // gl_state::merge()
void inventory_panel::update() { m_inventory.start = inventory_start(*m_canvas); m_inventory.range = inventory_range(*m_canvas); m_list.start = items_start(m_inventory.start); m_list.range = items_range(m_inventory.range); m_count = m_list.range.Y / element_range(m_list.range).Y; m_scroll = std::max(std::min(m_scroll, (int)m_target->item_count() - m_count), 0); }
/** * \brief Constructs a state to render a given texture in a given mode. * \param texture_id The identifier of the texture to use when drawing. * \param shader The shader to use when drawing. * \param vertices The vertices to draw. * \param texture_coordinates The coordinates of the vertices in the texture. * \param c The color of the vertices. */ bear::visual::gl_state::gl_state ( GLuint texture_id, const shader_program& shader, const position_vector& texture_coordinates, const position_vector& vertices, const color_type& c ) : m_mode( render_triangles ), m_shader( shader ), m_line_width( 0 ) { const position_vector v( polygon_to_triangles( vertices ) ); push_vertices( v ); push_texture_coordinates( polygon_to_triangles(texture_coordinates) ); push_colors( c, v.size() ); m_elements.push_back( element_range( texture_id, 0, get_vertex_count() ) ); } // gl_state::gl_state()