void DrawAxes () { #define drawOneLine(x1,y1,x2,y2) glBegin(GL_LINES); \ glVertex2f ((x1),(y1)); glVertex2f ((x2),(y2)); glEnd(); #define Min(x,y) ((x) < (y) ? (x) : (y)) drawOneLine (min[0], 0.0, max[0], 0.0); // x-axis drawOneLine (min[0], Min(0,min[1]), min[0], max[1]); // y-axis }
/// Graph plotting function void goplot(){ int j,k; int n= nodes; char buffer[24]; gedge** matrix = output; /* gedge matrix[n][n]; for(j=0;j<nodes;j++){ for(k=0;k<nodes;k++){ if(j!=k){//j!=k&&j!=k-1&&k!=j-1&&j!=k-3&&k!=j-3){ matrix[j][k].weight=j+k+j; matrix[j][k].visited=0; } else{ matrix[j][k].weight=0; matrix[j][k].visited=0; } } }*/ for(j=0;j<nodes;j++){ for(k=0;k<nodes;k++){ if(matrix[j][k].weight!=-1){ if(matrix[j][k].weight==matrix[k][j].weight){ if(j<k){ sprintf(buffer, "<->%.3f",matrix[j][k].weight); if(showWeights){ write_strings( buffer ,(((array[j].x)+(array[k].x))/2)+10,(((array[k].y)+(array[j].y))/2)+10); } drawOneLine (array[j].x,array[j].y,array[k].x,array[k].y); } } else{ if(j>k){ sprintf(buffer, "->%.3f",matrix[j][k].weight); if(showWeights){ write_strings( buffer ,(((array[j].x)+(array[k].x))/2)+10,(((array[k].y)+(array[j].y))/2)+10); } drawOneLine (array[j].x,array[j].y,array[k].x,array[k].y); } else{ sprintf(buffer, "<-%.3f",matrix[j][k].weight); if(showWeights){ write_strings( buffer ,(((array[j].x)+(array[k].x))/2)-10,(((array[k].y)+(array[j].y))/2)-10); } drawOneLine (array[j].x,array[j].y,array[k].x,array[k].y); } } } } } }
void display(void) { int i; glClear (GL_COLOR_BUFFER_BIT); /* select white for all lines */ glColor3f (1.0, 1.0, 1.0); /* in 1st row, 3 lines, each with a different stipple */ glEnable (GL_LINE_STIPPLE); glLineStipple (1, 0x0101); /* dotted */ drawOneLine (50.0, 125.0, 150.0, 125.0); glLineStipple (1, 0x00FF); /* dashed */ drawOneLine (150.0, 125.0, 250.0, 125.0); glLineStipple (1, 0x1C47); /* dash/dot/dash */ drawOneLine (250.0, 125.0, 350.0, 125.0); /* in 2nd row, 3 wide lines, each with different stipple */ glLineWidth (5.0); glLineStipple (1, 0x0101); /* dotted */ drawOneLine (50.0, 100.0, 150.0, 100.0); glLineStipple (1, 0x00FF); /* dashed */ drawOneLine (150.0, 100.0, 250.0, 100.0); glLineStipple (1, 0x1C47); /* dash/dot/dash */ drawOneLine (250.0, 100.0, 350.0, 100.0); glLineWidth (1.0); /* in 3rd row, 6 lines, with dash/dot/dash stipple */ /* as part of a single connected line strip */ glLineStipple (1, 0x1C47); /* dash/dot/dash */ glBegin (GL_LINE_STRIP); for (i = 0; i < 7; i++) glVertex2f (50.0 + ((GLfloat) i * 50.0), 75.0); glEnd (); /* in 4th row, 6 independent lines with same stipple */ for (i = 0; i < 6; i++) { drawOneLine (50.0 + ((GLfloat) i * 50.0), 50.0, 50.0 + ((GLfloat)(i+1) * 50.0), 50.0); } /* in 5th row, 1 line, with dash/dot/dash stipple */ /* and a stipple repeat factor of 5 */ glLineStipple (5, 0x1C47); /* dash/dot/dash */ drawOneLine (50.0, 25.0, 350.0, 25.0); /* in paw ares stipple */ glLineStipple (3, 0xAAAA); /* ares */ drawOneLine (175.0, 5.0, 175.0, 145.0); glDisable (GL_LINE_STIPPLE); glFlush (); }
void CALLBACK display() { glClear(GL_COLOR_BUFFER_BIT); glColor3d(1.0, 1.0, 1.0); // Все отрезки рисуются белым цветом glBegin(GL_LINES); for (double i = -7; i < 7;i+=0.000001) glVertex2d(i,5*cos(i*i)); glEnd(); glColor3d(0, 1.0, 0); drawOneLine(0, -7,0,7); drawOneLine(-7, 0, 7, 0); for (int i = -7; i < 7; i++) { drawOneLine(i, -0.3, i, 0.3); drawOneLine(-0.3, i, 0.3, i); } glFlush(); }
void display(void){ int i; glClear(GL_COLOR_BUFFER_BIT); glColor3f(1,1,1); glEnable(GL_LINE_STIPPLE); glLineStipple(1,0x0101); drawOneLine(50,125,150,125); glLineStipple(1,0x00FF); drawOneLine(150,125,250,125); glLineStipple(1,0x1C47); drawOneLine(250,125,350,125); glFlush(); }
void display(UGWindow uwin) { int i; glClear (GL_COLOR_BUFFER_BIT); /* select white for all lines */ glColor4f (1.0, 1.0, 1.0, 1.0); /* in 1st row, 3 lines, each with a different stipple */ //glEnable (GL_LINE_STIPPLE); //glLineStipple (1, 0x0101); /* dotted */ glColor4f(1., 0., 0., 1.); drawOneLine (50.0, 125.0, 150.0, 125.0); //glLineStipple (1, 0x00FF); /* dashed */ glColor4f(0., 1., 0., 1.); drawOneLine (150.0, 125.0, 250.0, 125.0); //glLineStipple (1, 0x1C47); /* dash/dot/dash */ glColor4f(0., 0., 1., 1.); drawOneLine (250.0, 125.0, 350.0, 125.0); glColor4f(1., 1., 1., 1.); /* in 2nd row, 3 wide lines, each with different stipple */ glLineWidth (5.0); //glLineStipple (1, 0x0101); /* dotted */ drawOneLine (50.0, 100.0, 150.0, 100.0); //glLineStipple (1, 0x00FF); /* dashed */ glColor4f(1., 1., 0., 1.); drawOneLine (150.0, 100.0, 250.0, 100.0); //glLineStipple (1, 0x1C47); /* dash/dot/dash */ glColor4f(0., 1., 1., 1.); drawOneLine (250.0, 100.0, 350.0, 100.0); glLineWidth (1.0); glColor4f(1., 0., 1., 1.); /* in 3rd row, 6 lines, with dash/dot/dash stipple */ /* as part of a single connected line strip */ //glLineStipple (1, 0x1C47); /* dash/dot/dash */ #if 0 glBegin (GL_LINE_STRIP); for (i = 0; i < 7; i++) glVertex2f (50.0 + ((GLfloat) i * 50.0), 75.0); glEnd (); #else { GLfloat v[14]; for (i = 0; i < 7; i++) { v[2*i] = 50.0 + ((GLfloat) i * 50.0); v[2*i+1] = 75.0; } glVertexPointer(2, GL_FLOAT, 0, v); glEnableClientState(GL_VERTEX_ARRAY); glDrawArrays(GL_LINE_STRIP, 0, 7); } #endif glColor4f(1., 1., 1., 1.); /* in 4th row, 6 independent lines with same stipple */ for (i = 0; i < 6; i++) { drawOneLine (50.0 + ((GLfloat) i * 50.0), 50.0, 50.0 + ((GLfloat)(i+1) * 50.0), 50.0); } glColor4f(.8, .8, .8, 1.); /* in 5th row, 1 line, with dash/dot/dash stipple */ /* and a stipple repeat factor of 5 */ //glLineStipple (5, 0x1C47); /* dash/dot/dash */ drawOneLine (50.0, 25.0, 350.0, 25.0); //glDisable (GL_LINE_STIPPLE); glFlush (); ugSwapBuffers(uwin); }