30

Si quelqu'un pouvait poster un screenshot du résultat, ce serai super!
J'ai pas de compilateur sous la main...et de toute facon ce PC est beaucoup trop
restreint pour y faire quoi que ce soit!
Merci!

31

j'ai corrigé ton flou pour que ça passe en 32bits...
screenshot9yw.png
 
#include <stdio.h> 
#include <stdlib.h> 
#include <stdint.h> 
#include <SDL/SDL.h> 
#include <math.h> 
 
typedef struct{ 
    unsigned int uWidth; 
    unsigned int uHeight; 
    SDL_Surface *pData; 
} SBitMapFont; 
 
SBitMapFont* LoadBitMapFontFromFile(char *pFileName) 
{ 
    SBitMapFont* pReturn = NULL; 
    SDL_Surface *pTmpSurface; 
 
    if((pTmpSurface = SDL_LoadBMP(pFileName)) 
	    && !(pReturn  = malloc(sizeof(SBitMapFont)))) 
    { 
	pReturn->uWidth  = (unsigned int)pTmpSurface->w/255; 
	pReturn->uHeight = (unsigned int)pTmpSurface->h; 
	pReturn->pData   = pTmpSurface; 
    } 
    else 
	fprintf(stderr,"[Erreur ::LoadFontFromFile] : Can't load %s\n",pFileName); 
    return pReturn; 
} 
 
/* amusons nous à dessiner avec les nombres premiers! */ 
uint8_t isprime(uint32_t n) { 
    for (uint32_t d=2;d*d<=n;d++) 
	if(!(n%d)) 
	    return 0; 
    return 42; 
} 
 
 
/* oui c'est moche et lent */ 
void addPixelSat(SDL_Surface *s, int x, int y, Uint32 c) { 
    Uint32 cc = *((Uint32*)(s->pixels) + x + y * s->w); 
    Uint16 nr = ((c >> 16) & 255)+((cc >> 16) & 255); 
    Uint16 ng = ((c >> 8) & 255)+((cc >> 8) & 255); 
    Uint16 nb = (c & 255)+(cc & 255); 
    if (nr > 255) nr = 255; 
    if (ng > 255) ng = 255; 
    if (nb > 255) nb = 255; 
    *((Uint32*)(s->pixels) + x + y * s->w) = (nr<<16)|(ng<<8)|nb; 
} 
 
 
void line (SDL_Surface *s, float x1, float y1, float x2, float y2, Uint32 c) { 
    double hl=fabs(x2-x1), vl=fabs(y2-y1), length=(hl>vl)?hl:vl; 
    float deltax=(x2-x1)/(float)length, deltay=(y2-y1)/(float)length; 
    for (int i=0; i<(int)length; i++) 
	addPixelSat(s, (int)(x1+=deltax), (int)(y1+=deltay), c); 
} 
 
 
char *lipsum = 
"Lorem ipsum dolor sit amet, consectetuer adipiscing elit " 
"Aenean volutpat lorem ut enim. Cras accumsan porta augue " 
"Nulla quis magna. Morbi at dolor. Vivamus quam. Fusce feugiat egestas elit " 
"Nullam tincidunt. Donec et felis " 
"Fusce purus dui, semper vitae, tincidunt nec, malesuada id, purus " 
"Lorem ipsum dolor sit amet, consectetuer adipiscing elit " 
"Etiam a risus nec tellus ultrices tempor. Nunc mauris velit, euismod vitae, hendrerit et, auctor eget, odio " 
"Praesent dapibus nulla. Nunc et nulla   " 
"Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec lobortis rhoncus tortor   " 
; 
 
int font[26][11]={{7,24,36,66,126,66,66,66,0,0,0},{8,240,136,136,252,130,130,252,0,0,0},{8,28,98,128,128,128,64,62,0,0,0}, 
    {8,240,136,132,130,130,130,252,0,0,0},{8,252,128,128,240,128,128,254,0,0,0},{6,62,32,32,60,32,32,32,0,0,0}, 
    {8,60,66,128,142,130,66,60,0,0,0},{7,66,66,66,126,66,66,66,0,0,0},{2,2,2,2,2,2,2,2,0,0,0},{5,2,2,2,2,18,18,12,0,0,0}, 
    {7,66,68,72,80,104,68,66,0,0,0},{5,16,16,16,16,16,16,30,0,0,0},{8,130,198,170,146,130,130,130,0,0,0}, 
    {6,34,34,50,42,38,34,34,0,0,0},{7,24,36,66,66,66,66,60,0,0,0},{6,56,36,34,60,32,32,32,0,0,0}, 
    {8,48,72,132,132,148,140,118,0,0,0},{7,112,72,68,120,72,68,66,0,0,0},{6,14,16,32,28,2,4,56,0,0,0}, 
    {6,62,8,8,8,8,8,8,0,0,0},{5,18,18,18,18,18,18,12,0,0,0},{8,130,130,68,68,40,40,16,0,0,0}, 
    {8,130,130,130,146,146,146,108,0,0,0},{8,130,68,40,16,40,68,130,0,0,0},{6,34,34,20,20,8,8,16,0,0,0}, 
    {8,254,4,8,16,32,64,252,0,0,0}}; 
 
#define mulRGB_tmp(k,x,n) ((128+(((x)>>n)&255)*(k))>>8)<<n 
inline uint32_t mulRGB(int k,uint32_t x) { return mulRGB_tmp(k,x,16) | mulRGB_tmp(k,x,8) | mulRGB_tmp(k,x,0); } 
 
int main(int argc,char *argv[]){ 
    SDL_Surface *screen; 
    SDL_Event event; 
    if(SDL_Init(SDL_INIT_VIDEO) == -1) 
	exit(1); 
    atexit(SDL_Quit); 
    screen = SDL_SetVideoMode(640, 480, 32, SDL_SWSURFACE); 
    if (screen == NULL) 
	exit(1); 
    SDL_WM_SetCaption("Enjoy !", NULL); 
 
    /* youpi, ça bouge! */ 
    for (uint32_t n=0,z=160+320*120,c=0x123456; !SDL_PollEvent(&event) 
	    || event.type!=SDL_QUIT; n+=64*48,c=(c*189+123)%0xFF7821,z=c/21<320*240?c/21:z) { 
	for (uint32_t x=0; x<64*48; x++) 
	    if (isprime(x+n)) { 
		SDL_Rect r={z%320+x%64*5,z/320+x/64*5,5,5}; 
		SDL_FillRect(screen, &r, c); 
	    } 
 
	/* il est flou afflelou */ 
	uint32_t *pix = (uint32_t *)screen->pixels; 
	int pp[] = {1,640*480-1,640,640*480-640,1,640*480-1,640,640*480-640,0}; 
	for (int *p = pp; *p; p++) { 
	    uint32_t x=0,y=*p; 
	    for (; y<640*480; x++,y++) 
		pix[x] = pix[x]-((pix[x]>>4)&0x0F0F0F)+((pix[y]>>4)&0x0F0F0F) | 0xFF000000; 
	    for (y=0; x<640*480; x++,y++) 
		pix[x] = pix[x]-((pix[x]>>4)&0x0F0F0F)+((pix[y]>>4)&0x0F0F0F) | 0xFF000000; 
	} 
 
	static int tpos = 0; 
	for (Uint16 l = 0; l < tpos; l++) { 
	    char huhu = lipsum[l]; 
	    if ((huhu = (huhu > 'Z') ? (huhu - 'a') : (huhu - 'A')) != ' '-'A') 
	       for (Uint16 y = 1; y < 10; y++) 
		   for (Uint16 x = 0; x < 8; x++) 
		       if (font[huhu][y]&(1<<(7-x))) 
			   addPixelSat(screen,  160 + (x+((l * 8)))%320, 
				   120 + (y + ((l * 8) / 320) * 10)%240, 0xffffff); 
	} 
	if(lipsum[++tpos] == 0) tpos = 0; 
 
	static float xs = 0.0, ys = 0.0; 
	line(screen, sin(xs+=0.1)*320+320, cos(ys+=0.07)*240+240, cos(xs)*320+320, sin(ys)*240+240,rand()); 
 
	SDL_Flip(screen); 
	SDL_Delay(20); 
    } 
 
    return 0; 
}
avatar
fabetal_ > Hier, je me suis fait monter par un pote
redangel > et en chevals, ça donne quoi?
Nil> OMG I think I'm gay

