Home > Back-end >  Seek help from a great god, online to find the opengl a code, run out the image
Seek help from a great god, online to find the opengl a code, run out the image

Time:11-10

Void myDisplay01 ()
{
GlEnable (GL_DEPTH_TEST);//use the depth test solution because after drawing object covered in drawing first, and at the beginning of the drawing picture to empty the depth buffer
GlClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

GlMatrixMode (GL_PROJECTION);
GlLoadIdentity ();//current matrix is set to unit array
GluPerspective (75, 1, 1, 400000000);//the current matrix and projection matrix multiplication
GlMatrixMode (GL_MODELVIEW);
GlLoadIdentity ();
GluLookAt (0-200000000, 200000000, 0, 0, 0, 0, 0, 1);//change the position of observation point


//draw the red sun
GlColor3f (0.0 1.0 f, 0.0 f, f);
GlutSolidSphere (69600000, 20, 20);
//draw the blue earth
GlColor3f (1.0 0.0 f, 0.0 f, f);
GlRotatef (day/360.0 * 360.0, 0.0, 0.0, f to 1.0 f);//set up around the z axis Angle
GlTranslatef (150000000, 0.0 f to 0.0 f);
GlutSolidSphere (15945000, 20, 20);
//draw blue moon
GlColor3f (0.0 0.0 f, 1.0 f, f);
GlRotatef (day/360.0, 360.0 * 30.0 * 360.0 - day/f 0.0, 0.0, f to 1.0 f);
GlTranslatef (38000000, 0.0 f to 0.0 f);
GlutSolidSphere (4345000, 20, 20);

GlFlush ();


}


Int main (int arg c, char * argv [])
{
GlutInit (& amp; Arg c, argv);
GlutInitDisplayMode (GLUT_RGB);
GlutInitWindowPosition (100, 100);
GlutInitWindowSize (600, 600);
GlutCreateWindow (opengl program ");
GlutDisplayFunc (& amp; MyDisplay01);
GlutMainLoop ();
system("pause");
return 0;
}

CodePudding user response:

 # include & lt; stdlib.h> 
#include

Float day=1.0 f;

Void myDisplay01 ()
{
GlEnable (GL_DEPTH_TEST);//use the depth test solution because after drawing object covered in drawing first, and at the beginning of the drawing picture to empty the depth buffer
GlClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

GlMatrixMode (GL_PROJECTION);
GlLoadIdentity ();//current matrix is set to unit array
GluPerspective (75, 1, 1, 400000000);//the current matrix and projection matrix multiplication
GlMatrixMode (GL_MODELVIEW);
GlLoadIdentity ();
GluLookAt (0-200000000, 200000000, 0, 0, 0, 0, 0, 1);//change the position of observation point


//draw the red sun
GlColor3f (0.0 1.0 f, 0.0 f, f);
GlutSolidSphere (69600000, 20, 20);
//draw the blue earth
GlColor3f (1.0 0.0 f, 0.0 f, f);
GlRotatef (day/360.0 * 360.0, 0.0, 0.0, f to 1.0 f);//set up around the z axis Angle
GlTranslatef (150000000, 0.0 f to 0.0 f);
GlutSolidSphere (15945000, 20, 20);
//draw blue moon
GlColor3f (0.0 0.0 f, 1.0 f, f);
GlRotatef (day/360.0, 360.0 * 30.0 * 360.0 - day/f 0.0, 0.0, f to 1.0 f);
GlTranslatef (38000000, 0.0 f to 0.0 f);
GlutSolidSphere (4345000, 20, 20);

GlFlush ();


}


Int main (int arg c, char * argv []) {
GlutInit (& amp; Arg c, argv);
GlutInitDisplayMode (GLUT_RGB);
GlutInitWindowPosition (100, 100);
GlutInitWindowSize (600, 600);
GlutCreateWindow (opengl program ");
GlutDisplayFunc (& amp; MyDisplay01);
GlutMainLoop ();
system("pause");
return 0;
}
  • Related