// // Torbert, 7 January 2016 // #include // #include // #define W 640 #define H 480 // double minRe = -2.0 ; double maxRe = 2.0 ; double minIm = -1.5 ; double maxIm = 1.5 ; // int maxiter = 80 ; // void displayfunc() { int x , y , n ; // double cRe , cIm ; double zRe , zIm ; // double tmp ; // glClear(GL_COLOR_BUFFER_BIT); // green // for( x = 0 ; x < W ; x++ ) { for( y = 0 ; y < H ; y++ ) { zRe = 0.0 ; zIm = 0.0 ; // cRe = minRe + x * ( maxRe - minRe ) / W ; cIm = minIm + y * ( maxIm - minIm ) / H ; // for( n = 0 ; n < maxiter ; n++ ) { if( zRe * zRe + zIm * zIm > 4.0 ) break ; // tmp = zRe * zRe - zIm * zIm + cRe ; // zIm = 2.0 * zRe * zIm + cIm ; // zRe = tmp ; } // if( n == maxiter ) { glColor3f( 0.0 , 0.0 , 0.0 ) ; // black } else { tmp = ( 1.0 * n ) / maxiter ; // glColor3f( tmp * 0.6 , tmp * 0.3 , 0.0 ) ; // brown } // glBegin(GL_POINTS); glVertex2f(x,y); glEnd(); } } // glutSwapBuffers(); } void mousefunc(int button,int state,int xscr,int yscr) { double x , y ; double w , h ; // yscr = H - yscr ; // invert the y-coordinate // if(button==GLUT_LEFT_BUTTON) { if(state==GLUT_DOWN) // zoom { w = maxRe - minRe ; h = maxIm - minIm ; // w *= 0.5 ; h *= 0.5 ; // printf( "w = %0.16e\n" , w ) ; printf( "h = %0.16e\n" , h ) ; printf( "\n" ) ; // x = minRe + xscr * ( maxRe - minRe ) / W ; // center y = minIm + yscr * ( maxIm - minIm ) / H ; // minRe = x - 0.5 * w ; maxRe = x + 0.5 * w ; // minIm = y - 0.5 * h ; maxIm = y + 0.5 * h ; } } else if(button==GLUT_RIGHT_BUTTON) { if(state==GLUT_DOWN) // sharpen { maxiter *= 2 ; // printf( "maxiter = %d\n" , maxiter ) ; printf( "\n" ) ; } } // glutPostRedisplay(); } int main(int argc,char* argv[]) { glutInit(&argc,argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB); glutInitWindowSize(W,H); glutInitWindowPosition(100,50); glutCreateWindow(""); glClearColor(0.0,1.0,0.0,0.0); // green glShadeModel(GL_SMOOTH); // glViewport(0,0,(GLsizei)W,(GLsizei)H); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(0.0,1.0*W,0.0,1.0*H); glMatrixMode(GL_MODELVIEW); // glutDisplayFunc(displayfunc); glutMouseFunc(mousefunc); // glutMainLoop(); // return 0; } // // end of file //