32

BookeldOr
: j'ai corrigé ton flou pour que ça passe en 32bits...

Euh, en théorie mon flou passe nickel en 32 bits, c'est plutôt SDL_FillRect qui aurait dû remplir avec c | 0xFF000000 au lieu de c ^^

« The biggest civil liberty of all is not to be killed by a terrorist. » (Geoff Hoon, ministre des transports anglais)

33

ouais ouais, c'est juste que j'ai pas cherché à comprendre les 0x123456 et compagnie du fillrect

edit: non non même en remplissant de noir au début et dans les petits carrés, ma fenêtre devient peu à peu transparente cheeky si je rajoute pas le masque dans ton zoom
avatar
fabetal_ > Hier, je me suis fait monter par un pote
redangel > et en chevals, ça donne quoi?
Nil> OMG I think I'm gay

34

bon, j'ai corrigé pour le 32 bits et viré les undefined behaviour liés à xs+=0.1 ^^
 
#include <stdio.h> 
#include <stdlib.h> 
#include <stdint.h> 
#include <SDL/SDL.h> 
#include <math.h> 
 
typedef struct{ 
    unsigned int uWidth; 
    unsigned int uHeight; 
    SDL_Surface *pData; 
} SBitMapFont; 
 
SBitMapFont* LoadBitMapFontFromFile(char *pFileName) 
{ 
    SBitMapFont* pReturn = NULL; 
    SDL_Surface *pTmpSurface; 
 
    if((pTmpSurface = SDL_LoadBMP(pFileName)) 
	    && !(pReturn  = malloc(sizeof(SBitMapFont)))) 
    { 
	pReturn->uWidth  = (unsigned int)pTmpSurface->w/255; 
	pReturn->uHeight = (unsigned int)pTmpSurface->h; 
	pReturn->pData   = pTmpSurface; 
    } 
    else 
	fprintf(stderr,"[Erreur ::LoadFontFromFile] : Can't load %s\n",pFileName); 
    return pReturn; 
} 
 
/* amusons nous à dessiner avec les nombres premiers! */ 
uint8_t isprime(uint32_t n) { 
    for (uint32_t d=2;d*d<=n;d++) 
	if(!(n%d)) 
	    return 0; 
    return 42; 
} 
 
 
/* oui c'est moche et lent */ 
void addPixelSat(SDL_Surface *s, int x, int y, Uint32 c) { 
    Uint32 cc = *((Uint32*)(s->pixels) + x + y * s->w); 
    Uint16 nr = ((c >> 16) & 255)+((cc >> 16) & 255); 
    Uint16 ng = ((c >> 8) & 255)+((cc >> 8) & 255); 
    Uint16 nb = (c & 255)+(cc & 255); 
    if (nr > 255) nr = 255; 
    if (ng > 255) ng = 255; 
    if (nb > 255) nb = 255; 
    *((Uint32*)(s->pixels) + x + y * s->w) = (nr<<16)|(ng<<8)|nb; 
} 
 
 
void line (SDL_Surface *s, float x1, float y1, float x2, float y2, Uint32 c) { 
    double hl=fabs(x2-x1), vl=fabs(y2-y1), length=(hl>vl)?hl:vl; 
    float deltax=(x2-x1)/(float)length, deltay=(y2-y1)/(float)length; 
    for (int i=0; i<(int)length; i++) 
	addPixelSat(s, (int)(x1+=deltax), (int)(y1+=deltay), c); 
} 
 
 
char *lipsum = 
"Lorem ipsum dolor sit amet, consectetuer adipiscing elit " 
"Aenean volutpat lorem ut enim. Cras accumsan porta augue " 
"Nulla quis magna. Morbi at dolor. Vivamus quam. Fusce feugiat egestas elit " 
"Nullam tincidunt. Donec et felis " 
"Fusce purus dui, semper vitae, tincidunt nec, malesuada id, purus " 
"Lorem ipsum dolor sit amet, consectetuer adipiscing elit " 
"Etiam a risus nec tellus ultrices tempor. Nunc mauris velit, euismod vitae, hendrerit et, auctor eget, odio " 
"Praesent dapibus nulla. Nunc et nulla   " 
"Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec lobortis rhoncus tortor   " 
; 
 
int font[26][11]={{7,24,36,66,126,66,66,66,0,0,0},{8,240,136,136,252,130,130,252,0,0,0},{8,28,98,128,128,128,64,62,0,0,0}, 
    {8,240,136,132,130,130,130,252,0,0,0},{8,252,128,128,240,128,128,254,0,0,0},{6,62,32,32,60,32,32,32,0,0,0}, 
    {8,60,66,128,142,130,66,60,0,0,0},{7,66,66,66,126,66,66,66,0,0,0},{2,2,2,2,2,2,2,2,0,0,0},{5,2,2,2,2,18,18,12,0,0,0}, 
    {7,66,68,72,80,104,68,66,0,0,0},{5,16,16,16,16,16,16,30,0,0,0},{8,130,198,170,146,130,130,130,0,0,0}, 
    {6,34,34,50,42,38,34,34,0,0,0},{7,24,36,66,66,66,66,60,0,0,0},{6,56,36,34,60,32,32,32,0,0,0}, 
    {8,48,72,132,132,148,140,118,0,0,0},{7,112,72,68,120,72,68,66,0,0,0},{6,14,16,32,28,2,4,56,0,0,0}, 
    {6,62,8,8,8,8,8,8,0,0,0},{5,18,18,18,18,18,18,12,0,0,0},{8,130,130,68,68,40,40,16,0,0,0}, 
    {8,130,130,130,146,146,146,108,0,0,0},{8,130,68,40,16,40,68,130,0,0,0},{6,34,34,20,20,8,8,16,0,0,0}, 
    {8,254,4,8,16,32,64,252,0,0,0}}; 
 
