Fast draw

I’m writing a tile scrolling game, and was just wondering if I’m updating my
screen the fastest possible way.

imagebmp = SDL_LoadBMP(filename);
image = SDL_DisplayFormat(imagebmp);
SDL_FreeSurface(imagebmp);


    for(int x = 0; x<10; x++)
        for(int y = 0; y<10; y++)
        {
    	rectangle.x = x;
    	rectangle.y = y;
    	rectangle.w = image[index]->w;
    	rectangle.h = image[index]->h;
    	SDL_BlitSurface(image, NULL, display, &rectangle);
         }

     SDL_FlipDisplay(display);

where display is the screen surface
and image and imagebmp are surfaces also.

I know the display loop is just going to show the same tile in a 10x10 grid,
but just pretend it’s a state of the art tile display system :).

Am I drawing and showing my graphics the fastest way possible?______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com

It may take more memory and is sure to be considered a micro-optimsation
but (LOOK BELOW FOR COMMENTS IN YOUR CODE)

I’m writing a tile scrolling game, and was just wondering if I’m updating my
screen the fastest possible way.

imagebmp = SDL_LoadBMP(filename);
image = SDL_DisplayFormat(imagebmp);
SDL_FreeSurface(imagebmp);

    for(int x = 0; x<10; x++)
        for(int y = 0; y<10; y++)
        {
    	rectangle.x = x;
    	rectangle.y = y;

//Instead of looking up the indexed image 100 times yoo could
//look it up before you enter the loop and just stor it in your rectagle
//I don’t see anywhere in either for loop that changes the value of index.On Sun, 2 Apr 2000, Robert Clayton wrote:

    	rectangle.w = image[index]->w;
    	rectangle.h = image[index]->h;
    	SDL_BlitSurface(image, NULL, display, &rectangle);
         }

     SDL_FlipDisplay(display);

where display is the screen surface
and image and imagebmp are surfaces also.

I know the display loop is just going to show the same tile in a 10x10 grid,
but just pretend it’s a state of the art tile display system :).

Am I drawing and showing my graphics the fastest way possible?


Get Your Private, Free Email at http://www.hotmail.com