Answered step by step
Verified Expert Solution
Link Copied!

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 9 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 init(void)
{
glClearColor(1.0,1.0,1.0,0.0);
glEnable(GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0,400.0,0.0,500.0,-400,400);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
//-------------------------------------------------------------------
void sea(){
}
//-------------------------------------------------------------------
void land(){
}
//-------------------------------------------------------------------
void sky(){
}
//-------------------------------------------------------------------
void movingObjects(){
}
//-------------------------------------------------------------------
void draw(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
sky();
land();
sea();
movingObjects();
glutSwapBuffers();
}
//-------------------------------------------------------------------
void animation(void)
{
glutPostRedisplay();
}
//-------------------------------------------------------------------
void processNormalKeys(unsigned char key, int x, int y){
switch (key){
case 'S':
case 's':
break;
case 'O':
case 'o':
break;
}
}
//-------------------------------------------------------------------
void menu(int ms){
switch (ms){
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;
}
glutPostRedisplay();
}
void setUpMenu(void){
}
//-------------------------------------------------------------------
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowPosition(100,200);
glutInitWindowSize(320,320);
glutCreateWindow("Your Name - ID"); // Rename the window
glutDisplayFunc(draw);
glutKeyboardFunc(processNormalKeys);
setUpMenu();
init();
glutMainLoop();
return 0;
}
satisfying these requirements
3D Scene
You are required to draw the 3D scene shown in Figure 1,and you must add your own object (e.g.,
additional ship, airplane, clouds, etc.).
You can print Figure1 on a graph paper similar to Figure2 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 built-in function glutSolidSphere(radius, slices, stacks) to draw the sun.
Name the drawing window with Your Name - ID.
Use the source file (CPIT285-Assignment_2024.cpp) as a starting point for drawing
Menu & Submenu
You are required to create one main menu with one submenu as shown in Figure 3.
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 4:
1) The big ship moves towards the negative x axis.
2) 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 (i.e., write comments to show the
purpose of each part)Figure 3 Menu and submenu.
Figure 4 Keyboard interaction & transformation.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Management Databases And Organizations

Authors: Richard T. Watson

6th Edition

1943153035, 978-1943153039

More Books

Students also viewed these Databases questions

Question

Th ey told me Id have to write a lett er. Whos got time for that?

Answered: 1 week ago