#define mulRGB_tmp(k,x,n) ((128+(((x)>>n)&255)*(k))>>8)<<n 
inline uint32_t mulRGB(int k,uint32_t x) { return mulRGB_tmp(k,x,16) | mulRGB_tmp(k,x,8) | mulRGB_tmp(k,x,0); } 
 
int main(int argc,char *argv[]){ 
    SDL_Surface *screen; 
    SDL_Event event; 
    if(SDL_Init(SDL_INIT_VIDEO) == -1) 
	exit(1); 
    atexit(SDL_Quit); 
    screen = SDL_SetVideoMode(640, 480, 32, SDL_SWSURFACE); 
    if (screen == NULL) 
	exit(1); 
    SDL_WM_SetCaption("Enjoy !", NULL); 
 
    /* youpi, ça bouge! */ 
    for (uint32_t n=0,z=160+320*120,c=0x123456; !SDL_PollEvent(&event) 
	    || event.type!=SDL_QUIT; n+=64*48,c=(c*189+123)%0xFF7821,z=c/21<320*240?c/21:z) { 
	for (uint32_t x=0; x<64*48; x++) 
	    if (isprime(x+n)) { 
		SDL_Rect r={z%320+x%64*5,z/320+x/64*5,5,5}; 
		SDL_FillRect(screen, &r, c | 0xFF000000); 
	    } 
 
	/* il est flou afflelou */ 
	uint32_t *pix = (uint32_t *)screen->pixels; 
	int pp[] = {1,640*480-1,640,640*480-640,1,640*480-1,640,640*480-640,0}; 
	for (int *p = pp; *p; p++) { 
	    uint32_t x=0,y=*p; 
	    for (; y<640*480; x++,y++) 
		pix[x] = pix[x]-((pix[x]>>4)&0x0F0F0F)+((pix[y]>>4)&0x0F0F0F); 
	    for (y=0; x<640*480; x++,y++) 
		pix[x] = pix[x]-((pix[x]>>4)&0x0F0F0F)+((pix[y]>>4)&0x0F0F0F); 
	} 
 
	static int tpos = 0; 
	for (Uint16 l = 0; l < tpos; l++) { 
	    char huhu = lipsum[l]; 
	    if ((huhu = (huhu > 'Z') ? (huhu - 'a') : (huhu - 'A')) != ' '-'A') 
	       for (Uint16 y = 1; y < 10; y++) 
		   for (Uint16 x = 0; x < 8; x++) 
		       if (font[huhu][y]&(1<<(7-x))) 
			   addPixelSat(screen,  160 + (x+((l * 8)))%320, 
				   120 + (y + ((l * 8) / 320) * 10)%240, 0xffffff); 
	} 
	if(lipsum[++tpos] == 0) tpos = 0; 
 
	static float xs = 0.0, ys = 0.0; 
	xs+=0.1; ys+=sqrt(0.005);
	line(screen, sin(xs)*320+320, cos(ys)*240+240, cos(xs)*320+320, sin(ys)*240+240,rand()); 
 
	SDL_Flip(screen); 
	SDL_Delay(20); 
    } 
 
    return 0; 
}


« The biggest civil liberty of all is not to be killed by a terrorist. » (Geoff Hoon, ministre des transports anglais)

35

ok en fait le problème venait de pixelsattruc
j'ai rajouté un espèce de trèfle tournant vert

#include <stdio.h>  
#include <stdlib.h>  
#include <stdint.h>  
#include <SDL/SDL.h>  
#include <math.h>  
  
typedef struct{  
    unsigned int uWidth;  
    unsigned int uHeight;  
    SDL_Surface *pData;  
} SBitMapFont;  
  
SBitMapFont* LoadBitMapFontFromFile(char *pFileName)  
{  
    SBitMapFont* pReturn = NULL;  
    SDL_Surface *pTmpSurface;  
  
    if((pTmpSurface = SDL_LoadBMP(pFileName))  
	    && !(pReturn  = malloc(sizeof(SBitMapFont))))  
    {  
	pReturn->uWidth  = (unsigned int)pTmpSurface->w/255;  
	pReturn->uHeight = (unsigned int)pTmpSurface->h;  
	pReturn->pData   = pTmpSurface;  
    }  
    else  
	fprintf(stderr,"[Erreur ::LoadFontFromFile] : Can't load %s\n",pFileName);  
    return pReturn;  
}  
  
/* amusons nous à dessiner avec les nombres premiers! */  
uint8_t isprime(uint32_t n) {  
    for (uint32_t d=2;d*d<=n;d++)  
	if(!(n%d))  
	    return 0;  
    return 42;  
}  
  
  
/* oui c'est moche et lent */  
void addPixelSat(SDL_Surface *s, int x, int y, Uint32 c) {  
    Uint32 cc = *((Uint32*)(s->pixels) + x + y * s->w);  
    Uint16 nr = ((c >> 16) & 255)+((cc >> 16) & 255);  
    Uint16 ng = ((c >> 8) & 255)+((cc >> 8) & 255);  
    Uint16 nb = (c & 255)+(cc & 255);  
    if (nr > 255) nr = 255;  
    if (ng > 255) ng = 255;  
    if (nb > 255) nb = 255;  
    *((Uint32*)(s->pixels) + x + y * s->w) = (nr<<16)|(ng<<8)|nb | 0xFF000000;  
}
 

void line (SDL_Surface *s, float x1, float y1, float x2, float y2, Uint32 c) {  
    double hl=fabs(x2-x1), vl=fabs(y2-y1), length=(hl>vl)?hl:vl;  
    float deltax=(x2-x1)/(float)length, deltay=(y2-y1)/(float)length;  
    for (int i=0; i<(int)length; i++)
      addPixelSat(s, (int)(x1+=deltax), (int)(y1+=deltay), c);
}
  
  
char *lipsum =  
"Lorem ipsum dolor sit amet, consectetuer adipiscing elit "  
"Aenean volutpat lorem ut enim. Cras accumsan porta augue "  
"Nulla quis magna. Morbi at dolor. Vivamus quam. Fusce feugiat egestas elit "  
"Nullam tincidunt. Donec et felis "  
"Fusce purus dui, semper vitae, tincidunt nec, malesuada id, purus "  
"Lorem ipsum dolor sit amet, consectetuer adipiscing elit "  
"Etiam a risus nec tellus ultrices tempor. Nunc mauris velit, euismod vitae, hendrerit et, auctor eget, odio "  
"Praesent dapibus nulla. Nunc et nulla   "  
"Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec lobortis rhoncus tortor   "  
;  
  
