/* Called when window needs to be redrawn */ void redraw(void) { glClear(GL_COLOR_BUFFER_BIT); draw_dither(); glRasterPos2i(0, 0); glPixelZoom(3.f, 3.f); glDrawPixels(image_w, image_h, GL_RGBA, GL_UNSIGNED_BYTE, (GLubyte *)img); glPixelZoom(1.f, 1.f); glAccum(GL_ACCUM, -1.0); glAccum(GL_RETURN, -1.f); glRasterPos2i(0, 0); glDrawBuffer(GL_FRONT); glReadBuffer(GL_FRONT); pixel_map(1); glCopyPixels(0, 0, 3*image_w, 3*image_h, GL_COLOR); pixel_map(0); CHECK_ERROR("redraw"); }
void graphic_ui::create_the_animation_objects() { if(movements_info.size()) { for(auto& elem:movements_info) { sf::Vector2f begin_pos(elem.x_from*x_s,elem.y_from*y_s), end_pos(elem.x_to*x_s,elem.y_to*y_s); sf::Texture grid_movement_texture; grid_movement_texture.create(x_s,y_s); sf::Uint32 pixel=(0xff<<24)|//Assuming a little endian machine.. from RGBA to ABGR :| ((sf::Uint32)num_colors[elem.num].b<<16)| ((sf::Uint32)num_colors[elem.num].g<<8)| ((sf::Uint32)num_colors[elem.num].r); std::vector<sf::Uint32> pixel_map(x_s*y_s,pixel); grid_movement_texture.update((sf::Uint8*)&pixel_map.front()); sf::Sprite obj_sprite(grid_movement_texture); animation_engine::anim_texture_ptr object=animation_engine::animated_texture::create(obj_sprite); object->set_begin_position(begin_pos); object->set_end_position(end_pos); object->prepare_to_render(); object->set_animation_duration(0.07); anim_engine->register_object(object,animation_engine::animated_obj_completion_opt::ACTION_DONT_MOVE); //Add the text std::stringstream text_ss; text_ss<<elem.num; sf::Text text(text_ss.str().c_str(),font,52); text.setColor(sf::Color::Black); text.setStyle(sf::Text::Bold); animation_engine::anim_text_ptr object_text=animation_engine::animated_text::create(text); //Set the proper offset int x_offset=x_s/2-text.getCharacterSize()*text_ss.str().size()/4, y_offset=y_s/2-text.getCharacterSize()/2; begin_pos.x+=x_offset; begin_pos.y+=y_offset; end_pos.x+=x_offset; end_pos.y+=y_offset; object_text->set_begin_position(begin_pos); object_text->set_end_position(end_pos); object_text->prepare_to_render(); object_text->set_animation_duration(0.07); anim_engine->register_object(object_text,animation_engine::animated_obj_completion_opt::ACTION_DONT_MOVE); } movements_info.clear(); draw_movement=true; } else draw_movement=false; }