Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4347804
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T12:21:22+00:00 2026-05-21T12:21:22+00:00

i have the following code ,which draws mandelbrot set.I created a menu with an

  • 0

i have the following code ,which draws mandelbrot set.I created a menu with an option “black&white” which i want to draw the mandelbrot in black and white color.I haven’t figured how to do this (if it can be done this way).mandelbrot is called through the display function ,but how can i call mandelbrot_black?

Also, if someone knows hot to make “zoom” in my code…here…http://stackoverflow.com/questions/5705554/how-to-do-zoom-in-my-code-mandelbrot

 void mandelbrot();     
 void mandelbrot_black();

 GLsizei width = 600;
 GLsizei height = 600; 
 GLfloat AspectRatio;
 int max = 500;
 double xpos=0,ypos=0;
 int CLEARFLAG=1;


  double xmax = 2.0;
  double xmin = -2.0; 
  double ymax = 2.0;
  double ymin = -2.0;

  using namespace std;

  void display()
 {
   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
  gluOrtho2D(-2, width, -2, height);
  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();
  glClear(GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT );
  mandelbrot();
  glutSwapBuffers();
  }


  void reshape(GLsizei w, GLsizei h) {

  width=w; height=h;
  glViewport(0,0,width,height);
  glutPostRedisplay();
   }



  void setXYpos(int px, int py)
    {  
     xpos=xmin+(xmax-xmin)*px/width;
     ypos=ymax-(ymax-ymin)*py/height;

     }



   void mouse(int button, int state, int x, int y)
  {
if(button==GLUT_LEFT_BUTTON && state==GLUT_DOWN) {CLEARFLAG=0; setXYpos(x,y);}

glutPostRedisplay();
  }

void mandelbrot()
 {
 ...}

void mandelbrot_black(){
...}

void mymenu(int n)
{
  switch(n) {

   case 1: zoom_in();break;
   case 2: zoom_out();break;
   case 3: mandelbrot_black();break;
   case 4: exit(0);
     }

   glutPostRedisplay();
    }




   void SetupMenu()
   {

glutCreateMenu(mymenu);
glutAddMenuEntry("zoom in",1);
glutAddMenuEntry("zoom out",2);
glutAddMenuEntry("black&white",3);
glutAddMenuEntry("exit",4);
glutAttachMenu(GLUT_RIGHT_BUTTON);
    } 

     int main(int argc, char *argv[])
     {

     glutInit(&argc, argv);
     glutInitWindowSize(600, 600);
     glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
     glutCreateWindow("Mandelbrot");
     glutDisplayFunc(display);
     glutReshapeFunc(reshape);
     glutMainLoop();

     return 0;
      }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T12:21:23+00:00Added an answer on May 21, 2026 at 12:21 pm

    Your display function needs to draw either mandelbrot() or mandelbrot_black() depending on the current state (which can/should be a global variable).

    //in global scope
    static bool black = false;
       ...
    
    //in display()
    if(black)
      mandelbrot_black();
    else
      mandelbrot();
    

    Change black accordingly in mymenu(). You still need to attach your menu to a mouse button and call SetupMenu().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code which works fine. However, I only want to return
I have the following code which draws a square on the main window of
I have the following code which work fine: $('.ui-selectmenu-menu a').click(function() { alert('OK'); }); However,
I'm trying to use opengl in C#. I have following code which fails with
I have following Code Block Which I tried to optimize in the Optimized section
I have the following code which works just fine when the method is POST,
Okay so I have the following Code which appends a string to another in
I have the following JQuery code which does similar functionality like Stackoverflow where the
I have the following piece of code which replaces template markers such as %POST_TITLE%
I have the following JavaScript code: Link In which the function makewindows does not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.