int font[26][11]={{7,24,36,66,126,66,66,66,0,0,0},{8,240,136,136,252,130,130,252,0,0,0},{8,28,98,128,128,128,64,62,0,0,0},  
    {8,240,136,132,130,130,130,252,0,0,0},{8,252,128,128,240,128,128,254,0,0,0},{6,62,32,32,60,32,32,32,0,0,0},  
    {8,60,66,128,142,130,66,60,0,0,0},{7,66,66,66,126,66,66,66,0,0,0},{2,2,2,2,2,2,2,2,0,0,0},{5,2,2,2,2,18,18,12,0,0,0},  
    {7,66,68,72,80,104,68,66,0,0,0},{5,16,16,16,16,16,16,30,0,0,0},{8,130,198,170,146,130,130,130,0,0,0},  
    {6,34,34,50,42,38,34,34,0,0,0},{7,24,36,66,66,66,66,60,0,0,0},{6,56,36,34,60,32,32,32,0,0,0},  
    {8,48,72,132,132,148,140,118,0,0,0},{7,112,72,68,120,72,68,66,0,0,0},{6,14,16,32,28,2,4,56,0,0,0},  
    {6,62,8,8,8,8,8,8,0,0,0},{5,18,18,18,18,18,18,12,0,0,0},{8,130,130,68,68,40,40,16,0,0,0},  
    {8,130,130,130,146,146,146,108,0,0,0},{8,130,68,40,16,40,68,130,0,0,0},{6,34,34,20,20,8,8,16,0,0,0},  
    {8,254,4,8,16,32,64,252,0,0,0}};  
  
#define mulRGB_tmp(k,x,n) ((128+(((x)>>n)&255)*(k))>>8)<<n  
inline uint32_t mulRGB(int k,uint32_t x) { return mulRGB_tmp(k,x,16) | mulRGB_tmp(k,x,8) | mulRGB_tmp(k,x,0); }  
  
int main(int argc,char *argv[]){  
    SDL_Surface *screen;  
    SDL_Event event;  
    if(SDL_Init(SDL_INIT_VIDEO) == -1)  
	exit(1);  
    atexit(SDL_Quit);  
    screen = SDL_SetVideoMode(640, 480, 32, SDL_SWSURFACE);  
    if (screen == NULL)  
	exit(1);  
    SDL_WM_SetCaption("Enjoy !", NULL);  
    SDL_FillRect(screen, &(SDL_Rect){0,0,640,480}, 0xFF000000);  
  
    /* youpi, ça bouge! */  
    double la = 0.1, lb = 0.1;
    for (uint32_t n=0,z=160+320*120,c=0x123456; !SDL_PollEvent(&event)  
	    || event.type!=SDL_QUIT; n+=64*48,c=(c*189+123)%0xFF7821,z=c/21<320*240?c/21:z) {  
	for (uint32_t x=0; x<64*48; x++)  
	    if (isprime(x+n)) {  
		SDL_Rect r={z%320+x%64*5,z/320+x/64*5,5,5};  
		SDL_FillRect(screen, &r, c | 0xFF000000);  
	    }  
  
	/* il est flou afflelou */  
	uint32_t *pix = (uint32_t *)screen->pixels;  
	int pp[] = {1,640*480-1,640,640*480-640,1,640*480-1,640,640*480-640,0};  
	for (int *p = pp; *p; p++) {  
	    uint32_t x=0,y=*p;  
	    for (; y<640*480; x++,y++)  
		pix[x] = pix[x]-((pix[x]>>4)&0x0F0F0F)+((pix[y]>>4)&0x0F0F0F);  
	    for (y=0; x<640*480; x++,y++)  
		pix[x] = pix[x]-((pix[x]>>4)&0x0F0F0F)+((pix[y]>>4)&0x0F0F0F);  
	}

	for(int slop = 0;slop < 10;slop++) {
	  line(screen, 320+sin(lb)*120-sin(la)*60,
	       240+cos(lb)*120-cos(la)*60,
	       320+sin(lb)*120+sin(la)*60,
	       240+cos(lb)*120+cos(la)*60,0xFF00FF00);  
	  la += 0.05;
	}
	lb += 0.203;
  
	static int tpos = 0;  
	for (Uint16 l = 0; l < tpos; l++) {  
	    char huhu = lipsum[l];  
	    if ((huhu = (huhu > 'Z') ? (huhu - 'a') : (huhu - 'A')) != ' '-'A')  
	       for (Uint16 y = 1; y < 10; y++)  
		   for (Uint16 x = 0; x < 8; x++)  
		       if (font[huhu][y]&(1<<(7-x)))  
			   addPixelSat(screen,  160 + (x+((l * 8)))%320,  
				   120 + (y + ((l * 8) / 320) * 10)%240, 0xffffff);  
	}
	if(lipsum[++tpos] == 0) tpos = 0;  
  
	static float xs = 0.0, ys = 0.0;  
	xs+=0.1; ys+=sqrt(0.005); 
	line(screen, sin(xs)*320+320, cos(ys)*240+240, cos(xs)*320+320, sin(ys)*240+240,rand());  
	SDL_Flip(screen);
	SDL_Delay(20);  
    }  
  
    return 0;  
} 
avatar
fabetal_ > Hier, je me suis fait monter par un pote
redangel > et en chevals, ça donne quoi?
Nil> OMG I think I'm gay

36

demo1.png
avatar
fabetal_ > Hier, je me suis fait monter par un pote
redangel > et en chevals, ça donne quoi?
Nil> OMG I think I'm gay

37

BookeldOr :
ARG cross!

edit: on garde la mienne, tu n'as pas respecté les règles! tongue

toi non plus, j'avais ajouté 10 lignes, tu les as modifiées toutes et ce n'est pas tout ce que tu as a fait
avatar
Webmaster du site Ti-FRv3 (et aussi de DevLynx)
Si moins de monde enculait le système, alors celui ci aurait plus de mal à nous sortir de si grosses merdes !
"L'erreur humaine est humaine"©Nil (2006) // topics/6238-moved-jamais-jaurais-pense-faire-ca

38

oui et? c'est prévu dans les règles...
avatar
fabetal_ > Hier, je me suis fait monter par un pote
redangel > et en chevals, ça donne quoi?
Nil> OMG I think I'm gay

39

//gcc -std=c99 -O2 -W cccs.c -lSDL -o cccs && ./cccs 
#include <stdio.h>   
#include <stdlib.h>   
#include <stdint.h>   
#include <SDL/SDL.h>   
#include <math.h>   
   
typedef struct{   
    unsigned int uWidth;   
    unsigned int uHeight;   
    SDL_Surface *pData;   
} SBitMapFont;   
   
SBitMapFont* LoadBitMapFontFromFile(char *pFileName)   
{   
    SBitMapFont* pReturn = NULL;   
    SDL_Surface *pTmpSurface;   
   
    if((pTmpSurface = SDL_LoadBMP(pFileName))   
	    && !(pReturn  = malloc(sizeof(SBitMapFont))))   
    {   
	pReturn->uWidth  = (unsigned int)pTmpSurface->w/255;   
	pReturn->uHeight = (unsigned int)pTmpSurface->h;   
	pReturn->pData   = pTmpSurface;   
    }   
    else   
	fprintf(stderr,"[Erreur ::LoadFontFromFile] : Can't load %s\n",pFileName);   
    return pReturn;   
}   
   
