void PassMipmap(ge_Image* image, int max, int algo){ if(!max)return; gePrintDebug(0x100, "Making mipmaps at %d level\n", max); int i = 0; int w=image->textureWidth, h=image->textureHeight; // u32* mipmap = (u32*)geMalloc(sizeof(u32) * w * h); // memcpy(mipmap, image->data, sizeof(u32)*w*h); u32* mipmaps[16]; mipmaps[0] = image->data; for(i=0; i<max; i++){ w /= 2; h /= 2; u32* mipmap = (u32*)geMalloc(sizeof(u32) * image->textureWidth * image->textureHeight); mipmaps[i+1] = mipmap; if(algo == 10){ MakeSubImage(mipmaps[i+1], mipmaps[0], image->textureWidth, image->textureHeight, algo, (float)image->textureWidth/(float)w); }else{ MakeSubImage(mipmaps[i+1], mipmaps[i], w*2, h*2, algo, 2.0); } glTexSubImage2D(GL_TEXTURE_2D, i+1, 0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, mipmap); libge_context->gpumem += w*h*sizeof(u32); if(i>0)geFree(mipmaps[i]); } geFree(mipmaps[i]); }
int InitImage( PSENTIENT ps, PENTITY pe, PTEXT parameters ) { INDEX idx; for( idx = 0; idx < NUM_IMAGE_VARS; idx++ ) { PTEXT saveparms = parameters; PTEXT arg; Image parent = GetLink( &FindContainer( pe )->pPlugin, iImage ); arg = GetParam( ps, ¶meters ); if( IsNumber( arg ) ) { PTEXT arg2 = GetParam( ps, ¶meters ); if( IsNumber( arg2 ) ) { Image image; if( parent ) image = MakeSubImage( parent , 0, 0 // need other 2 arguments. , atoi( GetText( arg ) ) , atoi( GetText( arg2 ) ) ); else image = MakeImageFile( atoi( GetText( arg ) ) , atoi( GetText( arg2 ) ) ); SetLink( &pe->pPlugin, iImage, image ); if( ps->CurrentMacro ) ps->CurrentMacro->state.flags.bSuccess = TRUE; else { DECLTEXT( msg, "Invalid second parameter, expecting a number" ); EnqueLink( &ps->Command->Output, &msg ); } // if more args - warn? } } else { Image image; // expect that the remainder is a name.. parameters = saveparms; arg = GetFileName( ps, ¶meters ); // loaded image file doesn't care for parent status... image = LoadImageFile( GetText( arg ) ); if( image ) { SetLink( &pe->pPlugin, iImage, image ); if( ps->CurrentMacro ) ps->CurrentMacro->state.flags.bSuccess = TRUE; else { DECLTEXT( msg, "Failed to load image..." ); EnqueLink( &ps->Command->Output, &msg ); } } } AddVolatileVariable( pe, ImageVars + idx, 0 ); { int n; for( n = 0; n < NUM_METHODS; n++ ) AddMethod( pe, ImageMethods + n ); } } return 0; // return success }
int main( void ) { uint32_t width, height; uint32_t imagecount = 0; uint32_t testimagesatinitialization = 0; Image blank; srand( time( NULL ) ); for(width=0; width< NUM_REELS; width++) { g.uiSpeedCounter[width] = 0; g.uiSpeedStep[width] = 2; g.idx[width]= 0; } g.pdi = GetDisplayInterface(); g.pii = GetImageInterface(); //SetSystemLog( SYSLOG_FILE, stdout ); SetSystemLoggingLevel( 1000 + LOG_NOISE); GetDisplaySize( &width, &height );; g.render = OpenDisplaySizedAt( 0, width, height, 0, 0 ); UpdateDisplay(g.render); g.surface = GetDisplayImage( g.render ); SetMouseHandler( g.render, MouseMethod, 0 ); // blank = LoadImageFile( WIDE("blankimage.jpg")); blank = MakeImageFile(96,96); ClearImageTo( blank, BASE_COLOR_CYAN ); g.playagain=LoadImageFile( WIDE("%images%/playagain.jpg")); g.playing =LoadImageFile( WIDE("%images%/playing.jpg")); g.background = LoadImageFile( WIDE("%images%/background.jpg") ); // g.background = blank; g.strip = LoadImageFile( WIDE("%images%/slot_strip.jpg") ); g.nReels = NUM_REELS; { Image icons[NUM_ICONS]; int n, m; INDEX idx; for( n = 0; n < NUM_ICONS; n++ ) { icons[n] = MakeSubImage( g.strip, 96 * n, 0, 96, 96 ); } n = width = imagecount = height = 0; while(imagecount < NUM_IMAGES ) { idx = rand()%NUM_ICONS; g.images[imagecount] = icons[idx]; if( testimagesatinitialization ) { BlotImage( g.surface, g.images[imagecount], width * 96, height * 96 ); width++; if(!( width % 8 )) { width=0; height++; } } imagecount++; for( m = 0; m < (( rand()%2 ) ); m++) { g.images[imagecount] = blank; if( testimagesatinitialization ) { BlotImage( g.surface, g.images[imagecount], width * 96, height * 96 ); width++; if(!( width % 8 )) { width=0; height++; } } imagecount++; } if( testimagesatinitialization ) { SyncRender( g.render); UpdateDisplay(g.render); } } if( !testimagesatinitialization ) { SyncRender( g.render); UpdateDisplay(g.render); } for( n = 0; n < NUM_BLURS; n++ ) { g.blurs[n] = MakeImageFile( 96, (NUM_PICS) * 96 ); g.dodges[n] = MakeImageFile( 96, (NUM_PICS) * 96 ); for( m = 0; m < NUM_IMAGES; m++ ) { idx = rand()%NUM_IMAGES; g.reel[0][m] = g.images[idx]; } Blur( g.blurs[n], g.reel[0] ); DodgeEx( g.dodges[n], g.reel[0] , 2); } for( n = 0; n < NUM_REELS; n++) { g.subsurface[n] = MakeSubImage( g.surface , REEL_OFSX + REEL_STEPX * n , REEL_OFSY , REEL_WIDTH, (96 * NUM_PICS_IN_WINDOW) ); g.testsurface[n] = MakeSubImage( g.surface, REEL_OFSX + REEL_STEPX * n + 480, REEL_OFSY , REEL_WIDTH, (96 * NUM_PICS) ); } g.statussurface = MakeSubImage( g.surface , 490, 10 , 140, 68 ); g.backgroundsurface = MakeSubImage( g.surface , 0, 0 , 640, 460 ); } g.flags.bBackgroundInitialized = 0; ThreadTo( ReadInput, 0 ); { uint32_t start = GetTickCount(); xlprintf(LOG_NOISE)("Started at %lu" , start); g.ofs = 0; while( 1 ) { if( g.flags.bSpinning ) { DrawSpinningReels(FALSE); } #ifndef __ARM__ // scale to approx unit speeds.. WakeableSleep( 250 ); //WakeableSleep( 33); #endif } } CloseDisplay( g.render ); UnmakeImageFile( g.strip ); return 0; }