Beispiel #1
0
/* Allocate an image structure and start a file loading in the background.
 */
static image *
alloc_image (ModeInfo *mi)
{
  slideshow_state *ss = &sss[MI_SCREEN(mi)];
  int wire = MI_IS_WIREFRAME(mi);
  image *img = (image *) calloc (1, sizeof (*img));

  img->id = ++ss->image_id;
  img->loaded_p = False;
  img->used_p = False;
  img->mi = mi;

  glGenTextures (1, &img->texid);
  if (img->texid <= 0) abort();

  ss->image_load_time = ss->now;

  if (wire)
    image_loaded_cb (0, 0, 0, 0, 0, 0, img);
  else
    load_texture_async (mi->xgwa.screen, mi->window, *ss->glx_context,
                        0, 0, mipmap_p, img->texid, image_loaded_cb, img);

  ss->images[ss->nimages++] = img;
  if (ss->nimages >= countof(ss->images)) abort();

  return img;
}
Beispiel #2
0
/* Load a new file.
 */
static void
load_image (ModeInfo *mi)
{
  photopile_state *ss = &sss[MI_SCREEN(mi)];
  int wire = MI_IS_WIREFRAME(mi);
  image *frame = ss->frames + ss->nframe;

  if (debug_p && !wire && frame->w != 0)
    fprintf (stderr, "%s:  dropped %4d x %-4d  %4d x %-4d  \"%s\"\n",
             progname, 
             frame->geom.width, 
             frame->geom.height, 
             frame->tw, frame->th,
             (frame->title ? frame->title : "(null)"));

  frame->loaded_p = False;

  if (wire)
    image_loaded_cb (0, 0, 0, 0, 0, 0, ss);
  else
    {
      int w = MI_WIDTH(mi);
      int h = MI_HEIGHT(mi);
      int size = (int)((w > h ? w : h) * scale);
      if (size <= 10) size = 10;
      load_texture_async (mi->xgwa.screen, mi->window, *ss->glx_context,
                          size, size,
                          mipmap_p, frame->texid, 
                          image_loaded_cb, ss);
    }
}
/* Load a new file into the given image struct.
 */
static void
load_image (ModeInfo *mi, image_frame *frame)
{
  carousel_state *ss = &sss[MI_SCREEN(mi)];
  int wire = MI_IS_WIREFRAME(mi);

  if (debug_p && !wire && frame->current.w != 0)
    fprintf (stderr, "%s:  dropped %4d x %-4d  %4d x %-4d  \"%s\"\n",
             progname, 
             frame->current.geom.width, 
             frame->current.geom.height, 
             frame->current.tw, frame->current.th,
             (frame->current.title ? frame->current.title : "(null)"));

  switch (frame->mode) 
    {
    case EARLY:  break;
    case NORMAL: frame->mode = LOADING; break;
    default: abort();
    }

  ss->loads_in_progress++;

  if (wire)
    image_loaded_cb (0, 0, 0, 0, 0, 0, frame);
  else
    {
      int w = (MI_WIDTH(mi)  / 2) - 1;
      int h = (MI_HEIGHT(mi) / 2) - 1;
      if (w <= 10) w = 10;
      if (h <= 10) h = 10;
      load_texture_async (mi->xgwa.screen, mi->window, *ss->glx_context, w, h,
                          mipmap_p, frame->loading.texid, 
                          image_loaded_cb, frame);
    }
}