Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void displayfunc() {
- glClear(GL_COLOR_BUFFER_BIT);
- glColor3f(0.0, 1.0, 0.0);
- for (int x = 0; x < N; x++) {
- for (int y = 0; y < N; y++) {
- glBegin(GL_POINTS);
- double scaledX = (x - N / 2) * 4 / (N * 1.0);
- double scaledY = (y - N / 2) * 4 / (N * 1.0); //dark voodoo magic
- int count = 0;
- int max = 256;
- double a, b = 0.0;
- while (count < max && ((a * a) + (b * b)) <= 4) {
- int temp_a = (a * a) - (b * b) + scaledX;
- b = 2 * a * b + scaledY;
- a = temp_a;
- count++;
- }
- if (count < max) {
- glColor3f(1.0, 1.0, 0.0); //outside color
- } else {
- glColor3f(0.0, 0.0, 0.0); //inside color
- }
- glVertex2f(x, y); //draw a pixel of the color specified in glColor3f
- glEnd();
- }
- }
- glutSwapBuffers(); //always at the end of displayfunc()
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement