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

  • Home
  • SEARCH
  • 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 8973173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:23:13+00:00 2026-06-15T18:23:13+00:00

I have written a c++ program in Xcode to implement Symbolic Regression & Genetic

  • 0

I have written a c++ program in Xcode to implement Symbolic Regression & Genetic Programming. I’d like to create a window to visualize the reference data (an array of 2d points) and the best function that the program generates each generation.

To put it simply, I’d like the window to show 2 graphs, and have it be updated with a for loop. From what I understand, GLUT seems like a good framework, and I’ve written a function to display the reference data (std::vector is how I’m storing the “referenceDataSet” variable):

void renderScene(){
    // The min/max variables are just for scaling & centering the graph
    double minX, maxX, minY, maxY;
    minX = referenceDataSet[0].first;
    maxX = referenceDataSet[0].first;
    minY = referenceDataSet[0].second;
    maxY = referenceDataSet[0].second;
    for (int i = 0; i < referenceDataSet.size(); i++) {
        minX = min(minX, referenceDataSet[i].first);
        maxX = max(maxX, referenceDataSet[i].first);
        minY = min(minY, referenceDataSet[i].second);
        maxY = max(maxY, referenceDataSet[i].second);
    }
    glLoadIdentity ();
    glClear(GL_COLOR_BUFFER_BIT);
    glBegin( GL_LINE_STRIP );
    glColor4f( 1.0, 0.0, 0.0, 1.0);
    for (int i = 0; i < referenceDataSet.size(); i++) {
        glVertex2f((referenceDataSet[i].first-minX)/(maxX-minX)-0.5, (referenceDataSet[i].second-minY)/(maxY-minY)-0.5);
    }
    glEnd();
    glFlush();
}

void renderInit(int argc, char **argv){
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
    glutInitWindowSize(600, 600);
    glutCreateWindow("");
    glutDisplayFunc(renderScene);
    glutCheckLoop();
}

The problem with this is that I’m not sure how I should go about updating the window, or drawing a second graph that constantly changes.

Also, this is my first question on Stack Overflow, so I apologize if I’m not doing something correctly here, or if any of this is difficult to understand. I searched as best I could for the answer, but couldn’t really find anything relevant.

  • 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-06-15T18:23:14+00:00Added an answer on June 15, 2026 at 6:23 pm

    In glut or OpenGL, glutIdleFunc(void (*func)(void)) is used to update the scene.
    The idle func will call the glutDisplayFunc every time the scene refreshes.

    Reference is here http://www.opengl.org/resources/libraries/glut/spec3/node63.html

    I guess renderScene() is your glutDisplayFunc. And you need to register an idle function using glutIdleFunc. In the idle function, you can change the parameters for the second graph that constantly changes, and renderScene() will be called again after changes in the idle function are done.

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

Sidebar

Related Questions

I have written a small program just like hello the world , everything was
Suppose I have written a little program by Xcode 4, how can I test
I have written a program that generates random expressions and then uses genetic techniques
I have written php program and uploaded on server. I want run this program
I have written a program in VB6. When I compile it and send it
I have written a program that uses qhttp to get a webpage. This works
I have written this program, which sorts some ints using a functor: #include<iostream> #include<list>
I have written my program in python. It is written across seven files and
Visual Studio C++ 2008 / GCC 4.4.2 I have written a program to run
I have program written in C. It takes 2 arguments username/password and try to

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.