Skip to content

Instantly share code, notes, and snippets.

@Madsy
Created October 10, 2009 19:04
Show Gist options
  • Save Madsy/207053 to your computer and use it in GitHub Desktop.
Save Madsy/207053 to your computer and use it in GitHub Desktop.
#include <SDL/SDL.h>
SDL_Surface* s; SDL_Event e;
void render()
{
unsigned char* pix = screen->pixels;
SDL_LockSurface(s);
for(int y=0;y<600;++y){
int c=y*800;
for(int x=0;x<800;++x){
int i= (col+x)*4;
pix[col ]=a;
pix[col+1]=r;
pix[col+2]=g;
pix[col+3]=b;
}
}
SDL_UnlockSurface(s);
SDL_Flip(s);
}
int main()
{
SDL_Init(SDL_INIT_VIDEO);
s=SDL_SetVideoMode(800,600,32,SDL_HWSURFACE|SDL_DOUBLEBUF);
int r=1;
while(r){
while(SDL_PollEvent(&e))
{
if(e.type==SDL_QUIT || (e.type==SDL_KEYDOWN&&e.key.keysym.sym==SDLK_ESCAPE))
r=0;
}
render();
}
SDL_Quit();
exit(0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment