コード例 #1
0
ファイル: main.cpp プロジェクト: FreeCX/one-day-game
void game_destroy( void )
{
    font_destroy( ft );
    SDL_DestroyTexture( tiles );
    SDL_DestroyRenderer( render );
    SDL_DestroyWindow( window );
    SDL_Quit();
}
コード例 #2
0
ファイル: main.cpp プロジェクト: FreeCX/one-day-game
void game_destroy( void )
{
    font_destroy( ft );
    SDL_DestroyTexture( unit );
    SDL_DestroyTexture( background );
    SDL_DestroyTexture( t_bullet );
    SDL_DestroyTexture( t_ammo );
    SDL_DestroyTexture( t_blood );
    SDL_DestroyRenderer( render );
    SDL_DestroyWindow( window );
    SDL_Quit();
}
コード例 #3
0
ファイル: game.c プロジェクト: shiver/vectir
// deal with all the things that need to be shut down
void game_shutdown() {
  debug_print("Freeing texture resources.");
	graphics_destroyTexture(block_texture);
  graphics_destroyTexture(grid_texture);
	debug_print("Game shutting down...");

  font_destroy();
	graphics_shutdown();

	tetromino_destroy(current_tetromino);
	grid_destroy(grid);

	exit(1);
}
コード例 #4
0
ファイル: api_text.c プロジェクト: GunioRobot/mesa-7.10.2-PS3
void vegaDestroyFont(VGFont f)
{
   struct vg_font *font = (struct vg_font *)f;
   struct vg_context *ctx = vg_current_context();

   if (f == VG_INVALID_HANDLE) {
      vg_set_error(ctx, VG_BAD_HANDLE_ERROR);
      return;
   }
   if (!vg_object_is_valid((void *) font, VG_OBJECT_FONT)) {
      vg_set_error(ctx, VG_BAD_HANDLE_ERROR);
      return;
   }

   font_destroy(font);
}
コード例 #5
0
ファイル: intro.c プロジェクト: myeongjinkim/sample
/* creates the background */
image_t* create_background()
{
    image_t* img = image_create(VIDEO_SCREEN_W, VIDEO_SCREEN_H);
    font_t *fnt = font_create("disclaimer");
    v2d_t camera = v2d_new(VIDEO_SCREEN_W/2, VIDEO_SCREEN_H/2);

    image_clear(video_get_backbuffer(), image_rgb(0,0,0));
    font_set_width(fnt, VIDEO_SCREEN_W - 6);
    font_set_text(fnt, "%s", text);
    font_set_position(fnt, v2d_new(3,3));
    font_render(fnt, camera);
    image_blit(video_get_backbuffer(), img, 0, 0, 0, 0, image_width(img), image_height(img));

    font_destroy(fnt);
    return img;
}
コード例 #6
0
ファイル: textout.c プロジェクト: myeongjinkim/sample
void release(objectmachine_t *obj)
{
    objectdecorator_t *dec = (objectdecorator_t*)obj;
    objectmachine_t *decorated_machine = dec->decorated_machine;
    objectdecorator_textout_t *me = (objectdecorator_textout_t*)obj;

    expression_destroy(me->xpos);
    expression_destroy(me->ypos);
    expression_destroy(me->max_width);
    expression_destroy(me->index_of_first_char);
    expression_destroy(me->length);
    font_destroy(me->fnt);
    free(me->text);

    decorated_machine->release(decorated_machine);
    free(obj);
}
コード例 #7
0
ファイル: font_data.cpp プロジェクト: republic-of-almost/core
bool
font_create(Font_data *data, const size_t size_hint)
{
  assert(data);
  assert(size_hint);

  // Size up the capacity
  {
    size_t *capacity = const_cast<size_t*>(&data->capacity);
    *capacity = size_hint;
  }

  // Allocate memory
  bool all_alloc = true;
  {
    // Alloc keys
    if(all_alloc)
    {
      data->keys = new uint32_t[size_hint];
      assert(data->keys);
      if(!data->keys) { all_alloc = false; }
      else { memset(data->keys, 0, sizeof(uint32_t) * size_hint); }
    }

    // Alloc space for name
    if(all_alloc)
    {
      data->field_name = new char[size_hint * 32];
      assert(data->field_name);
      if(!data->field_name) { all_alloc = false; }
      else { memset(data->field_name, 0, sizeof(char) * size_hint * 32); }
    }

    // Alloc space for font_face
    if(all_alloc)
    {
      data->field_font_face = new stbtt_fontinfo[size_hint * 1];
      assert(data->field_font_face);
      if(!data->field_font_face) { all_alloc = false; }
      else { memset(data->field_font_face, 0, sizeof(stbtt_fontinfo) * size_hint * 1); }
    }

    // Alloc space for font_bitmap
    if(all_alloc)
    {
      data->field_font_bitmap = new Text::Font_bitmap[size_hint * 1];
      assert(data->field_font_bitmap);
      if(!data->field_font_bitmap) { all_alloc = false; }
      else { memset(data->field_font_bitmap, 0, sizeof(Text::Font_bitmap) * size_hint * 1); }
    }

    // Alloc space for glyph_texture_id
    if(all_alloc)
    {
      data->field_glyph_texture_id = new uint32_t[size_hint * 1];
      assert(data->field_glyph_texture_id);
      if(!data->field_glyph_texture_id) { all_alloc = false; }
      else { memset(data->field_glyph_texture_id, 0, sizeof(uint32_t) * size_hint * 1); }
    }

    // Alloc space for metric_texture_id
    if(all_alloc)
    {
      data->field_metric_texture_id = new uint32_t[size_hint * 1];
      assert(data->field_metric_texture_id);
      if(!data->field_metric_texture_id) { all_alloc = false; }
      else { memset(data->field_metric_texture_id, 0, sizeof(uint32_t) * size_hint * 1); }
    }
  }

  // Failed so clean up.
  if(!all_alloc)
  {
    font_destroy(data);
  }

  return all_alloc;
}
コード例 #8
0
ファイル: font_data.cpp プロジェクト: republic-of-almost/core
bool
font_resize_capacity(Font_data *data, const size_t size_hint)
{
  assert(data);
  assert(size_hint > data->size); // Will slice data

  // Create new data.
  Font_data new_data;
  const bool created_new = font_create(&new_data, size_hint);

  // Failed to resize.
  if(!created_new)
  {
    font_destroy(&new_data);
    return false;
  }

  // Copy over data
  {
    memcpy(new_data.keys, data->keys, sizeof(uint32_t) * data->size);
    memcpy(new_data.field_name, data->field_name, sizeof(char) * data->size * 32);
    memcpy(new_data.field_font_face, data->field_font_face, sizeof(stbtt_fontinfo) * data->size * 1);
    memcpy(new_data.field_font_bitmap, data->field_font_bitmap, sizeof(Text::Font_bitmap) * data->size * 1);
    memcpy(new_data.field_glyph_texture_id, data->field_glyph_texture_id, sizeof(uint32_t) * data->size * 1);
    memcpy(new_data.field_metric_texture_id, data->field_metric_texture_id, sizeof(uint32_t) * data->size * 1);
  }

  // Swap ptrs
  {
    uint32_t *old_keys = data->keys;
    data->keys = new_data.keys;
    new_data.keys = old_keys;

    char *old_name = data->field_name;
    data->field_name = new_data.field_name;
    new_data.field_name = old_name;

    stbtt_fontinfo *old_font_face = data->field_font_face;
    data->field_font_face = new_data.field_font_face;
    new_data.field_font_face = old_font_face;

    Text::Font_bitmap *old_font_bitmap = data->field_font_bitmap;
    data->field_font_bitmap = new_data.field_font_bitmap;
    new_data.field_font_bitmap = old_font_bitmap;

    uint32_t *old_glyph_texture_id = data->field_glyph_texture_id;
    data->field_glyph_texture_id = new_data.field_glyph_texture_id;
    new_data.field_glyph_texture_id = old_glyph_texture_id;

    uint32_t *old_metric_texture_id = data->field_metric_texture_id;
    data->field_metric_texture_id = new_data.field_metric_texture_id;
    new_data.field_metric_texture_id = old_metric_texture_id;
  }

  // Set the Capacity
  {
    size_t *capacity = const_cast<size_t*>(&data->capacity);
    *capacity = new_data.capacity;
  }

  // Destroy new data
  font_destroy(&new_data);

  return true;
}