Esempio n. 1
0
static void ss_reconfig(ss_t *s, size_t new_alloc_size, const size_t new_mt_sz)
{
	size_t size = sd_get_size(s), unicode_size = get_unicode_size(s);
	char *s_str = get_str(s);
	/* Compute offset on target location: */
	struct SSTR_Small sm;
	struct SSTR_Full sf;
	const size_t s2_off = new_mt_sz == SS_METAINFO_SMALL?
				sm.str -(char *)&sm : sf.str - (char *)&sf;
	/* Convert string: */
	memmove((char *)s + s2_off, s_str, size);
	s->is_full = sd_alloc_size_to_is_big(new_alloc_size, &ssf);
	set_size(s, size);
	set_alloc_size(s, new_alloc_size);
	set_unicode_size(s, unicode_size);
}
Esempio n. 2
0
/*
 * clique_unweighted_max_weight()
 *
 * Returns the size of the maximum (sized) clique in g (or 0 if search
 * was aborted).
 *
 *   g    - the graph
 *   opts - time printing options
 *
 * Note: As we don't have an algorithm faster than actually finding
 *       a maximum clique, we use clique_unweighted_find_single().
 *       This incurs only very small overhead.
 */
int clique_unweighted_max_weight(graph_t *g, clique_options *opts) {
	set_t s;
	int size;

	ASSERT((sizeof(setelement)*8)==ELEMENTSIZE);
	ASSERT(g!=NULL);

	s=clique_unweighted_find_single(g,0,0,FALSE,opts);
	if (s==NULL) {
		/* Search was aborted. */
		return 0;
	}
	size=set_size(s);
	set_free(s);
	return size;
}
Esempio n. 3
0
RadioButton::RadioButton (const RefPtr<AbstractIcon>& icon)
    : AbstractButton(icon)
{
  set_round_type(RoundAll);
  set_checkable(true);

  int w = this->icon()->size().width();
  int h = this->icon()->size().height();

  w += pixel_size(kPadding.hsum());
  h += pixel_size(kPadding.vsum());

  set_size(w, h);

  InitializeRadioButtonOnce();
}
Esempio n. 4
0
/**
 * \brief Creates a carried item (i.e. an item carried by the hero).
 * \param hero the hero who is lifting the item to be created
 * \param original_entity the entity that will be replaced by this carried item
 * (its coordinates, size and origin will be copied)
 * \param animation_set_id name of the animation set for the sprite to create
 * \param destruction_sound_id Name of the sound to play when this item is destroyed
 * (or an empty string).
 * \param damage_on_enemies damage received by an enemy if the item is thrown on him
 * (possibly 0)
 * \param explosion_date date of the explosion if the item should explode,
 * or 0 if the item does not explode
 */
