All pastes #838466 Raw Edit

tonkman

public cpp v1 · immutable
#838466 ·published 2007-12-30 11:36 UTC
rendered paste body
#include<SDL/SDL.h>#include<SDL/SDL_opengl.h>#include<math.h>#include<time.h>SDL_Surface *naytto;double poten(double luku,int exp){	double kluku=luku;	for(int i=0;i<exp-1;i++){		luku = luku*kluku;	}	return luku;}int main(int argc, char **argv){	naytto = SDL_SetVideoMode(600,400,32,SDL_OPENGL|SDL_DOUBLEBUF);	srand(time(NULL));	int met = glGenLists(1);	glNewList(met, GL_COMPILE);	glBegin(GL_POINTS);	for(int a=1;a<35;a++){		for(double i=0;i<100;i+=0.1){			glColor3f(0,0,100/poten(a,2));			glVertex2f(cos(i)*a,sin(i)*a);		}	}	glEnd();	glEndList();	int met2 = glGenLists(1);	glNewList(met2, GL_COMPILE);	glBegin(GL_POINTS);	glColor3f(1,0,0);	for(int a=1;a<5;a++){		for(double i=0;i<50;i+=0.1){			glVertex2f(cos(i)*a,sin(i)*a);		}	}	glEnd();	glEndList();	double sx = 0;	double sy = 0;			SDL_Event e;	bool paalla=true;	while(paalla){		while(SDL_PollEvent(&e)){			if(e.type == SDL_QUIT) paalla = false;		}		glClear(GL_COLOR_BUFFER_BIT);		glLoadIdentity();		glOrtho(-300,300,200,-200,-0.5,0);		glTranslatef(cos(sx/14)*100,sin(sy/14)*100,0);				glCallList(met);				glTranslatef(cos(sx/16)*5,sin(sy/16)*10,0);		glCallList(met2);		glTranslatef(cos(sx/16)*10,sin(sy/16)*10,0);		glCallList(met2);		glTranslatef(cos(sx/16)*5,sin(sy/16)*20,0);		glCallList(met2);		glTranslatef(cos(sx/16)*10,sin(sy/16)*40,0);		glCallList(met2);		SDL_GL_SwapBuffers();		SDL_Delay(20);		sx++;		sy++;	}	SDL_Quit();return 0;}