Question: #include #include float x = 0 ; float y = 0 ; int ligt = 0 ; float red = 1 . 0 f ,
#include
#include
float x ;
float y ;
int ligt ;
float red f blue f green f;
void processSpecialKeysint key, int x int y;
void processSpecialKeysint key, int x int y
switch key
case GLUTKEYF:
red ;
green ;
blue ; break;
case GLUTKEYF:
red ;
green ;
blue ; break;
case GLUTKEYF:
red ;
green ;
blue ; break;
void Drow
glClearGLCOLORBUFFERBIT GLDEPTHBUFFERBIT;
glPushMatrix;
gluLookAtfffffffff;
glShadeModelGLSMOOTH;
glEnableGLLIGHTING;
glEnableGLLIGHT;
GLfloat position;
glLightfvGLLIGHT GLPOSITION, position;
glEnableGLCOLORMATERIAL;
glEnableGLLIGHTING;
glEnableGLLIGHT;
spaceship
glColorfred green, blue;
glColorf;
glPushMatrix;
glTranslatedx y;
glRotatef;
glScaled;
glutSolidSphere;
glPopMatrix;
glPushMatrix;
the moon
glColorf;
glTranslated;
glutSolidSphere;
glPopMatrix;
black circule in the moon
glPushMatrix;
glColorf;
glTranslated;
glutSolidSphere;
glPopMatrix;
glPushMatrix;
the earth
glColorf;
glTranslated;
glutSolidSphere;
glPopMatrix;
glPushMatrix;
glTranslatedx y;
glLineWidthf;
glBeginGLLINES;
glColorf;
glVertexf; Center of the circle
glVertexf; Point on the circle's circumference
glEnd;
glPopMatrix;
glPushMatrix;
glTranslatedx y;
glLineWidthf;
glBeginGLLINES;
glColorf;
glVertexf; Center of the circle
glVertexf; Point on the circle's circumference
glEnd;
glPopMatrix;
glPushMatrix;
glTranslatedx y;
glLineWidthf;
glBeginGLLINES;
glColorf;
glVertexf; Center of the circle
glVertexf; Point on the circle's circumference
glEnd;
glPopMatrix;
glColorffff;
glPointSizef; Set the point size for stars
glBeginGLPOINTS;
glColorf;
for int i ; i ; i
float rx floatrand; Random x coordinate within viewport
float ry floatrand; Random y coordinate within viewport
glVertexfrx ryf; Draw stars randomly in the background
glEnd;
circul around the space ship
glPushMatrix;
glColorf;
glTranslatedx y;
glRotatef;
glutSolidTorus;
glPopMatrix;
glPopMatrix;
glPopMatrix;
glDisableGLLIGHTING;
glDisableGLCOLORMATERIAL;
glDisableGLLIGHT;
moving the space ship
x ;
if x
x ;
y ;
if y
y ;
glutSwapBuffers;
glutSpecialFuncprocessSpecialKeys;
int main
glutInitDisplayModeGLUTDEPTH GLUTDOUBLE GLUTRGBA;
glutInitWindowPosition;
glutInitWindowSize;
glutCreateWindowproject;
glEnableGLDEPTHTEST;
glMatrixModeGLPROJECTION;
glLoadIdentity;
gluPerspectivef;
glMatrixModeGLMODELVIEW;
glLoadIdentity;
glutDisplayFuncDrow;
glClearColor;
glutIdleFuncDrow;
glutMainLoop;
I want to modify the code above by Adding gray spots on the moon to make it more realistic. Adding a green color to the blue ball to resemble planet Earth.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
