Professional Documents
Culture Documents
#include "introGlutLib.h"
#include <time.h>
#include <stdlib.h>
/*
* pickRandomRGB() generates a random color value
*/
/* =================================Main:=======================================
* Seed the random number generator with the time before
* starting the graphics loop.
*/
int main()
{
srand(time(NULL));
InitGraphics();
// start GLUT/OpenGL
return 0;
}
/***************************************************************
myDisplay()
void myDisplay(void)
{
static int first_time = 1;
if (first_time) {
unsigned long color = pickRandomRGB();
int x = rand() % 300;
int y = rand() % 200;
int w = rand() % 400 + 50;
int h = rand() % 200 + 50;
ClearWindow();
SetPenColorHex(color);
DrawFillBox(x, y, x + w, y + h);
first_time = 0;
}
}
/**********************************************************************
myMouse(button, state, x, y)
/**********************************************************************
myKeyboard(key, x, y)
/**********************************************************************
mySpecialKey(key, x, y)
/**********************************************************************
pickRandomRGB()
***********************************************************************/