CarriedItem::CarriedItem(
    Hero& hero,
    const Entity& original_entity,
    const std::string& animation_set_id,
    const std::string& destruction_sound_id,
    int damage_on_enemies,
    uint32_t explosion_date
):
  Entity("", 0, hero.get_layer(), Point(0, 0), Size(0, 0)),
  hero(hero),
  is_lifting(true),
  is_throwing(false),
  is_breaking(false),
  break_one_layer_above(false),
  destruction_sound_id(destruction_sound_id),
  damage_on_enemies(damage_on_enemies),
  shadow_sprite(nullptr),
  throwing_direction(0),
  next_down_date(0),
  item_height(0),
  y_increment(0),
  explosion_date(explosion_date) {

  // align correctly the item with the hero
  int direction = hero.get_animation_direction();
  if (direction % 2 == 0) {
    set_xy(original_entity.get_x(), hero.get_y());
  }
  else {
    set_xy(hero.get_x(), original_entity.get_y());
  }
  set_origin(original_entity.get_origin());
  set_size(original_entity.get_size());
  set_drawn_in_y_order(true);

  // create the lift movement and the sprite
  std::shared_ptr<PixelMovement> movement = std::make_shared<PixelMovement>(
      lifting_trajectories[direction], 100, false, true
  );
  create_sprite(animation_set_id);
  get_sprite().set_current_animation("stopped");
  set_movement(movement);

  // create the shadow (not visible yet)
  shadow_sprite = std::make_shared<Sprite>("entities/shadow");
  shadow_sprite->set_current_animation("big");
}
Esempio n. 5
0
RadioButton::RadioButton (const String& text)
    : AbstractButton(text)
{
  set_round_type(RoundAll);
  set_checkable(true);

  int w = this->text()->size().width();
  int h = this->text()->font().height();
  if(w < 80) w = 80;

  w += pixel_size(kPadding.hsum());
  h += pixel_size(kPadding.vsum());

  set_size(w, h);

  InitializeRadioButtonOnce();
}
Esempio n. 6
0
/* graph_rem_veterx */
int graph_rem_vertex(Graph *graph, void **data) {
	ListElmt *element, *temp, *prev;
	AdjList *adjlist;
	int found;

	/* Traverse each adjacency list and the vertices it contains. */
	prev = NULL;
	found = 0;

	for (element = list_head(&graph->adjlists); element != NULL;
		 element = list_next(element)) {
		/* Do not allow removal of the vertex if it is in an adjacenty list. */
		if (set_is_member(&((AdjList *)list_data(element))->adjacent, *data))
			return -1;

		/* Keep a pointer to the vertex to be removed. */
		if (graph->match(*data, ((AdjList *)list_data(element))->vertex)) {
			temp = element;
			found = 1;
		}

		/* Keep a pointer to the vertex before the vertex to be removed. */
		if (!found)
			prev = element;
	}

	/* Return if the vertex was not found. */
	if (!found)
		return -1;

	/* Do not allow removal of the vertex if its adjacency list is not empty. */
	if (set_size(&((AdjList *)list_data(temp))->adjacent) > 0)
		return -1;

	/* Remove the vertex. */
	if (list_rem_next(&graph->adjlists, prev, (void **)&adjlist) != 0)
		return -1;

	/* Free the storage allocated by the abstract datatype. */
	*data = adjlist->vertex;
	free(adjlist);

	/* Adjust the vertex count to account for the removed vertex. */
	graph->vcount--;
	return 0;
}
Esempio n. 7
0
Asteroid::Asteroid(float x, float y, float ang, float xv, float yv, float rv, int s)
{
    xPos = x;
    yPos = y;
    Collider.x = xPos;
    Collider.y = yPos;
    Angle = ang;
    xVel = xv;
    yVel = yv;
    rotVel = rv;
    split_num = 3;
    mass_max = 90;
    powerup_chance = 10;
    set_size(s);

    TYPE = T_ASTEROID;
}
Esempio n. 8
0
TiXmlString& TiXmlString::assign(const char* str, size_type len)
{
	size_type cap = capacity();
	if (len > cap || cap > 3*(len + 8))
	{
		TiXmlString tmp;
		tmp.init(len);
		std::memcpy(tmp.start(), str, len);
		swap(tmp);
	}
	else
	{
		std::memmove(start(), str, len);
		set_size(len);
	}
	return *this;
}
Esempio n. 9
0
void setup(){
    set_brief("How to make a basic sword");
    set_long(@MAY

Inherit the appropriate file - SWORD, M_VALUABLE.
Normal setup for adj, size and value (id not needed).
Set weapon_class - approx max hps of damage from a hit.

inherit SWORD;
inherit M_VALUABLE;

void setup() {
    set_adj("dull");
    set_weapon_class(15);
    set_size(MEDIUM);
    set_value(1000);
}
Esempio n. 10
0
void setup(void) {
   set_id("crown");
   set_adj("metal");
   set_short("A metal crown");
   set_long("This crown functions as a useful helmet." +
      " It is a simple crown of metal but you know that it's ancient " +
      "and has rested upon the heads of champions throughout the " +
      "ages.");
   set_gettable(1);
   set_slot("head");
   set_wear_message("$N $vdon $o.");
   set_remove_message("$N $vtake off $o");
   set_ac(2);
   set_value(3000);
   set_size(3);
   set_weight(1);
}
Esempio n. 11
0
bool vsx_widget_note::init_from_command(vsx_command_s* c)
{
  set_render_type(render_3d);
  vsx_vector3<> np;
  np = vsx_vector3_helper::from_string<float>(c->parts[2]);
  set_pos(np);
  np = vsx_vector3_helper::from_string<float>(c->parts[3]);
  set_size(np);
  set_font_size(vsx_string_helper::s2f(c->parts[5]));
  set_border(font_size*0.15f);
  size_min.x = font_size*3.0f;
  size_min.y = font_size*4.0f;

  //new_note->target_size = new_note->size;
  load_text( vsx_string_helper::base64_decode(c->parts[4]));
  return true;
}
Esempio n. 12
0
void set_to_xml(int *l, char* res) /* prints the content of a set */
{
  int i, j, start = 1;

  for(i = 0; i < set_size(4); i++) {
    for(j = 0; j < mod; j++){
      if(l[i] & (1 << j)) {
        if(!start) strcat(res, ",");
        char tmp[8];
        sprintf(tmp, "z[%i]=0", mod * i + j);
        strcat(res,tmp);

        start = 0;
      }
    }
  }
}
Esempio n. 13
0
/**
 * \brief Creates an enemy.
 * \param game The game.
 * \param name Id of the enemy.
 * \param layer The layer on the map.
 * \param x X position on the map.
 * \param y Y position on the map.
 * \param breed Breed of the enemy.
 * \param treasure Treasure dropped when the enemy is killed.
 */
Enemy::Enemy(
    Game& game,
    const std::string& name,
    Layer layer,
    int x,
    int y,
    const std::string& breed,
    const Treasure& treasure):

  Detector(COLLISION_RECTANGLE | COLLISION_SPRITE,
      name, layer, x, y, 0, 0),

  breed(breed),
  damage_on_hero(1),
  magic_damage_on_hero(0),
  life(1),
  hurt_style(HURT_NORMAL),
  pushed_back_when_hurt(true),
  push_hero_on_sword(false),
  can_hurt_hero_running(false),
  minimum_shield_needed(0),
  rank(RANK_NORMAL),
  savegame_variable(),
  traversable(true),
  obstacle_behavior(OBSTACLE_BEHAVIOR_NORMAL),
  drawn_in_y_order(true),
  initialized(false),
  being_hurt(false),
  stop_hurt_date(0),
  invulnerable(false),
  vulnerable_again_date(0),
  can_attack(true),
  can_attack_again_date(0),
  immobilized(false),
  start_shaking_date(0),
  end_shaking_date(0),
  dying_animation_started(false),
  treasure(treasure),
  exploding(false),
  nb_explosions(0),
  next_explosion_date(0) {

  set_size(16, 16);
  set_origin(8, 13);
}
Esempio n. 14
0
/**
 * @brief Creates a carried item (i.e. an item carried by the hero).
 * @param hero the hero who is lifting the item to be created
 * @param original_entity the entity that will be replaced by this carried item
 * (its coordinates, size and origin will be copied)
 * @param animation_set_id name of the animation set for the sprite to create
 * @param destruction_sound_id name of the sound to play when this item is destroyed
 * (or an empty string)
 * @param damage_on_enemies damage received by an enemy if the item is thrown on him
 * (possibly 0)
 * @param explosion_date date of the explosion if the item should explode,
 * or 0 if the item does not explode
 */
CarriedItem::CarriedItem(Hero& hero, MapEntity& original_entity,
    const std::string& animation_set_id,
    const std::string& destruction_sound_id,
    int damage_on_enemies, uint32_t explosion_date):

  MapEntity(),
  hero(hero),
  is_lifting(true),
  is_throwing(false),
  is_breaking(false),
  break_on_intermediate_layer(false) {

  // put the item on the hero's layer
  set_layer(hero.get_layer());

  // align correctly the item with the hero
  int direction = hero.get_animation_direction();
  if (direction % 2 == 0) {
    set_xy(original_entity.get_x(), hero.get_y());
  }
  else {
    set_xy(hero.get_x(), original_entity.get_y());
  }
  set_origin(original_entity.get_origin());
  set_size(original_entity.get_size());

  // create the lift movement and the sprite
  PixelMovement *movement = new PixelMovement(lifting_trajectories[direction], 100, false, true);
  create_sprite(animation_set_id);
  get_sprite().set_current_animation("stopped");
  set_movement(movement);

  // create the breaking sound
  this->destruction_sound_id = destruction_sound_id;

  // create the shadow (not visible yet)
  this->shadow_sprite = new Sprite("entities/shadow");
  this->shadow_sprite->set_current_animation("big");

  // damage on enemies
  this->damage_on_enemies = damage_on_enemies;

  // explosion
  this->explosion_date = explosion_date;
}
Esempio n. 15
0
/*ARGSUSED*/
    static void
Initialize(Widget rq, Widget ebw, ArgList args, Cardinal *n)
{
    XmEnhancedButtonWidget  request = (XmEnhancedButtonWidget)rq;
    XmEnhancedButtonWidget  eb = (XmEnhancedButtonWidget)ebw;
    XtWidgetProc	    resize;

    XtProcessLock();
    resize = xmLabelClassRec.core_class.resize;
    XtProcessUnlock();

    /* Create a bitmap for stippling (Drawable resources are cheap).  */
    if (STIPPLE_BITMAP == None)
    {
	Display *dpy = XtDisplay((Widget) request);
	Window	rootW = DefaultRootWindow(dpy);

	STIPPLE_BITMAP = XCreateBitmapFromData(dpy, rootW, stipple_bits,
		stipple_width, stipple_height);
    }
    eb->enhancedbutton.doing_setvalues = False;

    /* First see what type of extended label this is.
     */
    if (eb->enhancedbutton.pixmap_data)
    {
	XmString str;
	set_pixmap(eb);

	/* FIXME: this is not the perfect way to deal with menues, which do not
	 * have any string set right now.  */
	str = XmStringCreateLocalized("");
	XtVaSetValues((Widget) eb, XmNlabelString, str, NULL);
	XmStringFree(str);
    }
    eb->label.pixmap = eb->enhancedbutton.normal_pixmap;

    if (request->core.width == 0)
	eb->core.width = 0;
    if (request->core.height == 0)
	eb->core.height = 0;
    set_size(eb);

    (* resize)((Widget)eb);
}
Esempio n. 16
0
Unison::Unison(int update_period_samples_, REALTYPE max_delay_sec_) {
    update_period_samples = update_period_samples_;
    max_delay    = (int)(max_delay_sec_ * (REALTYPE)SAMPLE_RATE + 1);
    if(max_delay < 10)
        max_delay = 10;
    delay_buffer = new REALTYPE[max_delay];
    delay_k      = 0;
    base_freq    = 1.0;
    unison_bandwidth_cents = 10.0;

    ZERO_REALTYPE(delay_buffer, max_delay);

    uv = NULL;
    update_period_sample_k = 0;
    first_time = 0;

    set_size(1);
}
Esempio n. 17
0
static boolean callback_callback(set_t s, graph_t *g, clique_options *opt) {
    igraph_vector_t *clique;
    struct callback_data *cd;
    int i, j;

    CLIQUER_ALLOW_INTERRUPTION();

    cd = (struct callback_data *) opt->user_data;

    clique = (igraph_vector_t *) malloc(sizeof(igraph_vector_t));
    igraph_vector_init(clique, set_size(s));

    i = -1; j = 0;
    while ((i = set_return_next(s,i)) >= 0)
        VECTOR(*clique)[j++] = i;

    return (*(cd->handler))(clique, cd->arg);
}
Esempio n. 18
0
	FileButton::FileButton ()
	: AbstractButton(String("...")),
	  dialog_(0)
	{
		set_round_type(RoundAll);

		int h = this->text()->font().height();
		int w = h;

		w += pixel_size(kPadding.hsum());
		h += pixel_size(kPadding.vsum());

		set_size(w, h);

		InitializeFileButtonOnce();

		clicked().connect(this, &FileButton::OnClicked);
	}
vsx_widget_controller_pad::vsx_widget_controller_pad()
{
    widget_type = 0;
    a.x = 0;
    a.y = 0;

    b.x = 1;
    b.y = 1;

    widget_type = VSX_WIDGET_TYPE_CONTROLLER;
    coord_type = VSX_WIDGET_COORD_CENTER;
    set_size(vsx_vector3<>(0.1,0.1));
    set_pos(vsx_vector3<>(-0.06));

    generate_menu();
    menu->init();
    drawing = false;
}
Esempio n. 20
0
void dfree(void* ptr, int flag) {

	/* Your free and coalescing code goes here */
	//bool left_f = is_free(left_block(ptr));
	bool right_f = is_free(to_meta(right_block(ptr)));
	bool left_f = is_free((metadata_t *)(ptr - META_SIZE - FOOTER_SIZE));
	
	if (!left_f && !right_f) {
	    set_free(to_meta(ptr));
	    set_free((metadata_t *)to_footer(ptr));
	    add_node(to_meta(ptr));
	}
	else if (left_f && !right_f) {
		//process the linked list
		//change the size of two blocks
		delete_node(to_meta(left_block(ptr)));
		int left_size = block_size(left_block(ptr));
		int new_size = left_size + FOOTER_SIZE + META_SIZE + block_size(ptr);
		set_size(to_meta(left_block(ptr)), new_size);
		set_size((metadata_t *)to_footer(ptr), new_size);
		set_free(to_meta(left_block(ptr)));
		set_free((metadata_t *)to_footer(ptr));
		add_node(to_meta(left_block(ptr)));
	}
	else if (!left_f && right_f) {
		//process the linked list
		delete_node(to_meta(right_block(ptr)));
		//change the size of two blocks
		int right_size = block_size(right_block(ptr));
		int new_size = right_size + block_size(ptr) + FOOTER_SIZE + META_SIZE;
		set_size((metadata_t *)to_footer(right_block(ptr)), new_size);
		set_free((metadata_t *)to_footer(right_block(ptr)));
		set_size(to_meta(ptr), new_size);
		set_free(to_meta(ptr));
		//process the linked list
		add_node(to_meta(ptr));
	}
	else if (left_f && right_f) {
		//process the linked list
		delete_node(to_meta(right_block(ptr)));
		delete_node(to_meta(left_block(ptr)));
		//change the size of two blocks
		int right_size = block_size(right_block(ptr));
		int left_size = block_size(left_block(ptr));
		int new_size = block_size(ptr) + left_size + right_size + 2 * (FOOTER_SIZE + META_SIZE);
		set_size((metadata_t *)to_footer(right_block(ptr)), new_size);
		set_free((metadata_t *)to_footer(right_block(ptr)));
		set_size(to_meta(left_block(ptr)), new_size);
		set_free(to_meta(left_block(ptr)));	
		add_node(to_meta(left_block(ptr)));
	}
}
Esempio n. 21
0
void setup() {
  add_relation("in");
  set_default_relation("in");
  set_gettable("It is securely anchored.\n");
  set_id("mailbox", "box");
  set_adj("small");
  set_in_room_desc("There is a small mailbox here.");
  set_max_capacity(SMALL);
#ifdef USE_SIZE
  set_size(MEDIUM);
#endif
#ifdef USE_MASS
  set_mass(MEDIUM);
#endif
  set_objects( ([
		 "leaflet" : 1
  ]) );
}
Esempio n. 22
0
CL_Texture::CL_Texture(
	int target_gl,
	int width,
	int height,
	int depth,
	int border,
	int format,
	int level)
: impl(new CL_Texture_Generic(target_gl))
{
	set_size(
		format,
		width,
		height,
		depth,
		border,
		level);
}
Esempio n. 23
0
static int coalesce(void* block, size_t* size){
    REQUIRES(block != NULL);
    REQUIRES(in_heap(block));

    //uint64_t* left_block;
    void* right_block;
    size_t new_size;
    int index;

    void* next;
    void* prev;

    *size = block_size(block);
    new_size = (*size) * 2;
    index = get_free_list_index(*size);

    if(new_size > MAX_SIZE) return index;

    right_block = ((uint64_t*)block)+(block_size(block)/sizeof(uint64_t*));

    // if(in_heap(left_block) && block_free(left_block)){
    //     if(block_size(left_block) == size){
    //         set_size(left_block, size*2);
    //         add_block_to_list(get_free_list_index(size*2), left_block);
    //     }
    // }
    
    if(in_heap(right_block) && block_free((uint32_t*)right_block)){
        if(block_size(right_block) == new_size/2){

            next = block_next(right_block);
            prev = block_prev(right_block);

            if(free_lists[index] == right_block) free_lists[index] = next;
            if(prev != NULL) set_next_pointer(prev, next);
            if(next != NULL) set_prev_pointer(next, prev);

            set_size(block, new_size);
            *size = new_size;
            index++;
        }
    }
    return index;
}
Esempio n. 24
0
/**
 * \brief Creates an NPC.
 * \param game the game
 * \param name name identifying this NPC
 * \param layer layer of the entity to create
 * \param xy Coordinates of the entity to create.
 * \param subtype the subtype of interaction
 * \param sprite_name sprite animation set of the entity, or an empty string to create no sprite
 * \param direction for a generalized NPC: direction for which the interactions are allowed
 * (0 to 4, or -1 for any direction), for a usual NPC: initial direction of the NPC's sprite
 * \param behavior_string indicates what happens when the hero interacts with this NPC:
 * "dialog#XXX" to start the dialog XXX, "map" to call the map script
 * (with an event_hero_interaction() call) or "item#XXX" to call the script
 * of item XXX  (with an event_hero_interaction() call)
 */
Npc::Npc(
    Game& /* game */,
    const std::string& name,
    int layer,
    const Point& xy,
    Subtype subtype,
    const std::string& sprite_name,
    int direction,
    const std::string& behavior_string
):
  Entity(name, 0, layer, xy, Size(0, 0)),
  subtype(subtype),
  behavior(BEHAVIOR_MAP_SCRIPT),
  traversable(false),
  dialog_to_show(""),
  item_name("") {

  set_collision_modes(CollisionMode::COLLISION_FACING | CollisionMode::COLLISION_OVERLAPPING);
  initialize_sprite(sprite_name, direction);
  set_size(16, 16);
  set_origin(8, 13);
  set_direction(direction);

  // Usual NPCs are displayed like the hero whereas generalized NPCs are
  // not necessarily people.
  set_drawn_in_y_order(subtype == USUAL_NPC);

  // behavior
  if (behavior_string == "map") {
    behavior = BEHAVIOR_MAP_SCRIPT;
  }
  else if (behavior_string.substr(0, 5) == "item#") {
    behavior = BEHAVIOR_ITEM_SCRIPT;
    item_name = behavior_string.substr(5);
  }
  else if (behavior_string.substr(0, 7) == "dialog#") {
    behavior = BEHAVIOR_DIALOG;
    dialog_to_show = behavior_string.substr(7);
  }
  else {
    Debug::die(std::string("Invalid behavior string for NPC '") + name
        + "': '" + behavior_string + "'");
  }
}
Esempio n. 25
0
void TimeRuler::PerformSizeUpdate(const AbstractView* source, const AbstractView* target, int width, int height)
{
  if(target == this) {

    float radius = std::min(width, height) / 2.f;

    set_size(width, height);
    set_round_radius(radius);

    std::vector<GLfloat> inner_verts;
    std::vector<GLfloat> outer_verts;

    if(AbstractWindow::theme()->scroll().shaded) {

      short shadetop = AbstractWindow::theme()->scroll().shadetop;
      short shadedown = AbstractWindow::theme()->scroll().shadedown;

      GenerateRoundedVertices(
          Vertical,
          shadetop,
          shadedown,
          &inner_verts,
          &outer_verts);
    } else {
      GenerateRoundedVertices(
          &inner_verts,
          &outer_verts);
    }

    buffer_.bind(0);
    buffer_.set_sub_data(0, sizeof(GLfloat) * inner_verts.size(), &inner_verts[0]);

    buffer_.bind(1);
    buffer_.set_sub_data(0, sizeof(GLfloat) * outer_verts.size(), &outer_verts[0]);

    buffer_.reset();

    RequestRedraw();
  }

  if(source == this) {
    report_size_update(source, target, width, height);
  }
}
Esempio n. 26
0
void vsx_widget_profiler_thread::init()
{
  support_interpolation = true;
  allow_resize_x = true;
  allow_resize_y = true;
  set_size(vsx_vector3<>(20.0f,0.3f));
  set_pos(vsx_vector3<>(0,0));
  size_min.x = 0.2;
  size_min.y = 0.2;

  profiler = vsx_profiler_manager::get_instance()->get_profiler();

  title = "thread";

  allow_move_x = false;

  this->interpolate_size();
  init_run = true;
}
Esempio n. 27
0
void setup(void) {
   add_ids("tower shield");
   set_adj("large");
   set_short("A large tower shield");
   set_long("A large tower shield It has an intricate holy symbol " +
		"elaborately created on the front of the tower shield. It is " +
		"heavy and sturdy.");
   set_gettable(1);

   set_ac(4);

   set_wield_type("single");
   set_wield_message("$N $vtake up $p $o.");
   set_unwield_message("$N $vremove $p $o.");
   set_value(1000);
   set_size(35);
   set_weight(3);
	add_bane("holy");
}
Esempio n. 28
0
/*
** Init a pre allocated or static hash structure
** and allocate buckets. NOT SAFE
*/
SafeHash* safe_hash_init(ErtsAlcType_t type, SafeHash* h, char* name, int size, SafeHashFunctions fun)
{
    int i, bytes;

    size = align_up_pow2(size);
    bytes = size * sizeof(SafeHashBucket*);
    h->type = type;
    h->tab = (SafeHashBucket**) erts_alloc(h->type, bytes);
    sys_memzero(h->tab, bytes);
    h->name = name;
    h->fun = fun;
    set_size(h,size);
    erts_smp_atomic_init(&h->is_rehashing, 0);
    erts_smp_atomic_init(&h->nitems, 0);
    for (i=0; i<SAFE_HASH_LOCK_CNT; i++) {
	erts_smp_mtx_init(&h->lock_vec[i].mtx,"safe_hash");
    }
    return h;
}
void FrameBufferObject::
attach_depth_stencil_buffer(RenderContext const& ctx, Texture const& buffer,
                            int mip_level, int z_slice) {

    std::unique_lock<std::mutex> lock(upload_mutex_);

    // only attach buffer if it has an appropriate size
    if (set_size(buffer)) {

        // create new fbo if there isn't any for this context
        if (fbos_.size() <= ctx.id || fbos_[ctx.id] == NULL) {
            fbos_.resize(ctx.id+1);
            fbos_[ctx.id] = ctx.render_device->create_frame_buffer();
        }

        fbos_[ctx.id]->attach_depth_stencil_buffer(
                                    buffer.get_buffer(ctx), mip_level, z_slice);
    }
}
Esempio n. 30
0
DotIcon::DotIcon ()
    : AbstractIcon()
{
  int radius = pixel_size(3);

  set_size(radius * 2, radius * 2);

  std::vector<GLfloat> inner_verts;
  std::vector<GLfloat> outer_verts;

  GenerateVertices(-radius, -radius, radius, radius, pixel_size(1), RoundAll,
                   radius, &inner_verts, &outer_verts);

  glGenVertexArrays(2, vao_);
  glBindVertexArray(vao_[0]);

  vbo_.generate();
  vbo_.bind(0);
  vbo_.set_data(sizeof(GLfloat) * inner_verts.size(), &inner_verts[0]);
  glEnableVertexAttribArray(
      AbstractWindow::shaders()->location(
          Shaders::WIDGET_SIMPLE_TRIANGLE_COORD));
  glVertexAttribPointer(
      AbstractWindow::shaders()->location(
          Shaders::WIDGET_SIMPLE_TRIANGLE_COORD),
      3,
      GL_FLOAT,
      GL_FALSE, 0, 0);

  glBindVertexArray(vao_[1]);

  vbo_.bind(1);
  vbo_.set_data(sizeof(GLfloat) * outer_verts.size(), &outer_verts[0]);
  glEnableVertexAttribArray(AttributeCoord);
  glVertexAttribPointer(AttributeCoord, 2,
  GL_FLOAT,
                        GL_FALSE, 0, 0);

  glBindVertexArray(0);

  vbo_.reset();

}