/* amusons nous à dessiner avec les nombres premiers! */   
uint8_t isprime(uint32_t n) {   
    for (uint32_t d=2;d*d<=n;d++)   
	if(!(n%d))   
	    return 0;   
    return 42;   
}   
   
   
/* oui c'est moche et lent */   
void addPixelSat(SDL_Surface *s, int x, int y, Uint32 c) {   
    Uint32 cc = *((Uint32*)(s->pixels) + x + y * s->w);   
    Uint16 nr = ((c >> 16) & 255)+((cc >> 16) & 255);   
    Uint16 ng = ((c >> 8) & 255)+((cc >> 8) & 255);   
    Uint16 nb = (c & 255)+(cc & 255);   
    if (nr > 255) nr = 255;   
    if (ng > 255) ng = 255;   
    if (nb > 255) nb = 255;   
    *((Uint32*)(s->pixels) + x + y * s->w) = (nr<<16)|(ng<<8)|nb | 0xFF000000;   
} 
  
 
void line (SDL_Surface *s, float x1, float y1, float x2, float y2, Uint32 c) {   
    double hl=fabs(x2-x1), vl=fabs(y2-y1), length=(hl>vl)?hl:vl;   
    float deltax=(x2-x1)/(float)length, deltay=(y2-y1)/(float)length;   
    for (int i=0; i<(int)length; i++) 
      addPixelSat(s, (int)(x1+=deltax), (int)(y1+=deltay), c); 
} 
   
   
char *lipsum =   
"Lorem ipsum dolor sit amet, consectetuer adipiscing elit "   
"Aenean volutpat lorem ut enim. Cras accumsan porta augue "   
"Nulla quis magna. Morbi at dolor. Vivamus quam. Fusce feugiat egestas elit "   
"Nullam tincidunt. Donec et felis "   
"Fusce purus dui, semper vitae, tincidunt nec, malesuada id, purus "   
"Lorem ipsum dolor sit amet, consectetuer adipiscing elit "   
"Etiam a risus nec tellus ultrices tempor. Nunc mauris velit, euismod vitae, hendrerit et, auctor eget, odio "   
"Praesent dapibus nulla. Nunc et nulla   "   
"Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec lobortis rhoncus tortor   "   
;   
   
int font[26][11]={{7,24,36,66,126,66,66,66,0,0,0},{8,240,136,136,252,130,130,252,0,0,0},{8,28,98,128,128,128,64,62,0,0,0},   
    {8,240,136,132,130,130,130,252,0,0,0},{8,252,128,128,240,128,128,254,0,0,0},{6,62,32,32,60,32,32,32,0,0,0},   
    {8,60,66,128,142,130,66,60,0,0,0},{7,66,66,66,126,66,66,66,0,0,0},{2,2,2,2,2,2,2,2,0,0,0},{5,2,2,2,2,18,18,12,0,0,0},   
    {7,66,68,72,80,104,68,66,0,0,0},{5,16,16,16,16,16,16,30,0,0,0},{8,130,198,170,146,130,130,130,0,0,0},   
    {6,34,34,50,42,38,34,34,0,0,0},{7,24,36,66,66,66,66,60,0,0,0},{6,56,36,34,60,32,32,32,0,0,0},   
    {8,48,72,132,132,148,140,118,0,0,0},{7,112,72,68,120,72,68,66,0,0,0},{6,14,16,32,28,2,4,56,0,0,0},   
    {6,62,8,8,8,8,8,8,0,0,0},{5,18,18,18,18,18,18,12,0,0,0},{8,130,130,68,68,40,40,16,0,0,0},   
    {8,130,130,130,146,146,146,108,0,0,0},{8,130,68,40,16,40,68,130,0,0,0},{6,34,34,20,20,8,8,16,0,0,0},   
    {8,254,4,8,16,32,64,252,0,0,0}};   
   
#define mulRGB_tmp(k,x,n) ((128+(((x)>>n)&255)*(k))>>8)<<n   
inline uint32_t mulRGB(int k,uint32_t x) { return mulRGB_tmp(k,x,16) | mulRGB_tmp(k,x,8) | mulRGB_tmp(k,x,0); }   
   
int main(int argc,char *argv[]){   
    SDL_Surface *screen;   
    SDL_Event event;   
    if(SDL_Init(SDL_INIT_VIDEO) == -1)   
	exit(1);   
    atexit(SDL_Quit);   
    screen = SDL_SetVideoMode(640, 480, 32, SDL_SWSURFACE);   
    if (screen == NULL)   
	exit(1);   
    SDL_WM_SetCaption("Enjoy !", NULL);   
    SDL_FillRect(screen, &(SDL_Rect){0,0,640,480}, 0xFF000000);   
   
    /* youpi, ça bouge! */   
    double la = 0.1, lb = 0.1; 
    for (uint32_t n=0,z=160+320*120,c=0x123456; !SDL_PollEvent(&event)   
	    || event.type!=SDL_QUIT; n+=64*48,c=(c*189+123)%0xFF7821,z=c/21<320*240?c/21:z) {   

	uint32_t *pix = (uint32_t *)screen->pixels; 
	    
	/* Effet spacy */
	for (uint32_t y=1;y<480;y++)
		for(uint32_t x=1;x<640;x++)
		{
			uint32_t val,r,g,b,rd = rand()%10;
			val = pix[y+x*480]; r = (val >> 16) & 0xFF; g = (val >> 8) & 0xFF; b = val & 0xFF; 
			r ^= 0x55; g |= 0x1A; b &= 0xA3;
			r -= (r>10)?rd:0; g -= (g>10)?rd:0; b -= (b>10)?rd:0;
			pix[y+x*480] = ((((((0xFF << 8) | r) << 8) | g) << 8) | b);
		}    
	    
	for (uint32_t x=0; x<64*48; x++)   
	    if (isprime(x+n)) {   
		SDL_Rect r={z%320+x%64*5,z/320+x/64*5,5,5};   
		SDL_FillRect(screen, &r, c | 0xFF000000);   
	    }   
   
	/* il est flou afflelou */     
	int pp[] = {1,640*480-1,640,640*480-640,1,640*480-1,640,640*480-640,0};   
	for (int *p = pp; *p; p++) {   
	    uint32_t x=0,y=*p;   
	    for (; y<640*480; x++,y++)   
		pix[x] = pix[x]-((pix[x]>>4)&0x0F0F0F)+((pix[y]>>4)&0x0F0F0F);   
	    for (y=0; x<640*480; x++,y++)   
		pix[x] = pix[x]-((pix[x]>>4)&0x0F0F0F)+((pix[y]>>4)&0x0F0F0F);   
	} 
 
	for(int slop = 0;slop < 10;slop++) { 
	  line(screen, 320+sin(lb)*120-sin(la)*60, 
	       240+cos(lb)*120-cos(la)*60, 
	       320+sin(lb)*120+sin(la)*60, 
	       240+cos(lb)*120+cos(la)*60,0xFF00FF00);   
	  la += 0.05; 
	} 
	lb += 0.203; 
   
	static int tpos = 0;   
	for (Uint16 l = 0; l < tpos; l++) {   
	    char huhu = lipsum[l];   
	    if ((huhu = (huhu > 'Z') ? (huhu - 'a') : (huhu - 'A')) != ' '-'A')   
	       for (Uint16 y = 1; y < 10; y++)   
		   for (Uint16 x = 0; x < 8; x++)   
		       if (font[huhu][y]&(1<<(7-x)))   
			   addPixelSat(screen,  160 + (x+((l * 8)))%320,   
				   120 + (y + ((l * 8) / 320) * 10)%240, 0xffffff);   
	} 
	if(lipsum[++tpos] == 0) tpos = 0;   

	static float xs = 0.0, ys = 0.0;   
	xs+=0.1; ys+=sqrt(0.005);  
	line(screen, sin(xs)*320+320, cos(ys)*240+240, cos(xs)*320+320, sin(ys)*240+240,rand());   
	SDL_Flip(screen); 
	SDL_Delay(20);   
    }   
   
    return 0;   
}  

