I can't get the output of what code, or at least as far as I can tell what should be the output, to show up on my screen. Would anyone be able to help me?
//Draw function using world coordinates and viewport
#define PI 3.14159265359
const int screenWidth = 640;
const int screenHeight = 480;
const int aspectRatio = 2;
void setWindow(float left, float right, float bottom, float top)
gluOrtho2D(left, right, bottom, top);
void setViewport(int left, int right, int bottom, int top)
glViewport(left, bottom, right - left, top - bottom);
glClearColor(1.0, 1.0, 1.0, 0.0);
glColor3f(1.0f, 0.0f, 0.0f);
void myReshape(GLsizei W, GLsizei H)
if (aspectRatio > W/H)
setViewport(0, W, 0, W/aspectRatio);
setViewport(0, H*aspectRatio, 0, H);
setWindow(0.0, (2 * PI), -1.0, 1.0);
setViewport(0, 80, 0, 40);
GLdouble x, y, a;
for (a = 0; a < (2 * PI); a += 0.0005)
x = (10 + sin(15 * a));
y = sin(a);
int main(int argc, char ** argv)
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutCreateWindow("Dot plot a function using world window and viewport.");
I'm trying to do something out of a book I got, it says the formula I shoud use is: "the x coordinate is driven by the parameter a and is given by x(a) = 10 + sin(15 * a) as a varies from 0 to 2PI. The y cordinate is given by y(a) = sin(a), and varies over the same range."
Its supposed to make a squiggly circle but it just comes up with a blank window. Any help would much appreciated.
EDIT: I suppose I should give some info about what I'm using. I'm using the latest version of freeglut, and the latest code::blocks ide. I know its old code(like opengl 1 or something from what my friends have said when they looked at the code). Its for a class, otherwise I'd be learning at least opengl 3.0 instead of this.