Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please I want to modify the error with this code and run it, I want to run it after deleting the key function. Run in

Please I want to modify the error with this code and run it, I want to run it after deleting the key function. Run in dev C++ and image the output
#include
#ifdef SUN
#include
#else
#include
#endif
#include
#include
#include
/* GLUT callback Handlers */
static void resize(int width, int height)
{
const float ar = (float) width / (float) height;
glViewport(0, 0, width, height);
g1MatrixMode(GL_PROJECTION);
glLoadIdentity();
g1Frustum(-ar, ar, -1.0, 1.0, 2.0, 100.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
// Planet class that will hold all our planetary data
class Planet {
public :
std::string name ="";
double x=0;
double y=0;
double c1=0;
double c2=0;
double c3=0:
double f=0;
double a=0;
double s1=0;
Planet(std::string, double, double, double, double, double, double);
void glStuff(double t, double closeness);
void printPlanet ();
};
// Simple planet constructor
Planet::Planet(std::string name="",double c1=0,double c2=0, double c3=0, double f=0,double a=0, double s1=0){
this->name = name;
this->x=0;
this->y=0;
this->c1=0;
this->c2=0;
this->c3=0;
this->f=0;
this->a=0;
this->s1=0;
}
//Function will compute new planet position
void Planet::glstuff(double t, double closeness) {
glColor3d(c1,c2,c3);
glPushMatrix();
glTranslated(x,y,closeness);
glRotated(50.0*t,0,0,1);
glutSolidSphere(s1,20,20);
glPopMatrix();
}
static double closeness = -3.0;
Planet** planets;
double moon_x; // moon x position
double moon_y; // moon y position
static double t; // time
static void display (void) // void
{
t=glutGet(GLUT_ELAPSED_TIME)/ 1000.0;
glClear(GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT);
(*planets [3]) .g1Stuff (t, closeness) ;
//moon orbit calculation
moon_x = -sin(t)*0.5+ planets[3]->x;
moon_y=cos(t)*0.5+planets[3]->y;
//Moon
gIColor3d (0.7,0.7,0.7);
glPushMatrix ();
glTranslated(moon_x ,moon_y , closeness);
gIRotated (60,1,0,0);
glRotated(50.0*t, ,0,0,1);
glutSolidSphere (0.1, 20, 20) ;
glPopMatrix();
glutSwapBuffers();
}
}
static void key (unsigned char key, int x, int y)
{
switch (key)
case 27:
case 'q':
exit (0);
break;
case "+":
if (closeness
closeness += 0.5;
}
break;
case '-':
closeness -=0.5;
break;
case'a':
glClearColor (0,0,0,0);
break;
case 'b':
glClearColor (1,1,1,0);
break;
}
glutPostRedisplay();
}
Static void idle(void)
{
glutPostRedisplay();
}
Const GLfloat light_ambient[] = {0.0f , 0.0f , 0.0f , 1.0f};
Const GLfloat light_diffuse[] = {1.0f , 1.0f , 1.0f , 1.0f};
Const GLfloat light_specular[] = {1.0f , 1.0f , 1.0f , 1.0f };
Const GLfloat light_position[] = {-20.0f , 10.0f , 0.0f , 0.0f};
Const GLfloat mat_ambient[] = {0.7f , 0.7f , 0.7f , 1.0f};
Const GLfloat mat_diffuse[] = {0.8f , 0.8f , 0.8f , 1.0f};
Const GLfloat mat_specular[] = {1.0f , 1.0f , 1.0f , 1.0f};
Const GLfloat high_shininess[] = {50.0f};
int main(int argc , char*argv[])
{
Planet = new Planet*[1];
Planet d( "earth", 0.0 , 0.0 , 0.7 , 0.2 , 4.0 , 0.2); planet[3]=&d;
glutInit(&argc , argv);
glutInitWindowSize(900,600);
glutInitWindowPosition(100,20);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutCreatWindow("Earth AND Moon");
glutReshapeFunc(resize);
glutDisplayFunc(display);
glutKeyboardFunc(Key);
glutIdleFunc(idle);
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
glEnable(GL_LIGHTE);
glEnable(GL_NORMALIZE);
glEnable(GL_COLOR_MATERIAL);
glEnable(GL_LIGHTING);
glLightfv(GL_LIGHTE, GL_AMBIENT, light_ambient);
glLightfv(GL_LIGHTE, GL_DIFFUSE, light_diffuse);
glLightfv(GL_LIGHTE, GL_SPECULAR , light_specular);
glLightfv(GL_LIGHTE, GL_POSITION,
light_position);
glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
glMaterialfv(GL_FRONT, GL_SPECULAR , mat_specular);
glMaterialfv(GL_FRONT, GL_SHININESS, high_shininess);
glutMainLoop();
return EXIT_SUCCESS;
}
I want the moon to revolve around the earth in 3D, but this code shows me that there is an error in the dev program, I want to modify the entire code with a picture of the output.
pleaseee i want correcte this code

#include

#ifdef __SUN__

#include

#else

#include

#endif

#include

#include

#include

/* GLUT callback Handlers */

static void resize(int width, int height)

{

const float ar = (float) width / (float) height;

glViewport(0, 0, width, height);

glMatrixMode (GL_PROJECTION);

glLoadIdentity();

glFrustum(-ar, ar, -1.0, 1.0, 2.0, 100.0);

glMatrixMode(GL_MODELVIEW);

glLoadIdentity();

}

