#include #include #include #define WIDTH 640 #define HEIGHT 480 #define DEPTH 32 #define BPP DEPTH/8 //bytes per pixel #define BLOCK 4 //each block pixel is BLOCKxBLOCK ordinary pixels int blockw, blockh; int bytesPerPix; SDL_Surface * screen; void setpixel8(int x, int y, Uint8 r, Uint8 g, Uint8 b) { Uint8 *pixmem8; Uint32 colour; colour = SDL_MapRGB( screen->format, r, g, b ); pixmem8 = (Uint8*) screen->pixels + y + x; *pixmem8 = colour; } void setpixel16(int x, int y, Uint8 r, Uint8 g, Uint8 b) { Uint16 *pixmem16; Uint32 colour; colour = SDL_MapRGB( screen->format, r, g, b ); pixmem16 = (Uint16*) screen->pixels + y + x; *pixmem16 = colour; } void setpixel32(int x, int y, Uint8 r, Uint8 g, Uint8 b) { Uint32 *pixmem32; Uint32 colour; colour = SDL_MapRGB( screen->format, r, g, b ); pixmem32 = (Uint32*) screen->pixels + y + x; *pixmem32 = colour; } void blockPixel(int x, int y, Uint8 r, Uint8 g, Uint8 b) { int itimesw; int xblock=x*BLOCK; int yblock=y*screen->pitch/bytesPerPix*BLOCK; for (int i=0; ipitch/bytesPerPix; for (int j=0; jformat->BytesPerPixel; blockw = screen->pitch/bytesPerPix/BLOCK; blockh = screen->h/BLOCK; } int main(int argc, char* argv[]) { SDL_Event event; int keypress = 0; int h=0; Init(); while(!keypress) { DrawScreen(screen,h++); while(SDL_PollEvent(&event)) { switch( event.type ) { case SDL_QUIT: keypress = 1; break; case SDL_KEYDOWN: keypress = 1; break; } } } SDL_Quit(); return 0; }