10 void fractal(
float left,
float top,
float xside,
float yside) {
11 glClear(GL_COLOR_BUFFER_BIT);
14 float xscale, yscale, zx, zy, cx, tempx, cy;
16 int maxx, maxy, count;
25 xscale = xside / maxx;
26 yscale = yside / maxy;
30 rectangle(0, 0, maxx, maxy);
35 for (y = 1; y <= maxy - 1; y++) {
36 for (x = 1; x <= maxx - 1; x++) {
38 cx = x * xscale + left;
41 cy = y * yscale + top;
56 while ((zx * zx + zy * zy < 4) && (count <
MAXCOUNT)) {
62 tempx = zx * zx - zy * zy + cx;
65 zy = 2 * zx * zy + cy;
75 putpixel(x, y, count);
83 float left, top, xside, yside;
90 fractal(left, top, xside, yside);
94 int main(
int argc,
char **argv) {
100 int gd = DETECT, gm, errorcode;
102 float left, top, xside, yside;
123 initgraph(&gd, &gm, driver);
125 glutInit(&argc, argv);
126 glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
127 glutInitWindowSize(1366, 768);
128 glutInitWindowPosition(0, 0);
140 glutCreateWindow(
"Mandelbrot Fractals with openGL");
void fractal(float left, float top, float xside, float yside)
int main(int argc, char **argv)