Beispiel #1
0
Player::Player()
    : m_data(ProjectManager::singleton().meta().player), m_moved(true)
{
    apply_image(m_data.image.id, m_data.image.at_x, m_data.image.at_y);
    move(m_data.x, m_data.y, false);
}
Beispiel #2
0
int
compare(Gif_Stream *s1, Gif_Stream *s2)
{
  Gif_Colormap *newcm;
  int imageno1, imageno2, background1, background2;
  char buf1[256], buf2[256], fbuf[256];

  was_different = 0;

  /* Compare image counts and screen sizes. If either of these differs, quit
     early. */
  Gif_CalculateScreenSize(s1, 0);
  Gif_CalculateScreenSize(s2, 0);

  if (s1->nimages != s2->nimages
      && (s1->nimages == 0 || s2->nimages == 0)) {
    different("frame counts differ: <#%d >#%d", s1->nimages, s2->nimages);
    return DIFFERENT;
  }

  if (s1->screen_width != s2->screen_width
      || s1->screen_height != s2->screen_height) {
    different("screen sizes differ: <%dx%d >%dx%d", s1->screen_width,
	      s1->screen_height, s2->screen_width, s2->screen_height);
    return DIFFERENT;
  }

  if (s1->screen_width == 0 || s1->screen_height == 0
      || s2->screen_width == 0 || s2->screen_height == 0) {
    /* paranoia -- don't think this can happen */
    different("zero screen sizes");
    return DIFFERENT;
  }

  /* Create arrays for the image data */
  screen_width = s1->screen_width;
  screen_height = s1->screen_height;

  gdata[0] = Gif_NewArray(uint16_t, screen_width * screen_height);
  gdata[1] = Gif_NewArray(uint16_t, screen_width * screen_height);
  glast[0] = Gif_NewArray(uint16_t, screen_width * screen_height);
  glast[1] = Gif_NewArray(uint16_t, screen_width * screen_height);
  scratch = Gif_NewArray(uint16_t, screen_width * screen_height);
  line = Gif_NewArray(uint16_t, screen_width);

  /* Merge all distinct colors from the two images into one colormap, setting
     the 'pixel' slots in the images' colormaps to the corresponding values
     in the merged colormap. Don't forget transparency */
  newcm = Gif_NewFullColormap(1, 256);
  combine_colormaps(s1->global, newcm);
  combine_colormaps(s2->global, newcm);
  for (imageno1 = 0; imageno1 < s1->nimages; ++imageno1)
    combine_colormaps(s1->images[imageno1]->local, newcm);
  for (imageno2 = 0; imageno2 < s2->nimages; ++imageno2)
    combine_colormaps(s2->images[imageno2]->local, newcm);

  /* Choose the background values and clear the image data arrays */
  if (s1->images[0]->transparent >= 0 || !s1->global)
    background1 = TRANSP;
  else
    background1 = s1->global->col[ s1->background ].pixel;

  if (s2->images[0]->transparent >= 0 || !s2->global)
    background2 = TRANSP;
  else
    background2 = s2->global->col[ s2->background ].pixel;

  fill_area(gdata[0], 0, 0, screen_width, screen_height, background1);
  fill_area(gdata[1], 0, 0, screen_width, screen_height, background2);

  /* Loopcounts differ? */
  if (s1->loopcount != s2->loopcount) {
    name_loopcount(s1->loopcount, buf1);
    name_loopcount(s2->loopcount, buf2);
    different("loop counts differ: <%s >%s", buf1, buf2);
  }

  /* Loop over frames, comparing image data and delays */
  apply_image(0, s1, 0, background1);
  apply_image(1, s2, 0, background2);
  imageno1 = imageno2 = 0;
  while (imageno1 != s1->nimages && imageno2 != s2->nimages) {
    int fi1 = imageno1, fi2 = imageno2,
      delay1 = s1->images[fi1]->delay, delay2 = s2->images[fi2]->delay;

    /* get message right */
    if (imageno1 == imageno2)
      sprintf(fbuf, "#%d", imageno1);
    else
      sprintf(fbuf, "<#%d >#%d", imageno1, imageno2);

    /* compare pixels */
    if (memcmp(gdata[0], gdata[1],
	       screen_width * screen_height * sizeof(uint16_t)) != 0) {
      unsigned d, c = screen_width * screen_height;
      uint16_t *d1 = gdata[0], *d2 = gdata[1];
      for (d = 0; d < c; d++, d1++, d2++)
	if (*d1 != *d2) {
	  name_color(*d1, newcm, buf1);
	  name_color(*d2, newcm, buf2);
	  different("frame %s pixels differ: %d,%d <%s >%s",
		    fbuf, d % screen_width, d / screen_width, buf1, buf2);
	  break;
	}
    }

    /* move to next images, skipping redundancy */
    for (++imageno1;
	 imageno1 < s1->nimages && !apply_image(0, s1, imageno1, background1);
	 ++imageno1)
      delay1 += s1->images[imageno1]->delay;
    for (++imageno2;
	 imageno2 < s2->nimages && !apply_image(1, s2, imageno2, background2);
	 ++imageno2)
      delay2 += s2->images[imageno2]->delay;

    if (!ignore_redundancy) {
      fi1 = (imageno1 - fi1) - (imageno2 - fi2);
      for (; fi1 > 0; --fi1)
	different("extra redundant frame: <#%d", imageno1 - fi1);
      for (; fi1 < 0; ++fi1)
	different("extra redundant frame: >#%d", imageno2 + fi1);
    }

    if (delay1 != delay2) {
      name_delay(delay1, buf1);
      name_delay(delay2, buf2);
      different("frame %s delays differ: <%s >%s", fbuf, buf1, buf2);
    }
  }

  if (imageno1 != s1->nimages || imageno2 != s2->nimages)
    different("frame counts differ: <#%d >#%d", s1->nimages, s2->nimages);

  /* That's it! */
  Gif_DeleteColormap(newcm);
  Gif_DeleteArray(gdata[0]);
  Gif_DeleteArray(gdata[1]);
  Gif_DeleteArray(glast[0]);
  Gif_DeleteArray(glast[1]);
  Gif_DeleteArray(scratch);
  Gif_DeleteArray(line);

  return was_different ? DIFFERENT : SAME;
}
Beispiel #3
0
int draw_brush(int i, float a)
{
    float d[4] = { 1.0f, 1.0f, 1.0f, 1.0f };

    struct brush *b = get_brush(i);
    
    if (b->count)
    {
        init_brush(i);

        /* Modulate the diffuse color by the current value. */

        d[0] = b->d[0];
        d[1] = b->d[1];
        d[2] = b->d[2];
        d[3] = b->d[3] * a;

        /* Apply the textures. */

        apply_image(GL_TEXTURE3_ARB, b->image[3]);
        apply_image(GL_TEXTURE2_ARB, b->image[2]);
        apply_image(GL_TEXTURE1_ARB, b->image[1]);
        apply_image(GL_TEXTURE0_ARB, b->image[0]);

        /* Enable texture coordinate generation, if requested. */

        set_tex_gen(GL_TEXTURE3_ARB, (b->flags & BRUSH_ENV_MAP_3),
                                     (b->flags & BRUSH_SKY_MAP_3));
        set_tex_gen(GL_TEXTURE2_ARB, (b->flags & BRUSH_ENV_MAP_2),
                                     (b->flags & BRUSH_SKY_MAP_2));
        set_tex_gen(GL_TEXTURE1_ARB, (b->flags & BRUSH_ENV_MAP_1),
                                     (b->flags & BRUSH_SKY_MAP_1));
        set_tex_gen(GL_TEXTURE0_ARB, (b->flags & BRUSH_ENV_MAP_0),
                                     (b->flags & BRUSH_SKY_MAP_0));

        /* Enable the shader program, if specified. */

        if (GL_has_shader_objects)
        {
            if (b->shad_prog)
                glUseProgramObjectARB(b->shad_prog);
            else
                glUseProgramObjectARB(0);
        }

        /* Enable vertex and fragment programs, if specified. */

        if (GL_has_fragment_program)
        {
            if (b->frag_prog)
            {
                glEnable(GL_FRAGMENT_PROGRAM_ARB);
                glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, b->frag_prog);
            }
            else
                glDisable(GL_FRAGMENT_PROGRAM_ARB);
        }

        if (GL_has_vertex_program)
        {
            if (b->vert_prog)
            {
                glEnable(GL_VERTEX_PROGRAM_ARB);
                glBindProgramARB(GL_VERTEX_PROGRAM_ARB,   b->vert_prog);
            }
            else
                glDisable(GL_VERTEX_PROGRAM_ARB);
        }

        /* Set the line width. */

        glLineWidth(b->line_width);

        /* Disable lighting, if requested. */

        if (b->flags & BRUSH_UNLIT)
        {
            glDisable(GL_LIGHTING);
            glColor4fv(d);
        }
        else
        {
            glColor4fv(d);

            /* Apply the material properties. */
    
            if (b->flags & BRUSH_DIFFUSE)
                glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE,   d);
            if (b->flags & BRUSH_AMBIENT)
                glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT,   b->a);
            if (b->flags & BRUSH_SPECULAR)
                glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR,  b->s);
            if (b->flags & BRUSH_SHINY)
                glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, b->x);
        }
    }

    /* Return an indication that this brush is transparent. */

    return (d[3] < 1) | (b->flags & BRUSH_TRANSPARENT);
}