My graphing calculator draws a line when y=sin(x)

Viewed 45

So, I'm building a graphing calculator. Basic operations are working all fine, but when I try to write an equation where y is supposed to be the sine or cosine of x, it won't draw the well known curves, but a straight line. Can somebody tell me what's wrong with this? All other operations from math.h like sqrt or tan are working perfectly.

The render function looks like this:

    for (int x = -720/2; x < 720; x++)
        Drawer::drawPixel(x, sin(x));

And the Drawer::drawPixel methode looks like this:

glBegin(GL_POLYGON);
glVertex2f(round(x) +           XOFF,   round(y) +              YOFF  );
glVertex2f(round(x) + SCALE +   XOFF,   round(y) +              YOFF  );
glVertex2f(round(x) + SCALE +   XOFF,   round(y) + SCALE +      YOFF  );
glVertex2f(round(x) +           XOFF,   round(y) + SCALE +      YOFF  );
glEnd();

OpenGL and GLUT were used

0 Answers
Related