You know, people have done quite pretty 2d graphics when 800MHz was science fiction.
I didn't mean to sound like I was insulting 800MHz and slower computers -- one of my favourite computers ever, this one I'm using right now, clocks in at 400MHz. I was trying to defend the SDL, because I really like it.
Incidentally, this computer took 20.981 seconds to run the original version (I didn't feel like running it more than once!), and this version only took slightly over 6.7 seconds:
Code:
#include "SDL/SDL.h"
const int SCREEN_WIDTH = 1024;
const int SCREEN_HEIGHT = 768;
SDL_Surface *screen = NULL;
int main( int argc, char* args[] )
{
int i, x, y, rgb;
SDL_Init(SDL_INIT_EVERYTHING);
screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 32, SDL_SWSURFACE);
SDL_WM_SetCaption("VirtualGL", NULL);
for (i = 0; i < 100; i++) {
rgb = ((rand() * 255) << 16) | ((rand() * 255) << 8) | (rand() * 255);
SDL_LockSurface(screen);
for (y = 0; y < SCREEN_HEIGHT; y++) {
Uint32 *bufp = (Uint32*) screen->pixels + y * screen->pitch / 4;
for (x = 0; x < SCREEN_WIDTH; x++) {
*bufp = rgb;
bufp++;
}
}
SDL_UnlockSurface(screen);
SDL_Flip(screen);
}
SDL_Quit();
return(0);
}
That's a substantial speed increase.