C'est pas du tout ce que je voulais faire mais bon tant pis ^^
avatar
Proud to be CAKE©®™


GCC4TI importe qui a problème en Autriche, pour l'UE plus et une encore de correspours nucléaire, ce n'est pas ytre d'instérier. L'état très même contraire, toujours reconstruire un pouvoir une choyer d'aucrée de compris le plus mite de genre, ce n'est pas moins)
Stalin est l'élection de la langie.

40

//gcc -std=c99 -O2 -W cccs.c -lSDL -o cccs && ./cccs 
#include <stdio.h>   
#include <stdlib.h>   
#include <stdint.h>   
#include <SDL/SDL.h>   
#include <math.h>   
   
typedef struct{   
    unsigned int uWidth;   
    unsigned int uHeight;   
    SDL_Surface *pData;   
} SBitMapFont;   
   
SBitMapFont* LoadBitMapFontFromFile(char *pFileName)   
{   
    SBitMapFont* pReturn = NULL;   
    SDL_Surface *pTmpSurface;   
   
    if((pTmpSurface = SDL_LoadBMP(pFileName))   
	    && !(pReturn  = malloc(sizeof(SBitMapFont))))   
    {   
	pReturn->uWidth  = (unsigned int)pTmpSurface->w/255;   
	pReturn->uHeight = (unsigned int)pTmpSurface->h;   
	pReturn->pData   = pTmpSurface;   
    }   
    else   
	fprintf(stderr,"[Erreur ::LoadFontFromFile] : Can't load %s\n",pFileName);   
    return pReturn;   
}   
   
/* amusons nous à dessiner avec les nombres premiers! */   
uint8_t isprime(uint32_t n) {   
    for (uint32_t d=2;d*d<=n;d++)   
	if(!(n%d))   
	    return 0;   
    return 42;   
}   

/* C'est à peu près la seule chose que je sais faire en C, à vous de l'utiliser intelligemment :p */
int mccarthy(unsigned int n) {
    if (n <= 100) {
        return mccarthy(mccarthy(n+11));
    } else {
        return n - 10;
    }
}
   
/* oui c'est moche et lent */   
void addPixelSat(SDL_Surface *s, int x, int y, Uint32 c) {   
    Uint32 cc = *((Uint32*)(s->pixels) + x + y * s->w);   
    Uint16 nr = ((c >> 16) & 255)+((cc >> 16) & 255);   
    Uint16 ng = ((c >> 8) & 255)+((cc >> 8) & 255);   
    Uint16 nb = (c & 255)+(cc & 255);   
    if (nr > 255) nr = 255;   
    if (ng > 255) ng = 255;   
    if (nb > 255) nb = 255;   
    *((Uint32*)(s->pixels) + x + y * s->w) = (nr<<16)|(ng<<8)|nb | 0xFF000000;   
} 
  
 
void line (SDL_Surface *s, float x1, float y1, float x2, float y2, Uint32 c) {   
    double hl=fabs(x2-x1), vl=fabs(y2-y1), length=(hl>vl)?hl:vl;   
    float deltax=(x2-x1)/(float)length, deltay=(y2-y1)/(float)length;   
    for (int i=0; i<(int)length; i++) 
      addPixelSat(s, (int)(x1+=deltax), (int)(y1+=deltay), c); 
} 
   
   
char *lipsum =   
"Lorem ipsum dolor sit amet, consectetuer adipiscing elit "   
"Aenean volutpat lorem ut enim. Cras accumsan porta augue "   
"Nulla quis magna. Morbi at dolor. Vivamus quam. Fusce feugiat egestas elit "   
"Nullam tincidunt. Donec et felis "   
"Fusce purus dui, semper vitae, tincidunt nec, malesuada id, purus "   
"Lorem ipsum dolor sit amet, consectetuer adipiscing elit "   
"Etiam a risus nec tellus ultrices tempor. Nunc mauris velit, euismod vitae, hendrerit et, auctor eget, odio "   
"Praesent dapibus nulla. Nunc et nulla   "   
"Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec lobortis rhoncus tortor   "   
;   
   
int font[26][11]={{7,24,36,66,126,66,66,66,0,0,0},{8,240,136,136,252,130,130,252,0,0,0},{8,28,98,128,128,128,64,62,0,0,0},   
    {8,240,136,132,130,130,130,252,0,0,0},{8,252,128,128,240,128,128,254,0,0,0},{6,62,32,32,60,32,32,32,0,0,0},   
    {8,60,66,128,142,130,66,60,0,0,0},{7,66,66,66,126,66,66,66,0,0,0},{2,2,2,2,2,2,2,2,0,0,0},{5,2,2,2,2,18,18,12,0,0,0},   
    {7,66,68,72,80,104,68,66,0,0,0},{5,16,16,16,16,16,16,30,0,0,0},{8,130,198,170,146,130,130,130,0,0,0},   
    {6,34,34,50,42,38,34,34,0,0,0},{7,24,36,66,66,66,66,60,0,0,0},{6,56,36,34,60,32,32,32,0,0,0},   
    {8,48,72,132,132,148,140,118,0,0,0},{7,112,72,68,120,72,68,66,0,0,0},{6,14,16,32,28,2,4,56,0,0,0},   
    {6,62,8,8,8,8,8,8,0,0,0},{5,18,18,18,18,18,18,12,0,0,0},{8,130,130,68,68,40,40,16,0,0,0},   
    {8,130,130,130,146,146,146,108,0,0,0},{8,130,68,40,16,40,68,130,0,0,0},{6,34,34,20,20,8,8,16,0,0,0},   
    {8,254,4,8,16,32,64,252,0,0,0}};   
   
#define mulRGB_tmp(k,x,n) ((128+(((x)>>n)&255)*(k))>>8)<<n   
inline uint32_t mulRGB(int k,uint32_t x) { return mulRGB_tmp(k,x,16) | mulRGB_tmp(k,x,8) | mulRGB_tmp(k,x,0); }   
   
