void jpeg_free_small(j_common_ptr cinfo, void *object, size_t size) { jpeg_free(cinfo, object, "Freeing JPEG small internal data"); }
void jpeg_free_large(j_common_ptr cinfo, void FAR * object, size_t size) { jpeg_free(cinfo, object, "Freeing JPEG large internal data"); }
int main(int argc, char *argv[]) { SDL_Surface *screen; TPool *tpool; CIList *cil; CImage *ci; int i, ch; unsigned int rw, rh; // requested window size unsigned long int fcount, do_jpeg; double ticks_start, load_fade, aspect; /* Copyright notice */ printf("\n Continuous Imaging 'fly'\n Copyright (C) 2008-2012 David Lowy & Tom Rathborne\n\n"); /* Get options --jpeg / -j and --geometry / -g */ static struct option longopts[] = { { "jpeg", no_argument, NULL, 'j' }, { "geometry", required_argument, NULL, 'g' }, { NULL, 0, NULL, 0 } }; /* Defaults */ do_jpeg = 0; rw = 0; rh = 0; while ((ch = getopt_long(argc, argv, "jg:", longopts, NULL)) != -1) switch(ch) { case 'j': do_jpeg = 1; break; case 'g': if (sscanf(optarg, "%ux%u", &rw, &rh) != 2) { printf("Unhandled geometry '%s': format is WxH\n", optarg); rw = 0; rh = 0; } break; default: printf("Unrecognized option %c ignored\n", ch); } argc -= optind; argv += optind; /* Get SDL+GL screen */ screen = init_sdl_gl(CI_BPC, CI_BITS, rw, rh); if(!screen) { fprintf(stderr, "Failed to init SDL GL context.\n"); return (0); } #ifndef CI_LINUX SDL_ShowCursor(SDL_DISABLE); #endif SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE); /* Set up JPEG if necessary */ if (do_jpeg) jpeg_alloc(screen->w, screen->h); aspect = CI_ASPECT / ((double)screen->w / (double)screen->h); /* time entire program */ ticks_start = SDL_GetTicks(); /* Init texture pool */ tpool = tp_create(65535, 800); // This was supposed to keep fewer textures in VRAM, but it just fills VRAM. /* create CI List */ cil = cil_create(tpool, "thumb/%s.jpg", "image/%s.jpg"); /* Load all dbs, make links */ cil_load_scidb(cil, "cidb.db"); /* Load image data and textures - and draw 'em! */ for(i = 0; i < cil->rcount; i++) { ci = cil->list[i]; assert(ci); assert(ci->subs); cil_ci_imgprep(cil, ci, 0); /* load images to N levels */ ci_load_tx(ci, 0); /* load textures to N level */ // Render load_fade = sqrt(1.0 - ((double) i / (double) cil->rcount)); glLoadIdentity(); glScalef(load_fade, load_fade / aspect, 1.0); // glRotatef(360.0 * ((double) i / (double) cil->rcount), 0.0, 0.0, 1.0); glTranslatef(-0.5, -0.5, 0.0); glClear(GL_COLOR_BUFFER_BIT); glColor4f(1.0, 1.0, 1.0, sqrt(load_fade)); glBindTexture(GL_TEXTURE_2D, ci->tid); glCallList(cil->gl_list); SDL_GL_SwapBuffers(); } for(i = 0; i < cil->rcount; i++) { ci = cil->list[i]; assert(ci); assert(ci->subs); ci_mklist(ci, cil->gl_list); } printf("Startup took %.2fs.\n", (SDL_GetTicks() - ticks_start) / 1000.0); /* Main loop */ ticks_start = SDL_GetTicks(); SDL_WarpMouse(screen->w/2, screen->h/2); SDL_EventState(SDL_MOUSEMOTION, SDL_ENABLE); fcount = fly(screen, cil, do_jpeg); printf("Average FPS: %.2f\n", fcount * 1000.0 / (SDL_GetTicks() - ticks_start)); printf("Cleaning up ...\n"); cil_cleanup(cil); /* cleanup */ cil_delete(cil); /* drop our data */ tp_delete(tpool); /* JPEG cleanup */ if (do_jpeg) jpeg_free(); SDL_Quit(); return (0); }