Home > Software engineering >  How to according to the following program or any genuflect is begged a OpenGL program, calculating t
How to according to the following program or any genuflect is begged a OpenGL program, calculating t

Time:09-22

# include & lt; Gl/glut. H>
#include
#include
# pragma comment (lib, "opengl32. Lib")
# pragma comment (lib, "glut32. Lib")
# pragma comment (lib, "glu32. Lib")
# pragma comment (lib, "glut. Lib")


#include
The void Cube ()
{
GlBegin (GL_QUAD_STRIP);//filling convex polygon
GlVertex3f (0.0 f, f, 0.0 0.0 f);
GlVertex3f (0.0 f, f, 1.0 0.0 f);
GlVertex3f (1.0 f, f, 0.0 0.0 f);
GlVertex3f (1.0 f, f, 1.0 0.0 f);
GlVertex3f (1.0 f, f, 0.0-1.0 f);
GlVertex3f (1.0 f, f, 1.0-1.0 f);
GlVertex3f (0.0 f, f, 0.0-1.0 f);
GlVertex3f (0.0 f, f, 1.0-1.0 f);
GlVertex3f (0.0 f, f, 0.0 0.0 f);
GlVertex3f (0.0 f, f, 1.0 0.0 f);
GlEnd ();
GlBegin (GL_QUAD_STRIP);
GlVertex3f (0.0 f, f, 0.0 0.0 f);
GlVertex3f (1.0 f, f, 0.0 0.0 f);
GlVertex3f (0.0 f, f, 0.0-1.0 f);
GlVertex3f (1.0 f, f, 0.0-1.0 f);
GlVertex3f (0.0 f, f, 1.0 0.0 f);
GlVertex3f (1.0 f, f, 1.0 0.0 f);
GlVertex3f (0.0 f, f, 1.0-1.0 f);
GlVertex3f (1.0 f, f, 1.0-1.0 f);
GlEnd ();
}
Void Circle ()
{
GlBegin (GL_TRIANGLE_FAN);//fan continuously populated triangle string
GlVertex3f (0.0 f, f, 0.0 0.0 f);
int i=0;
for (i=0; i <=390; I +=15)
{
Float p=I * 3.14/180;
GlVertex3f (sin (p), cos (p), 0.0 f);
}
GlEnd ();
}
Void Cylinder ()
{
GlBegin (GL_QUAD_STRIP);//continuously populated quadrilateral string
int i=0;
for (i=0; i <=390; I +=15)
{
Float p=I * 3.14/180;
GlVertex3f (sin (p), cos (p), 1.0 f);
GlVertex3f (sin (p), cos (p), 0.0 f);
}
GlEnd ();
Circle ();
GlTranslatef (0, 0, 1);
Circle ();
}
Void Cone ()
{
GlBegin (GL_QUAD_STRIP);//continuously populated quadrilateral string
int i=0;
for (i=0; i <=390; I +=15)
{
Float p=I * 3.14/180;
GlVertex3f (0, 0, 1.0 f);
GlVertex3f (sin (p), cos (p), 0.0 f);
}
GlEnd ();
Circle ();
}
Void renderScene (void)
{
The static float I=0;
I +=0.1;
If (I & gt; 360)
i=0;
GlClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
GlLoadIdentity ();

GlPushMatrix ();
GlColor3f (0, 1, 0);
GlTranslatef (- 2, 2.0, and 12);
GlRotatef (I, 1, 1, 1);
Cylinder ();
GlPopMatrix ();

GlPushMatrix ();
GlColor3f (1, 0, 0);
GlTranslatef (2, 2-12);
GlRotatef (I, 1, 1, 1);
Circle ();
GlPopMatrix ();

GlPushMatrix ();
GlColor3f (0, 1, 1);
GlTranslatef (- 2-2-12);
GlRotatef (I, 1, 1, 1);
Cube ();
GlPopMatrix ();

GlPushMatrix ();
GlColor3f (1, 1, 0);
GlTranslatef (2, 2, 12);
GlRotatef (I, 1, 1, 1);
Cone ();
GlPopMatrix ();
GlutSwapBuffers ();
}
Void changeSize (int w, int h) {

//to prevent the divisor that is highly 0
//(you can set the window width of 0.)
If (h==0)
H=1;
Float thewire=1.0 * w/h;

//unit of projection matrix,
GlMatrixMode (GL_PROJECTION);
GlLoadIdentity ();

//set the viewport size for the entire window size
GlViewport (0, 0, w, h);

//set the correct projection matrix
GluPerspective (45, thewire, 1, 1000);
//here is set up model view matrix
GlMatrixMode (GL_MODELVIEW);
GlLoadIdentity ();
GluLookAt (0.0, 0.0, 5.0, 0.0, 0.0, 1.0, 0.0 f, f 1.0, 0.0 f);//set the observation point
}
Int main (int arg c, char * argv [])
{
GlutInit (& amp; Arg c, argv);
GlutInitDisplayMode (GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
GlutInitWindowPosition (100, 100);
GlutInitWindowSize (320, 320);
GlutCreateWindow (" Hello OpenGL ");
GlutDisplayFunc renderScene ();
GlutIdleFunc renderScene (); Call a function to do in your spare time//specified program
GlutReshapeFunc (changeSize);//callback function specified window shape changes
GlEnable (GL_DEPTH_TEST);
GlutMainLoop ();
return 0;
}

CodePudding user response:

 
#include
#include
#include

Void main (void)
{
Time_t start and finish;
Long loop;
Double result, elapsed_time;

Printf (" Multiplying two floating point Numbers 10 m letters times... \n" );

Time (& amp; Start);
For (loop=0; Loop & lt; 10000000; Loop++)
Result=3.63 * 5.27;
Time (& amp; Finish);

Elapsed_time=difftime (finish, start);
Printf (" \ nProgram takes % 6.0 f seconds. \ n ", elapsed_time);
}

CodePudding user response:

Search online tutorial "learning OpenGL 3 d games",

CodePudding user response:

Int gStart=0;
Int gEnd=0;
,,,,,,,,
GStart= glutGet (GLUT_ELAPSED_TIME);
.
GEnd=glutGet (GLUT_ELAPSED_TIME);

CodePudding user response:

 
//
Int frame=0, timenow, timebase=0;
Void Idle (void)
{
If # 1
Frame++;
Timenow=glutGet (GLUT_ELAPSED_TIME);
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related