// Planet class that will hold all our planetary data

class Planet {

public :

std::string name ="";

double x=0;

double y=0;

double c1=0;

double c2=0;

double c3=0;

double f=0;

double a=0;

double s1=0;

Planet(std::string, double, double, double, double, double, double);

void glStuff(double t, double closeness);

void printPlanet ();

};

// Simple planet constructor

Planet::Planet(std::string name="",double c1=0,double c2=0, double c3=0, double f=0,double a=0, double s1=0){

this->name = name;

this->x=0;

this->y=0;

this->c1=0;

this->c2=0;

this->c3=0;

this->f=0;

this->a=0;

this->s1=0;

}

//Function will compute new planet position

void Planet::glstuff(double t, double closeness) {

glColor3d(c1,c2,c3);

glPushMatrix();

glTranslated(x,y,closeness);

glRotated(50.0*t,0,0,1);

glutSolidSphere(s1,20,20);

glPopMatrix();

}

static double closeness = -3.0;

Planet** planets;

double moon_x; // moon x position

double moon_y; // moon y position

static double t; // time

static void display (void) // void

{

t=glutGet(GLUT_ELAPSED_TIME)/ 1000.0;

glClear(GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT);

(*planets [3]) .g1Stuff (t, closeness) ;

//moon orbit calculation

moon_x = -sin(t)*0.5+ planets[3]->x;

moon_y=cos(t)*0.5+planets[3]->y;

//Moon

glColor3d (0.7,0.7,0.7);

glPushMatrix ();

glTranslated(moon_x ,moon_y , closeness);

glRotated (60,1,0,0);

glRotated(50.0*t, ,0,0,1);

glutSolidSphere (0.1, 20, 20) ;

glPopMatrix();

glutSwapBuffers();

}

static void key (unsigned char key, int x, int y)

{

switch (key)

case 27:

case 'q':

exit (0);

break;

case "+":

if (closeness

closeness += 0.5;

}

break;

case '-':

closeness -=0.5;

break;

case'a':

glClearColor (0,0,0,0);

break;

case 'b':

glClearColor (1,1,1,0);

break;

}

glutPostRedisplay();

}

Static void idle(void)

{

glutPostRedisplay();

}

Const GLfloat light_ambient[] = {0.0f , 0.0f , 0.0f , 1.0f};

Const GLfloat light_diffuse[] = {1.0f , 1.0f , 1.0f , 1.0f};

Const GLfloat light_specular[] = {1.0f , 1.0f , 1.0f , 1.0f };

Const GLfloat light_position[] = {-20.0f , 10.0f , 0.0f , 0.0f};

Const GLfloat mat_ambient[] = {0.7f , 0.7f , 0.7f , 1.0f};

Const GLfloat mat_diffuse[] = {0.8f , 0.8f , 0.8f , 1.0f};

Const GLfloat mat_specular[] = {1.0f , 1.0f , 1.0f , 1.0f};

Const GLfloat high_shininess[] = {50.0f};

int main(int argc , char*argv[])

{

Planet = new Planet*[1];

Planet d( "earth", 0.0 , 0.0 , 0.7 , 0.2 , 4.0 , 0.2); planet[3]=&d;

glutInit(&argc , argv);

glutInitWindowSize(900,600);

glutInitWindowPosition(100,20);

glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);

glutCreatWindow("Earth AND Moon");

glutReshapeFunc(resize);

glutDisplayFunc(display);

glutKeyboardFunc(Key);

glutIdleFunc(idle);

glEnable(GL_CULL_FACE);

glCullFace(GL_BACK);

glEnable(GL_DEPTH_TEST);

glDepthFunc(GL_LESS);

glEnable(GL_LIGHTE);

glEnable(GL_NORMALIZE);

glEnable(GL_COLOR_MATERIAL);

glEnable(GL_LIGHTING);

glLightfv(GL_LIGHTE, GL_AMBIENT, light_ambient);

glLightfv(GL_LIGHTE, GL_DIFFUSE, light_diffuse);

glLightfv(GL_LIGHTE, GL_SPECULAR , light_specular);

glLightfv(GL_LIGHTE, GL_POSITION,

glight_position);

glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);

glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);

glMaterialfv(GL_FRONT, GL_SPECULAR , mat_specular);

glMaterialfv(GL_FRONT, GL_SHININESS, high_shininess);

glutMainLoop();

return EXIT_SUCCESS;

}

image text in transcribed
Message Wamingl non-static data member initializers only avialable with -std c+11 or - std =gnu++11 Wamingl non-static data member initialicers only avaitable with 1td=c++11 or 5td=9nu+1) WWamingl nen-static data member initializers only available with -stdec+ +11 or -stde 9nu++1. WWaining] non-stebe dote member initia lizers anly available with -std=c++11 or -std=gnu+ 7+11 [Waming] non-stebe data member initslizers only available with itd =c++11 on -stde non-static data memberinitializers on w++11. [Waening] nen-static data member initializere only averilable with 5td=c+11 or 5tdzgnu++11 (Weningl noniztatic datie member initializers only avadable with 5td=c++11 or 5td=9nu++11 [Error] no 'void Planetrglstuff(double, double)' member function declared in class Planet' member function declared in class 'Planet' [Error) "class Planet' has no member named 'g g15 tuff' IEiror| expected ptimary-expression before; token

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

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions

Question

Explain the importance of cross-cultural relationships.

Answered: 1 week ago