int main(int argc,char *argv[]){   
    SDL_Surface *screen;   
    SDL_Event event;   
    if(SDL_Init(SDL_INIT_VIDEO) == -1)   
	exit(1);   
    atexit(SDL_Quit);   
    screen = SDL_SetVideoMode(640, 480, 32, SDL_SWSURFACE);   
    if (screen == NULL)   
	exit(1);   
    SDL_WM_SetCaption("Enjoy !", NULL);   
    SDL_FillRect(screen, &(SDL_Rect){0,0,640,480}, 0xFF000000);   
   
    /* youpi, ça bouge! */   
    double la = 0.1, lb = 0.1; 
    for (uint32_t n=0,z=160+320*120,c=0x123456; !SDL_PollEvent(&event)   
	    || event.type!=SDL_QUIT; n+=64*48,c=(c*189+123)%0xFF7821,z=c/21<320*240?c/21:z) {   

	uint32_t *pix = (uint32_t *)screen->pixels; 
	    
	/* Effet spacy */
	for (uint32_t y=1;y<480;y++)
		for(uint32_t x=1;x<640;x++)
		{
			uint32_t val,r,g,b,rd = rand()%10;
			val = pix[y+x*480]; r = (val >> 16) & 0xFF; g = (val >> 8) & 0xFF; b = val & 0xFF; 
			r ^= 0x55; g |= 0x1A; b &= 0xA3;
			r -= (r>10)?rd:0; g -= (g>10)?rd:0; b -= (b>10)?rd:0;
			pix[y+x*480] = ((((((0xFF << 8) | r) << 8) | g) << 8) | b);
		}    
	    
	for (uint32_t x=0; x<64*48; x++)   
	    if (isprime(x+n)) {   
		SDL_Rect r={z%320+x%64*5,z/320+x/64*5,5,5};   
		SDL_FillRect(screen, &r, c | 0xFF000000);   
	    }   
   
	/* il est flou afflelou */     
	int pp[] = {1,640*480-1,640,640*480-640,1,640*480-1,640,640*480-640,0};   
	for (int *p = pp; *p; p++) {   
	    uint32_t x=0,y=*p;   
	    for (; y<640*480; x++,y++)   
		pix[x] = pix[x]-((pix[x]>>4)&0x0F0F0F)+((pix[y]>>4)&0x0F0F0F);   
	    for (y=0; x<640*480; x++,y++)   
		pix[x] = pix[x]-((pix[x]>>4)&0x0F0F0F)+((pix[y]>>4)&0x0F0F0F);   
	} 
 
	for(int slop = 0;slop < 10;slop++) { 
	  line(screen, 320+sin(lb)*120-sin(la)*60, 
	       240+cos(lb)*120-cos(la)*60, 
	       320+sin(lb)*120+sin(la)*60, 
	       240+cos(lb)*120+cos(la)*60,0xFF00FF00);   
	  la += 0.05; 
	} 
	lb += 0.203; 
   
	static int tpos = 0;   
	for (Uint16 l = 0; l < tpos; l++) {   
	    char huhu = lipsum[l];   
	    if ((huhu = (huhu > 'Z') ? (huhu - 'a') : (huhu - 'A')) != ' '-'A')   
	       for (Uint16 y = 1; y < 10; y++)   
		   for (Uint16 x = 0; x < 8; x++)   
		       if (font[huhu][y]&(1<<(7-x)))   
			   addPixelSat(screen,  160 + (x+((l * 8)))%320,   
				   120 + (y + ((l * 8) / 320) * 10)%240, 0xffffff);   
	} 
	if(lipsum[++tpos] == 0) tpos = 0;   

	static float xs = 0.0, ys = 0.0;   
	xs+=0.1; ys+=sqrt(0.005);  
	line(screen, sin(xs)*320+320, cos(ys)*240+240, cos(xs)*320+320, sin(ys)*240+240,rand());   
	SDL_Flip(screen); 
	SDL_Delay(20);   
    }   
   
    return 0;   
}  

avatar
I'm on a boat motherfucker, don't you ever forget

41

Edited_3064

42

s/f/mccarthy/g

« The biggest civil liberty of all is not to be killed by a terrorist. » (Geoff Hoon, ministre des transports anglais)

43

//gcc -std=c99 -O2 -W cccs.c -lSDL -o cccs && ./cccs 
#include <stdio.h>   
#include <stdlib.h>   
#include <stdint.h>   
#include <SDL/SDL.h>   
#include <math.h>   
   
typedef struct{   
    unsigned int uWidth;   
    unsigned int uHeight;   
    SDL_Surface *pData;   
} SBitMapFont;   
   
SBitMapFont* LoadBitMapFontFromFile(char *pFileName)   
{   
    SBitMapFont* pReturn = NULL;   
    SDL_Surface *pTmpSurface;   
   
    if((pTmpSurface = SDL_LoadBMP(pFileName))   
	    && !(pReturn  = malloc(sizeof(SBitMapFont))))   
    {   
	pReturn->uWidth  = (unsigned int)pTmpSurface->w/255;   
	pReturn->uHeight = (unsigned int)pTmpSurface->h;   
	pReturn->pData   = pTmpSurface;   
    }   
    else   
	fprintf(stderr,"[Erreur ::LoadFontFromFile] : Can't load %s\n",pFileName);   
    return pReturn;   
}   
   
/* amusons nous à dessiner avec les nombres premiers! */   
uint8_t isprime(uint32_t n) {   
    for (uint32_t d=2;d*d<=n;d++)   
	if(!(n%d))   
	    return 0;   
    return 42;   
}   
/* tiens Orion, que tu comprennes bien ce qu'est la complexité =) */
unsigned long ack(unsigned long x, unsigned long y) {
  return (x>0)?ack(x-1,(y>0)?ack(x,y-1):1):y+1;
}

/* C'est à peu près la seule chose que je sais faire en C, à vous de l'utiliser intelligemment :p */
int mccarthy(unsigned int n) {
    if (n <= 100) {
        return mccarthy(mccarthy(n+11));
    } else {
        return n - 10;
    }
}
   
