Home > other >  Write a program that draw a rectangle, code no problem, but not mapped graphics rectangular, does an
Write a program that draw a rectangle, code no problem, but not mapped graphics rectangular, does an

Time:09-22

Want to draw a rectangle, with OpenGL program code is as follows:
 # include & lt; GL/glut. H> 
Void the display ()//defines to draw graphics entities
{
GlClear (GL_COLOR_BUFFER_BIT);
GlBegin (GL_POLYGON);
GlVertex2f (0.5, 0.5);
GlVertex2f (0.5, 0.5);
GlVertex2f (0.5, 0.5);
GlVertex2f (0.5, 0.5);
GlEnd ();
GlFlush ();
}

Int main (int arg c, char * * argv)//OpenGL initialization
{
GlutInit (& amp; Arg c, argv);
GlutCreateWindow (" simple ");
GlutDisplayFunc (display);
GlutMainLoop ();
}


But shows results for:


Tell please, thanks! ^_^

CodePudding user response:

Is the cause of the rendering, GL_POLYGON way of drawing as follows: if there is V1, V2, V3 and V4. So will the V1, V2, V3 draw a triangle, V1 and V3, V4 draw a triangle,
  • Related