Home > database >  Why codeblock code unable to display picture
Why codeblock code unable to display picture

Time:10-18

# include
# include
# include
Void init (void) {glClearColor (1.0, 1.0, 1.0, 0.0); GlMatrixMode (GL_PROJECTION); GluOrtho2D (0.0, 800, 800); } void setPixel (GLint x, GLint y) {glBegin (GL_POINTS); GlVertex2i (x, y);
GlEnd (); {} the inline int round (const float a)
Return int (a + 0.5); }
Void ellipseMidpoint (int xCenter, int yCenter, int Rx, int Ry)
{int Rx2=Rx * Rx;
Int Ry2=Ry * Ry;
Int * Rx2 twoRx2=2;
Int * Ry2 twoRy2=2;
Int p; Int x=0; Int y=Ry; Int px=0; Int p y=twoRx2 * y;
Void ellipsePlotPoints (int, int, int, int)./* the Plot the initial point in each quadrant. */
EllipsePlotPoints (xCenter, yCenter, x, y);/* 1 */Region
P=round (Ry2 - (Rx2 * Ry) + (0.25 * Rx2)); While (p

X++; Px +=twoRy2; If (p <0) p +=Ry2 + px;
The else {y -; Py -=twoRx2; P + + px=Ry2 - py; } ellipsePlotPoints (xCenter, yCenter, x, y); Region 2}/* */p=round (Ry2 * (x + 0.5) * (x + 0.5) + Rx2 * (y - 1) * (1) y - Rx2 * Ry2); While (y> 0) {y -; Py -=twoRx2; If (p> 0) p +=Rx2 - py; The else {x++; Px +=twoRy2; P +=Rx2 - py + px; } ellipsePlotPoints (xCenter, yCenter, x, y); }} void ellipsePlotPoints (int xCenter, int yCenter, int x, int y) {setPixel (, yCenter xCenter + x + y); SetPixel (xCenter - x, yCenter + y); SetPixel (yCenter xCenter + x, y); SetPixel (xCenter - x, yCenter - y); } void myDraw (void) {glClear (GL_COLOR_BUFFER_BIT); EllipseMidpoint,60,50 (450470); GlFlush (); } int main (int arg c, char * argv []) {glutInit (& arg c, argv); GlutInitDisplayMode (GLUT_RGB | GLUT_SINGLE); GlutInitWindowSize (900900); GlutInitWindowPosition (400400); The ellipse glutCreateWindow (" "); init(); GlutDisplayFunc (myDraw); GlutMainLoop (); Return EXIT_SUCCESS; }

  • Related