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 7505149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T21:48:38+00:00 2026-05-29T21:48:38+00:00

Limitations: I can’t change the frameworks I have to use the functions in the

  • 0

Limitations:

  • I can’t change the frameworks
  • I have to use the functions in the
    program (my beloved teacher doesn’t like us using functions given by any other than herself)

Here’s the code and it works just like this (just not as smooth as i would like it to)

#include<OpenGL/gl.h>
#include<OpenGL/glu.h>
#include<GLUT/glut.h>
#include <stdlib.h>
#include <math.h>

int lb=-30, ub=30;
double cpoints=9999999;

void init (void)
{
    glClearColor(1,1,1,1);
    glMatrixMode(GL_PROJECTION);
    gluOrtho2D(-30,30,-30,30);
}

void graphfunct2D(void)
{
    double dx, xi, yi;
    dx = (ub-lb)*1.0/cpoints;
    glColor3f(0,0,0);
    glClear(GL_COLOR_BUFFER_BIT);
    xi = lb;
    yi = xi*sin(xi);
    int i;
    for (i=0; i<=cpoints;i++)
    {
        glBegin(GL_POINTS);
        glVertex2i(xi,yi);
        glEnd();
        xi = xi+dx;
        yi = xi*sin(xi);
    }
    glFlush();
}

int main (int argc, char** argv)
{
    glutInit(&argc, argv);
    /*printf("lower bound: ");
    scanf(" %d",&lb);
    printf("upper bound:");
    scanf(" %d",&ub);
    printf("Give me the number of points to plot (int)");
    scanf(" %d",&cpoints);*/
    glutInitWindowSize(500,500);
    glutCreateWindow("Graph function in 2D");
    init();
    glutDisplayFunc(graphfunct2D);
    glutMainLoop();
}

I want the user to be able to provide the upper and lower bounds and plot the function based on those two but when i run the program with the inputs uncommented it doesnt display anything (when i dont ask for them and use the ones i defined it runs just fine)

  • 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-29T21:48:39+00:00Added an answer on May 29, 2026 at 9:48 pm

    Try something like this:

    #include <GL/glut.h>
    #include <stdlib.h>
    #include <math.h>
    
    double lb=-30, ub=30;
    unsigned int cpoints=2048;
    void graphfunct2D(void)
    {
        double dx, xi, yi;
        int i;
        dx = (ub-lb)/cpoints;
    
        glClearColor(1, 1, 1, 1);
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glOrtho( -30, 30, -30, 30, -1, 1 );
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
    
        glColor3ub(0,0,0);
        glBegin(GL_LINE_STRIP);
        for( i = 0; i <= cpoints; i++ )
        {
            xi = (i * dx) + lb;
            yi = xi * sin(xi);
            glVertex2f( xi, yi );
        }
        glEnd();
        glutSwapBuffers();
    }
    
    int main (int argc, char** argv)
    {
        printf("lower bound: ");
        scanf(" %d",&lb);
        printf("upper bound:");
        scanf(" %d",&ub);
        printf("Give me the number of points to plot (int)");
        scanf(" %d",&cpoints);
    
        glutInit(&argc, argv);
        glutInitDisplayMode(GLUT_RGBA | GLUT_DEPTH | GLUT_DOUBLE);
        glutInitWindowSize(500,500);
        glutCreateWindow("Graph function in 2D");
        glutDisplayFunc(graphfunct2D);
        glutMainLoop();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hidden worksheets/workbooks have some limitations to what can be done in VBA code, like
Can I use Sqlite with IOS using phonegap (with no limitations) ? If you
R class on android has it's limitations. You can't use the resources dynamically for
I would like to know, what limitations there are for how far one can
I have a situation where for size limitations, I can't host the bare repository
Does the erlang TCP/IP library have some limitations? I've done some searching but can't
I want to better understand the capabilities and limitations of what can be done
When adding code to an onclick handler, are there any limitations to what can
Are there different limitations as to how many connections (sockets) that can be created
Is there any limitations on AJAX Calls with ScriptManager to Web Services? I have

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.