Thursday, April 12, 2007

Pvc Potato Gun For Sale

6

/ / According to the numbering would be reporting this practice 5
/ / Program drawing lines, triangles, and tables, clean the window every 30 seconds

# include string.h # include GL / glut.h
# include windows.h # include stdarg.h


# # include stdio.h

include malloc.h
void paint (void);
int option;
float r, b, g;
float x1, y1, z1;
char string [] = "00:00:00";
x0 = 24;
option = 1;

void init (void) {

glClear (GL_COLOR_BUFFER_BIT);}


void paint (void) {int

xe, ze,
float x2, y2;

if (option == 1) {


if (r> = 1 b> = 1 g> = 1) {
r = 0;
b = 0;
g = 0;}


r = r + .1;
b = b + .2;
g = g + .3;
glColor3f (r, b, g);
x1 = rand ()% 500;
Y1 = rand ()% 500;
z1 = rand ()% 500;
glBegin (GL_LINES);
glVertex3f (x1, Y1, 0);
x1 = rand ()% 500 ;
Y1 = rand ()% 500;
z1 = rand ()% 500;
glVertex3f (x1, Y1, 0);
glEnd ();}


if (opcion == 3) {

if ( r> = 1 b> = 1 g> = 1) {
r = 0;
b = 0;
g = 0;

}
r = r + .3;
b = b + .1;
g = g + .2;
glColor3f (r, b, g);
Y1 = rand ()% 12;
z1 = rand ()% 12;
x2 = rand ()% 500;
Y2 = rand ()% 500;

glPushMatrix ();
glTranslatef (x2, Y2, 0 );
glScalef (z1, Y1, 0);

glBegin (GL_LINES);
glVertex3f (10,2,0);
glVertex3f (20,2,0);
glEnd ();

glBegin (GL_LINES) ;
glVertex3f (10,2,0);
glVertex3f (10,12,0);
glEnd ();

glBegin (GL_LINES);
glVertex3f (20,2,0);
glVertex3f (20.12, 0);
glEnd ();

glBegin (GL_LINES);
glVertex3f (10,12,0);
glVertex3f (20,12,0);
glEnd ();
glPopMatrix ();}


if (opcion == 2) {

if (r> = 1 b> = 1 g> = 1) {
r = 0;
b = 0;
g = 0;}


r = r + .2;
b = b + .3;
g = g + .1;
glColor3f (r, b, g);
x1 = rand ()% 15;
Y1 = rand ()% 15;
x2 = rand ()% 500;
Y2 = rand ()% 500;
glPushMatrix ();
glTranslatef (x2, Y2, 0);
glScalef (x1, Y1, 0);
glBegin (GL_LINES);
glVertex3f (-10,1,0);
glVertex3f (10,1,0);
glEnd ();

glBegin (GL_LINES);
glVertex3f (0,20,0);
glVertex3f (-10,1,0);
glEnd ();

glBegin (GL_LINES);
glVertex3f (0,20,0);
glVertex3f (10,1,0);
glEnd ();

glPopMatrix ();}



} void display (void) {

surface ();
glFlush ();}


void reshape (int w, int h) {

glViewport (0, 0, w , h);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gluOrtho2D (0, w, h, 0);
glMatrixMode (GL_MODELVIEW);}

/ / MANEJO DEL RETARDO
TimerFunction void () {

glutPostRedisplay ();
glutTimerFunc (3000, TimerFunction, 1);
}
void TimerFunction2()
{
glutPostRedisplay();
glClear(GL_COLOR_BUFFER_BIT);
glutTimerFunc(30000, TimerFunction2, 2);

}


//ACCIONES DEL MOUSE
void onMouse(int button, int state, int x, int y) {

if ( (button == GLUT_RIGHT_BUTTON) & (state == GLUT_DOWN) ) {
if(opcion==1)
opcion=1;
if(opcion==2)
opcion=1;
if(opcion==3)
opcion=2;
TimerFunction();
}

if ( (button == GLUT_LEFT_BUTTON) & (state == GLUT_DOWN) ) {
if(opcion==3)
opcion=3;
if(opcion==2)
opcion=3;
if(opcion==1)
opcion=2;
TimerFunction();
}
}



int main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE GLUT_RGB);
glutInitWindowSize(500, 500);
glutCreateWindow("Reporte Practica 6");
glClearColor(0.0, 0.0, 0.0, 1.0);
init ();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutMouseFunc(onMouse);
glutTimerFunc(3000, TimerFunction, 1);
glutTimerFunc(30000, TimerFunction2, 2);
glutMouseFunc(onMouse);
glutMainLoop ();
return 0;}

0 comments:

Post a Comment