Answered step by step
Verified Expert Solution
Question
1 Approved Answer
i want a code with openGL C + + that has a sphere that looks like the sun and a sky with changing colors using
i want a code with openGL C that has a sphere that looks like the sun and a sky with changing colors using a menu and square buildings and a sea in front of the buildings with weaves and ships that move forward when u click and restart when u click using this empty code
#include
void initvoid
glClearColor;
glEnableGLDEPTHTEST;
glMatrixModeGLPROJECTION;
glLoadIdentity;
glOrtho;
glMatrixModeGLMODELVIEW;
glLoadIdentity;
void sea
void land
void sky
void movingObjects
void drawvoid
glClearGLCOLORBUFFERBIT GLDEPTHBUFFERBIT;
sky;
land;
sea;
movingObjects;
glutSwapBuffers;
void animationvoid
glutPostRedisplay;
void processNormalKeysunsigned char key, int x int y
switch key
case S:
case s:
break;
case O:
case o:
break;
void menuint ms
switch ms
case :
break;
case :
break;
case :
break;
case :
break;
glutPostRedisplay;
void setUpMenuvoid
int mainint argc, char argv
glutInit&argc, argv;
glutInitDisplayModeGLUTDOUBLE GLUTRGB GLUTDEPTH;
glutInitWindowPosition;
glutInitWindowSize;
glutCreateWindowYour Name ID; Rename the window
glutDisplayFuncdraw;
glutKeyboardFuncprocessNormalKeys;
setUpMenu;
init;
glutMainLoop;
return ;
satisfying these requirements
D Scene
You are required to draw the D scene shown in Figure and you must add your own object eg
additional ship, airplane, clouds, etc.
You can print Figure on a graph paper similar to Figure to help you determine the required
coordinates and then start programming.
Feel free to change the drawing colors, see the RGB color.pdf for more colors.
Use the builtin function glutSolidSphereradius slices, stacks to draw the sun.
Name the drawing window with Your Name ID
Use the source file CPITAssignmentcpp as a starting point for drawing
Menu & Submenu
You are required to create one main menu with one submenu as shown in Figure
When the user opens the submenu Sky Color and selects any of its colors, then the sky color
must change according to the chosen color.
When the user selects Exit then the program must terminate.
The main menu must be opened when the right mouse button is clicked.
Keyboard Interaction & Transformation
If the key S or s is pressed, then your program must create a continues movement for both
ships, see Figure :
The big ship moves towards the negative x axis.
The small ship moves towards the positive x axis.
If the key O or o is pressed, then both ships must restart the movement from the original
position.
Code
Your code must be well written, organized, and documented ie write comments to show the
purpose of each partFigure Menu and submenu.
Figure Keyboard interaction & transformation.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started