/* oui c'est moche et lent */   
void addPixelSat(SDL_Surface *s, int x, int y, Uint32 c) {   
    Uint32 cc = *((Uint32*)(s->pixels) + x + y * s->w);   
    Uint16 nr = ((c >> 16) & 255)+((cc >> 16) & 255);   
    Uint16 ng = ((c >> 8) & 255)+((cc >> 8) & 255);   
    Uint16 nb = (c & 255)+(cc & 255);   
    if (nr > 255) nr = 255;   
    if (ng > 255) ng = 255;   
    if (nb > 255) nb = 255;   
    *((Uint32*)(s->pixels) + x + y * s->w) = (nr<<16)|(ng<<8)|nb | 0xFF000000;   
} 
  
 
void line (SDL_Surface *s, float x1, float y1, float x2, float y2, Uint32 c) {   
    double hl=fabs(x2-x1), vl=fabs(y2-y1), length=(hl>vl)?hl:vl;   
    float deltax=(x2-x1)/(float)length, deltay=(y2-y1)/(float)length;   
    for (int i=0; i<(int)length; i++) 
      addPixelSat(s, (int)(x1+=deltax), (int)(y1+=deltay), c); 
} 
   
   
char *lipsum =   
"Lorem ipsum dolor sit amet, consectetuer adipiscing elit "   
"Aenean volutpat lorem ut enim. Cras accumsan porta augue "   
"Nulla quis magna. Morbi at dolor. Vivamus quam. Fusce feugiat egestas elit "   
"Nullam tincidunt. Donec et felis "   
"Fusce purus dui, semper vitae, tincidunt nec, malesuada id, purus "   
"Lorem ipsum dolor sit amet, consectetuer adipiscing elit "   
"Etiam a risus nec tellus ultrices tempor. Nunc mauris velit, euismod vitae, hendrerit et, auctor eget, odio "   
"Praesent dapibus nulla. Nunc et nulla   "   
"Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec lobortis rhoncus tortor   "   
;   
   
int font[26][11]={{7,24,36,66,126,66,66,66,0,0,0},{8,240,136,136,252,130,130,252,0,0,0},{8,28,98,128,128,128,64,62,0,0,0},   
    {8,240,136,132,130,130,130,252,0,0,0},{8,252,128,128,240,128,128,254,0,0,0},{6,62,32,32,60,32,32,32,0,0,0},   
    {8,60,66,128,142,130,66,60,0,0,0},{7,66,66,66,126,66,66,66,0,0,0},{2,2,2,2,2,2,2,2,0,0,0},{5,2,2,2,2,18,18,12,0,0,0},   
    {7,66,68,72,80,104,68,66,0,0,0},{5,16,16,16,16,16,16,30,0,0,0},{8,130,198,170,146,130,130,130,0,0,0},   
    {6,34,34,50,42,38,34,34,0,0,0},{7,24,36,66,66,66,66,60,0,0,0},{6,56,36,34,60,32,32,32,0,0,0},   
    {8,48,72,132,132,148,140,118,0,0,0},{7,112,72,68,120,72,68,66,0,0,0},{6,14,16,32,28,2,4,56,0,0,0},   
    {6,62,8,8,8,8,8,8,0,0,0},{5,18,18,18,18,18,18,12,0,0,0},{8,130,130,68,68,40,40,16,0,0,0},   
    {8,130,130,130,146,146,146,108,0,0,0},{8,130,68,40,16,40,68,130,0,0,0},{6,34,34,20,20,8,8,16,0,0,0},   
    {8,254,4,8,16,32,64,252,0,0,0}};   
   
#define mulRGB_tmp(k,x,n) ((128+(((x)>>n)&255)*(k))>>8)<<n   
inline uint32_t mulRGB(int k,uint32_t x) { return mulRGB_tmp(k,x,16) | mulRGB_tmp(k,x,8) | mulRGB_tmp(k,x,0); }   
   
int main(int argc,char *argv[]){   
    SDL_Surface *screen;   
    SDL_Event event;   
    if(SDL_Init(SDL_INIT_VIDEO) == -1)   
	exit(1);   
    atexit(SDL_Quit);   
    screen = SDL_SetVideoMode(640, 480, 32, SDL_SWSURFACE);   
    if (screen == NULL)   
	exit(1);   
    SDL_WM_SetCaption("Enjoy !", NULL);   
    SDL_FillRect(screen, &(SDL_Rect){0,0,640,480}, 0xFF000000);   
   
    /* youpi, ça bouge! */   
    double la = 0.1, lb = 0.1; 
    for (uint32_t n=0,z=160+320*120,c=0x123456; !SDL_PollEvent(&event)   
	    || event.type!=SDL_QUIT; n+=64*48,c=(c*189+123)%0xFF7821,z=c/21<320*240?c/21:z) {   

	uint32_t *pix = (uint32_t *)screen->pixels; 
	    
	/* Effet spacy */
	for (uint32_t y=1;y<480;y++)
		for(uint32_t x=1;x<640;x++)
		{
			uint32_t val,r,g,b,rd = rand()%10;
			val = pix[y+x*480]; r = (val >> 16) & 0xFF; g = (val >> 8) & 0xFF; b = val & 0xFF; 
			r ^= 0x55; g |= 0x1A; b &= 0xA3;
			r -= (r>10)?rd:0; g -= (g>10)?rd:0; b -= (b>10)?rd:0;
			pix[y+x*480] = ((((((0xFF << 8) | r) << 8) | g) << 8) | b);
		}    
	    
	for (uint32_t x=0; x<64*48; x++)   
	    if (isprime(x+n)) {   
		SDL_Rect r={z%320+x%64*5,z/320+x/64*5,5,5};   
		SDL_FillRect(screen, &r, c | 0xFF000000);   
	    }   
   
	/* il est flou afflelou */     
	int pp[] = {1,640*480-1,640,640*480-640,1,640*480-1,640,640*480-640,0};   
	for (int *p = pp; *p; p++) {   
	    uint32_t x=0,y=*p;   
	    for (; y<640*480; x++,y++)   
		pix[x] = pix[x]-((pix[x]>>4)&0x0F0F0F)+((pix[y]>>4)&0x0F0F0F);   
	    for (y=0; x<640*480; x++,y++)   
		pix[x] = pix[x]-((pix[x]>>4)&0x0F0F0F)+((pix[y]>>4)&0x0F0F0F);   
	} 
 
	for(int slop = 0;slop < 10;slop++) { 
	  line(screen, 320+sin(lb)*120-sin(la)*60, 
	       240+cos(lb)*120-cos(la)*60, 
	       320+sin(lb)*120+sin(la)*60, 
	       240+cos(lb)*120+cos(la)*60,0xFF00FF00);   
	  la += 0.05; 
	} 
	lb += 0.203; 
   
	static int tpos = 0;   
	for (Uint16 l = 0; l < tpos; l++) {   
	    char huhu = lipsum[l];   
	    if ((huhu = (huhu > 'Z') ? (huhu - 'a') : (huhu - 'A')) != ' '-'A')   
	       for (Uint16 y = 1; y < 10; y++)   
		   for (Uint16 x = 0; x < 8; x++)   
		       if (font[huhu][y]&(1<<(7-x)))   
			   addPixelSat(screen,  160 + (x+((l * 8)))%320,   
				   120 + (y + ((l * 8) / 320) * 10)%240, 0xffffff);   
	} 
	if(lipsum[++tpos] == 0) tpos = 0;   

	static float xs = 0.0, ys = 0.0;   
	xs+=0.1; ys+=sqrt(0.005);  
	line(screen, sin(xs)*320+320, cos(ys)*240+240, cos(xs)*320+320, sin(ys)*240+240,rand());   
	SDL_Flip(screen); 
	SDL_Delay(20);   
    }   
   
    return 0;   
}  

avatar
fabetal_ > Hier, je me suis fait monter par un pote
redangel > et en chevals, ça donne quoi?
Nil> OMG I think I'm gay