The next code segment, which is the whole main loop is very slow.
It has just 2 for loops, which may has the main time consumption.
Please have a quick look at the code.
Code: Select all
...
while( !bDone )
{
/////////////////////////////////////////////
// Handle input
while( SDL_PollEvent( &event ) )
{
switch( event.type )
{
case SDL_KEYDOWN:
switch( event.key.keysym.sym )
{
case SDLK_ESCAPE:
bDone = true ;
break ;
case SDLK_p:
{
char sz[25] ;
sprintf( sz, "/tmp/screenshot\0" ) ;
int i = SDL_SaveBMP(screen, sz) ;
i=0 ;
}
break ;
} // switch sym
break ;
case SDL_MOUSEMOTION:
x = event.motion.x ;
y = event.motion.y ;
break ;
case SDL_MOUSEBUTTONDOWN:
break ;
} // switch type
} // poll event
///////////////////////////////
// start timing
runtime = clock() ;
// lets do something
SDL_LockSurface( screen ) ;
unsigned int *p = ((unsigned int*)(screen->pixels)) ;
for( int j=0; j< SCREEN_HEIGHT; j++ )
{
for( int i=0; i< SCREEN_WIDTH; i++ ){
vector float color = _load_vec_float4(1.0f,1.0f,0.0f,0.0f) ;
// put the color to the screen
p[j*SCREEN_WIDTH+i] = VEC_TO_A8R8G8B8(color) ;
}
}
SDL_UnlockSurface( screen ) ;
//time_int(1) ;
elapsed = clock() - runtime ;
SDL_Color sdlcolor={1,1,1,1} ;
char szfps[50] ;
float ftime = float(elapsed)/float(CLOCKS_PER_SEC) ;
sprintf(szfps, "Frame Time: %.3f", ftime ) ;
RenderText(screen, font, sdlcolor,5,50,szfps) ;
sprintf(szfps, "FPS: %.3f", 1.0f/ftime ) ;
RenderText(screen, font, sdlcolor,5,150,szfps) ;
//printf( "s/frame: %f\n", float(elapsed)/float(CLOCKS_PER_SEC) ) ;
SDL_Flip( screen ) ;
}
...
Screen width and height are defined as follows:
Code: Select all
#define SCREEN_WIDTH 1100 // 1100 max
#define SCREEN_HEIGHT 600
Is this possible?
I mean whats wrong?
I use Fedora 7 on the ps3 and the libs sdl, sdl_ttf, zlib, truetype.
And this code is just executed on the ppu.
Thanks