Пример #1
0
static int draw(RGB32 *src, RGB32 *dst)
{
  	memcpy(dst, src, video_area * PIXEL_SIZE);
  	apply_lens(x,y,src,dst);
	if (mode==1){
  		x+= xd; y+=yd;
  		if (x > (video_width - lens_width - 5) || x < 5) xd = -xd;
  		if (y > (video_height - lens_width - 5) || y < 5) yd = -yd;
	}

  	return 0;
} 
Пример #2
0
Файл: lens.c Проект: cjxgm/clabs
int main( int argc, char* argv[] )
{
    int x = 16, y = 16;
    int xd = 1, yd = 1;

    if (argc > 1) {
	printf("Retro Lens Effect - B. Ellacott - 2002\n");
	return -1;
    }

    if (!TDEC_set_video(SCREEN_WIDTH, SCREEN_HEIGHT, 8, SDL_HWSURFACE | SDL_HWPALETTE /*| SDL_FULLSCREEN*/))
	quit(1);
    
    TDEC_init_timer();

    SDL_WM_SetCaption("Retro - Lens - ", "");
  
    init();

    /* time based demo loop */
    while( 1 ) {
	TDEC_new_time();

	process_events();

        /* blit the whole backing image across */
        SDL_UnlockSurface(screen);
        SDL_BlitSurface(backing, NULL, screen, &dst);
        SDL_LockSurface(screen);

        /* apply the lens */
        apply_lens(x, y);

        /* shift the coordinates around */
        x += xd; y += yd;
        if (x > (SCREEN_WIDTH - LENS_WIDTH - 15) || x < 15) xd = -xd;
        if (y > (SCREEN_HEIGHT - LENS_WIDTH - 15) || y < 15) yd = -yd;

	/* update changed portions */
	if (TDEC_fps_ok()) {
            SDL_UpdateRects(screen, 1, &dst);
	}
    }
  
    return 0; /* never reached */
}